示例#1
0
        public ShippingAuthTest()
        {
            string fixedUrl = FixUrl(ServiceConstants.ShippingServiceApiUrl);
            bool   hasHttps = ServiceConstants.ShippingServiceApiUrl.Contains("https");

            Client = new ShippingServiceClient(fixedUrl, ServiceConstants.AllPointsPlatformExtId, hasHttps);
        }
示例#2
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");
            }
        }
示例#3
0
        public UniqueExternalIdentifierPerTenantTest()
        {
            bool shippingApiHasHttps = ServiceConstants.ShippingServiceApiUrl.Contains("https");
            //Gets bearer token
            string bearerToken = GetBearerToken(authName: ServiceConstants.AuthName,
                                                password: ServiceConstants.AuthPassword,
                                                publicKey: ServiceConstants.AuthPublicKey,
                                                shippingApiHasHttps: shippingApiHasHttps);

            AllPointsClient = new ShippingServiceClient(FixUrl(ServiceConstants.ShippingServiceApiUrl), ServiceConstants.AllPointsPlatformExtId, bearerToken, shippingApiHasHttps);
            FmpClient       = new ShippingServiceClient(FixUrl(ServiceConstants.ShippingServiceApiUrl), ServiceConstants.FmpPlatformExtId, bearerToken, shippingApiHasHttps);
        }
示例#4
0
        public DataFactory(DataFactoryConfiguration configuration)
        {
            IIntegrationsWebAppClient integrationsClient    = null;
            IShippingServiceClient    shippingServiceClient = null;

            //empties and nulls validation
            UrlExist(configuration.IntegrationsApiUrl, nameof(configuration.IntegrationsApiUrl));
            UrlExist(configuration.ShippingServiceApiUrl, nameof(configuration.ShippingServiceApiUrl));

            string integrationsApiUrl    = FixHttpOnUrl(configuration.IntegrationsApiUrl);
            string shippingServiceApiUrl = FixHttpOnUrl(configuration.ShippingServiceApiUrl);

            //services initialization
            integrationsClient    = new IntegrationsWebAppClient(integrationsApiUrl, configuration.TenantExternalIdentifier, configuration.TenantInternalIdentifier, configuration.IntegrationsApiUrl.Contains("https"));
            shippingServiceClient = new ShippingServiceClient(shippingServiceApiUrl, configuration.TenantExternalIdentifier, configuration.ShippingServiceApiUrl.Contains("https"));

            //dependencies initialization
            UserAccounts = new TestUserAccountsFactory(integrationsClient);
            Addresses    = new TestAddressesFactory(integrationsClient);
            ShippingConfigurationPreferences = new TestShippingConfigurationFactory(shippingServiceClient);
            ShippingRates = new TestShippingRatesFactory(shippingServiceClient);
        }
示例#5
0
 public TestShippingConfigurationFactory(IShippingServiceClient client)
 {
     _client = client;
 }
示例#6
0
 public ShippingServiceProcessor(IShippingServiceClient initializedClient, string essApiUrl, string tenantExtId)
 {
     Client       = initializedClient;
     _essApiUrl   = essApiUrl;
     _tenantExtId = tenantExtId;
 }
示例#7
0
 public TestShippingRatesFactory(IShippingServiceClient client)
 {
     _client = client;
 }