public void CallTheDataProvider(ICollection<IPointToLaceProvider> response) { try { var api = new ConfigureApi(); if (api.UserToken == Guid.Empty) throw new Exception("Cannot continue calling Lightstone Business Directory Api. User is not valid"); _logCommand.LogSecurity(new {Credentials = new {api.Username, api.Password}}, new {Message = "Lightstone Business Data Provider Credentials"}); var request = new DirectorRequest(_dataProvider.GetRequest<IAmLightstoneBusinessDirectorRequest>()).Map().Validate(); if (!request.IsValid) throw new Exception("Cannot continue call Lightstone Business Director Api. Request is not valid"); _logCommand.LogRequest(new ConnectionTypeIdentifier(api.Client.Endpoint.Address.ToString()).ForWebApiType(), new { _dataProvider }, _dataProvider.BillablleState.NoRecordState); DirectorDataRetriever.Start(api, request).WithReturnDirectors().ThenConfirmDirector().FinallyGetDirectorReport(out _result); _logCommand.LogResponse(_result == null || _result.Tables.Count == 0 ? DataProviderResponseState.NoRecords : DataProviderResponseState.Successful, new ConnectionTypeIdentifier(api.Client.Endpoint.Address.ToString()).ForWebApiType(), new { _result }, _dataProvider.BillablleState.NoRecordState); TransformResponse(response); } catch (Exception ex) { _log.ErrorFormat("Error calling Lightstone Business Director Data Provider {0}", ex, ex.Message); _logCommand.LogFault(ex, new {ErrorMessage = "Error calling Lightstone Business Director Data Provider"}); LightstoneDirectorResponseFailed(response); } }
public static DirectorDataRetriever Start(ConfigureApi api, DirectorRequest request) { return new DirectorDataRetriever(api, request); }
private DirectorDataRetriever(ConfigureApi api, DirectorRequest request) { _api = api; _request = request; }