コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void Authenticate(TestShippingAuthCredential authCredentials)
 {
     _processor.AuthenticateWithToken(authCredentials).Wait();
 }
コード例 #4
0
 public ShippingConfigurationFactory(ShippingServiceProcessor processor, TestShippingAuthCredential authCredentials)
 {
     _processor = processor;
     Authenticate(authCredentials);
 }