/// <inheritdoc/> public virtual async Task <V1Correlation> CreateCorrelationAsync(V1CreateCorrelationCommand command, CancellationToken cancellationToken = default) { if (command == null) { throw new ArgumentNullException(nameof(command)); } return(await this.Mediator.ExecuteAndUnwrapAsync(this.Mapper.Map <Application.Commands.Correlations.V1CreateCorrelationCommand>(command), cancellationToken)); }
/// <inheritdoc/> public virtual async Task <V1Correlation> CreateCorrelationAsync(V1CreateCorrelationCommand command, CancellationToken cancellationToken = default) { var result = await this.Adapter.CreateCorrelationAsync(command, cancellationToken); if (!result.Succeeded) { throw new SynapseApiException(result); } return(result.Data !); }
/// <inheritdoc/> public virtual async Task <V1Correlation> CreateCorrelationAsync(V1CreateCorrelationCommand command, CancellationToken cancellationToken = default) { var requestUri = "/api/v1/correlations"; using var request = this.CreateRequest(HttpMethod.Post, requestUri); var json = await this.Serializer.SerializeAsync(command, cancellationToken); request.Content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json); using var response = await this.HttpClient.SendAsync(request, cancellationToken); json = await response.Content?.ReadAsStringAsync(cancellationToken) !; if (!response.IsSuccessStatusCode) { this.Logger.LogError("An error occured while creating a new correlation: {details}", json); } response.EnsureSuccessStatusCode(); return(await this.Serializer.DeserializeAsync <V1Correlation>(json, cancellationToken)); }