public async Task AuthenticateWithToken(TestShippingAuthCredential authCredential) { var authRequest = new ShippingAuthRequest { Name = authCredential.Name, Password = authCredential.Password, PublicKey = authCredential.PublicKey }; var response = await Client.Token.Authenticate(authRequest); if (!response.Success) { throw new Exception($"Shipping auth request responded with: {response.StatusCode} code"); } //reasign client dependency string essUrl = ApiUrlHelper.GetRequesterFormatUrl(_essApiUrl); Client = new ShippingServiceClient(essUrl, _tenantExtId, response.Result, ApiUrlHelper.UrlContainsHttps(_essApiUrl)); //if response is null, then auth is not success var testResponse = await Client.ShippingConfigurations.GetSingle("string"); if (testResponse == null) { throw new Exception("Endpoints are not authenticated"); } }
public AutomationDataFactory(DataFactoryConfiguration configuration, TestShippingAuthCredential testShippingAuthCredential) { //empties and nulls validation ApiUrlHelper.ValidateUrl(configuration.IntegrationsApiUrl, nameof(configuration.IntegrationsApiUrl)); ApiUrlHelper.ValidateUrl(configuration.ShippingServiceApiUrl, nameof(configuration.ShippingServiceApiUrl)); //clean service api url string integrationsApiUrl = ApiUrlHelper.GetRequesterFormatUrl(configuration.IntegrationsApiUrl); string shippingServiceApiUrl = ApiUrlHelper.GetRequesterFormatUrl(configuration.ShippingServiceApiUrl); string tenantUrl = ApiUrlHelper.GetRequesterFormatUrl(configuration.TenantSiteUrl); //clients initialization var integrationsClient = new IntegrationsWebAppClient(integrationsApiUrl, configuration.TenantExternalIdentifier, configuration.TenantInternalIdentifier, configuration.IntegrationsApiUrl.Contains("https")); var shippingServiceClient = new ShippingServiceClient(shippingServiceApiUrl, configuration.TenantExternalIdentifier, configuration.ShippingServiceApiUrl.Contains("https")); //dependencies setup var usersProcessor = new UserAccountsProcessor(integrationsClient); Users = new UserAccountsFactory(usersProcessor); var shippingProcessor = new ShippingServiceProcessor(shippingServiceClient, configuration.ShippingServiceApiUrl, configuration.TenantExternalIdentifier); Shipping = new ShippingConfigurationFactory(shippingProcessor, testShippingAuthCredential); var productsProcessor = new MerchandiseProcessor(integrationsClient); Products = new ProductsFactory(productsProcessor, tenantUrl); }
public void Authenticate(TestShippingAuthCredential authCredentials) { _processor.AuthenticateWithToken(authCredentials).Wait(); }
public ShippingConfigurationFactory(ShippingServiceProcessor processor, TestShippingAuthCredential authCredentials) { _processor = processor; Authenticate(authCredentials); }