/// <summary> /// Acknowledges a notification as having been processed. /// </summary> /// <param name="factorySettings"></param> /// <param name="authenticationSettings"></param> /// <param name="acknowledgement"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task AcknowledgeNotification(ApiClientFactorySettings factorySettings, AuthenticationHelperSettings authenticationSettings, ConnectorNotificationAcknowledgeModel acknowledgement, CancellationToken cancellationToken = default(CancellationToken)) { var client = _apiClientFactory.CreateApiClient(factorySettings); var policy = ApiClientRetryPolicy.GetPolicy(MaxRetryAttempts, cancellationToken); var acknowledgementResponse = await policy.ExecuteAsync( async() => { var authHelper = _apiClientFactory.CreateAuthenticationHelper(); var headers = await authHelper.GetHttpRequestHeaders(authenticationSettings).ConfigureAwait(false); var response = await client.ApiNotificationsPostWithHttpMessagesAsync(acknowledgement, customHeaders: headers, cancellationToken: cancellationToken).ConfigureAwait(false); return(response); } ).ConfigureAwait(false); if (acknowledgementResponse.Response.StatusCode == HttpStatusCode.NotFound) { throw new ResourceNotFoundException($"Notification with ID [{acknowledgement.NotificationId}] was not found. It may have already been acknowledged."); } // TODO: add more comprehensive handling of the response codes }
public Task AcknowledgeNotification(ApiClientFactorySettings factorySettings, AuthenticationHelperSettings authenticationSettings, ConnectorNotificationAcknowledgeModel acknowledgement, CancellationToken cancellationToken = default(CancellationToken)) { if (!Dictionary.TryRemove(acknowledgement.NotificationId, out var dummy)) { throw new ResourceNotFoundException(); } return(Task.FromResult(0)); }