Ejemplo n.º 1
0
        public async Task PUT_ShippingAccountMaster_Invalid()
        {
            string accountMasterExtId = "notFound";

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = 0,
                        ThresholdAmount  = 0
                    }
                },
                UseCustomerCarrier = true,
                ShippingConfigurationExternalId = "ShippingConfigurationExternalId",
                FlatRateScheduleGroupExternalId = "FlatRateScheduleGroupExternalId",
                HandlingScheduleGroupExternalId = "HandlingScheduleGroupExternalId"
            };

            HttpEssResponse <ShippingAccountMasterPreferencesResponse> response = await Client.ShippingAccountMasterPreferences.Update(accountMasterExtId, request);

            Assert.IsNotNull(response);
            Assert.AreEqual(422, response.StatusCode);
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Result);
        }
Ejemplo n.º 2
0
        public async Task PUT_ShippingAccountMaster_NotFound()
        {
            string accountMasterExtId = "updateCase03";

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                UpdatedBy        = accountMasterExtId,
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = 1,
                        ThresholdAmount  = 1
                    }
                },
                UseCustomerCarrier = true
            };

            HttpEssResponse <ShippingAccountMasterPreferencesResponse> response = await Client.ShippingAccountMasterPreferences.Update(accountMasterExtId, request);

            Assert.IsNotNull(response);
            Assert.AreEqual(404, response.StatusCode);
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Result);
        }
Ejemplo n.º 3
0
        public async Task CreateAccountPreferences(string identifier, string accountMasterId, TestShippingPreferences preferences)
        {
            //TODO
            //validation:
            //at this step the configuration should exist

            //create handling and  flat rate generic groups
            await CreateEmptyGroups(identifier, identifier);

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "Data factory tool",
                FlatRateScheduleGroupExternalId = identifier,
                HandlingScheduleGroupExternalId = identifier,
                ShippingConfigurationExternalId = identifier,
                UseCustomerCarrier = preferences.UseCustomerCarrier,
                FreeFreightForNonContiguousStates = preferences.FreeFreightForNonContiguousStates,
                FreeFreightRules  = MapAccountFreeFreightRules(preferences.FreeFreightRuless),
                FreeHandlingRules = MapFreeHandlingRules(preferences.FreeHandlingRules),
                UseBestRate       = preferences.UseBestRate
            };
            var response = await Client.ShippingAccountMasterPreferences.Create(accountMasterId, request);

            if (!response.Success)
            {
                throw new Exception($"Cannot add the given account shipping preferences ~> error code: {response.StatusCode}");
            }
        }
Ejemplo n.º 4
0
        public async Task POST_ShippingAccountMaster_Invalid()
        {
            //does not need to exist
            string accountMasterExtId = "fakeAccountMasterExtId";

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                //does not have the CreatedBy property
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = 1,
                        ThresholdAmount  = 1
                    }
                },
                UseCustomerCarrier = true,
                ShippingConfigurationExternalId = "",
                FlatRateScheduleGroupExternalId = "",
                HandlingScheduleGroupExternalId = ""
            };

            HttpEssResponse <ShippingAccountMasterPreferencesResponse> response = await Client.ShippingAccountMasterPreferences.Create(accountMasterExtId, request);

            Assert.IsNotNull(response);
            Assert.AreEqual(422, response.StatusCode);
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Result);
        }
Ejemplo n.º 5
0
        protected override async Task TestScenarioSetUp(ShippingPreferenceTestData data)
        {
            //create shipping configuration
            ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = data.ShippingConfigurationExtId,
                ServiceLevels      = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Code                = (int)ServiceLevelCodesEnum.Ground,
                        Amount              = 200,
                        CarrierCode         = "nothing",
                        IsEnabled           = true,
                        Label               = "temporal label",
                        SortOrder           = 2,
                        CarrierRateDiscount = 2
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create flat rate schedule group
            FlatRateScheduleGroupsRequest flatRateScheduleGroupsRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = data.FlatRateScheduleGroupExtId,
                Name = "temporal name"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupsRequest);

            //create handling schedule group
            HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = data.HandlingScheduleGroupExtId,
                Name = "temporal name"
            };
            await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest);

            //create account master shipping preference
            ShippingAccountMasterPreferencesRequest shippingAccountMasterPreferencesRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "temporal request",
                ShippingConfigurationExternalId = data.ShippingConfigurationExtId,
                FlatRateScheduleGroupExternalId = data.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = data.HandlingScheduleGroupExtId,
                UseCustomerCarrier = false,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Showroom,
                        ThresholdAmount  = 2
                    }
                },
            };
            await Client.ShippingAccountMasterPreferences.Create(data.AccountMasterExtId, shippingAccountMasterPreferencesRequest);
        }
Ejemplo n.º 6
0
        public async Task PUT_ShippingAccountMaster_FreeFreightRules_Success()
        {
            ShippingPreferenceTestData testData = new ShippingPreferenceTestData
            {
                AccountMasterExtId         = "putShippingAm01",
                ShippingConfigurationExtId = "putShippingAmShippConf01",
                HandlingScheduleGroupExtId = "putShippingAmHdScheduleGroup01",
                FlatRateScheduleGroupExtId = "putShippingAmFrScheduleGroup01"
            };

            //test scenario setup
            await TestScenarioSetUp(testData);

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                UpdatedBy        = "PUT request",
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = 1,
                        ThresholdAmount  = 10
                    }
                },
                UseCustomerCarrier = true,
                ShippingConfigurationExternalId = testData.ShippingConfigurationExtId,
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };

            HttpEssResponse <ShippingAccountMasterPreferencesResponse> response = await Client.ShippingAccountMasterPreferences.Update(testData.AccountMasterExtId, request);

            //clear generated test data
            await TestScenarioCleanUp(testData);

            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Result);

            //specific put validations
            Assert.AreEqual(request.UpdatedBy, response.Result.UpdatedBy);
            Assert.AreEqual(request.UseCustomerCarrier, response.Result.UseCustomerCarrier);
            Assert.AreEqual(request.FreeFreightRules.FirstOrDefault().ThresholdAmount, response.Result.FreeFreightRules.FirstOrDefault().ThresholdAmount);
            //Assert.AreEqual(request.FreeFreightRules.FirstOrDefault().ThresholdAmount, response.Result.FreeFreightRules.FirstOrDefault().ThresholdAmount);
        }
Ejemplo n.º 7
0
        public async Task AddAccountPreferences(TestShippingExternals externalIds, TestShippingPreferences preferences)
        {
            //create handling and  flat rate generic groups
            await CreateEmptyGroups(externalIds.FlatRateGroupExtId, externalIds.HandlingGroupExtId);

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "Data factory tool",
                FlatRateScheduleGroupExternalId = externalIds.FlatRateGroupExtId,
                HandlingScheduleGroupExternalId = externalIds.HandlingGroupExtId,
                UseCustomerCarrier = preferences.UseCustomerCarrier,
                ShippingConfigurationExternalId = preferences.ConfigurationExtId,
                FreeFreightRules = preferences.FreeFreightRules,
                FreeFreightForNonContiguousStates = preferences.FreeFreightForNonContiguousStates,
                UseBestRate = preferences.UseBestRate
            };
            var response = await _client.ShippingAccountMasterPreferences.Create(externalIds.AccountMasterExtId, request);

            if (!response.Success)
            {
                throw new Exception("Cannot add the given account shipping preferences");
            }
        }
Ejemplo n.º 8
0
        public async Task POST_ShippingAccountMaster_Success()
        {
            string accountMasterExtId = "postAccountMasterShippingPref01";

            ShippingPreferenceTestData testData = new ShippingPreferenceTestData
            {
                AccountMasterExtId         = accountMasterExtId,
                ShippingConfigurationExtId = "postShippingPrefShippConfig01",
                FlatRateScheduleGroupExtId = "postShippingPrefFrScheduleGroup01",
                HandlingScheduleGroupExtId = "postShippingPrefHdScheduleGroup01"
            };

            //create shipping configuration
            ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.ShippingConfigurationExtId,
                ServiceLevels      = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Code                = (int)ServiceLevelCodesEnum.Ground,
                        Amount              = 200,
                        CarrierCode         = "nothing",
                        IsEnabled           = true,
                        Label               = "temporal label",
                        SortOrder           = 2,
                        CarrierRateDiscount = 2
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create flat rate schedule group
            FlatRateScheduleGroupsRequest flatRateScheduleGroupsRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                Name = "temporal name"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupsRequest);

            //create handling schedule group
            HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                Name = "temporal name"
            };
            await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest);

            ShippingAccountMasterPreferencesRequest request = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy        = "post request success",
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = 1,
                        ThresholdAmount  = 1
                    }
                },
                FreeHandlingRules = new List <FreeHandlingRule>
                {
                    new FreeHandlingRule
                    {
                        ServiceLevelCode = 1,
                        ThresholdAmount  = 109
                    }
                },
                UseCustomerCarrier = true,
                ShippingConfigurationExternalId = testData.ShippingConfigurationExtId,
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };

            HttpEssResponse <ShippingAccountMasterPreferencesResponse> response = await Client.ShippingAccountMasterPreferences.Create(accountMasterExtId, request);

            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Result);

            await TestScenarioCleanUp(testData);
        }
Ejemplo n.º 9
0
        public async Task POST_ShippingAccountMaster_DoesNotAllowDuplicateServiceLevels_Success()
        {
            string identifier = "postAmPreferenceNoDuplicateFrRules01";
            string createdBy  = "temporal test request";

            var testData = new ShippingPreferenceTestData
            {
                AccountMasterExtId         = identifier,
                FlatRateScheduleGroupExtId = identifier,
                HandlingScheduleGroupExtId = identifier,
                ShippingConfigurationExtId = identifier
            };

            //create groups
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = createdBy,
                ExternalIdentifier = identifier,
                Name = "flat rate group"
            };
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = createdBy,
                ExternalIdentifier = identifier,
                Name = "handling rate group",
            };
            var configurationRequest = new ShippingConfigurationRequest
            {
                ExternalIdentifier      = identifier,
                CreatedBy               = createdBy,
                DefaultServiceLevelCode = null,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Amount              = 0,
                        CarrierCode         = string.Empty,
                        CarrierRateDiscount = 0.05,
                        IsEnabled           = true,
                        Code      = (int)ServiceLevelCodesEnum.Local,
                        Label     = ServiceLevelCodesEnum.Local.ToString(),
                        SortOrder = 0
                    }
                }
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            await Client.ShippingConfigurations.Create(configurationRequest);

            var request = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = createdBy,
                FlatRateScheduleGroupExternalId   = flatRateGroupRequest.ExternalIdentifier,
                HandlingScheduleGroupExternalId   = handlingGroupRequest.ExternalIdentifier,
                FreeFreightForNonContiguousStates = false,
                UseCustomerCarrier = false,
                ShippingConfigurationExternalId = configurationRequest.ExternalIdentifier,
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                        ThresholdAmount  = 150
                    },
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                        ThresholdAmount  = 500
                    }
                }
            };

            var response = await Client.ShippingAccountMasterPreferences.Create(identifier, request);

            //test data clean up
            await TestScenarioCleanUp(testData);

            //validations
            Assert.IsNotNull(response, "response object should not ");

            //specific validations
            Assert.IsNull(response.Result, "result object should not be null");
            Assert.IsFalse(response.Success);
        }
Ejemplo n.º 10
0
        public async Task GET_Shipment_Warning312()
        {
            ShipmentTestData testData = new ShipmentTestData
            {
                AccountMasterExtId         = "accountM01Warning12",
                ShippingConfigExtId        = "shippingConfigShipment02",
                FlatRateScheduleGroupExtId = "flatRateGroupShipment02",
                FlatRateScheduleExtId      = "flatRateShipment02",
                HandlingScheduleGroupExtId = "handlingGroupShipment02",
                HandlingScheduleExtId      = "handlingShipment02"
            };

            string expectedDescription = "No destination address provided";
            int    expectedCode        = 312;

            await TestScenarioCleanUp(testData);

            //create shipping configuration
            var shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy               = "temporal shipmentrequest",
                ExternalIdentifier      = testData.ShippingConfigExtId,
                DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Ground,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Label             = "Shipment 312 req",
                        Amount            = 12,
                        CalculationMethod = "nothing",
                        CarrierCode       = "312",
                        Code                = (int)ServiceLevelCodesEnum.Ground,
                        SortOrder           = 5,
                        IsEnabled           = true,
                        CarrierRateDiscount = 0.6
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create flat rate group
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                CreatedBy          = "temporal shipment request",
                Name = "shipment group"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            //create handling group
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                CreatedBy          = "temporal shipment request",
                Name = "shipment group"
            };
            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            //create handling schedule
            var handlingScheduleRequest = new HandlingScheduleRequest
            {
                CreatedBy          = "shipment request",
                OrderAmountMin     = 1,
                OrderAmountMax     = 2,
                Rate               = 1,
                ExternalIdentifier = testData.HandlingScheduleExtId,
                ServiceLevelCode   = (int)ServiceLevelCodesEnum.Ground,
            };
            await Client.HandlingSchedules.Create(handlingScheduleRequest);

            //link handling schedule with group
            var handlingScheduleConfigurationRequest = new HandlingSchedulesConfigurationRequest
            {
                CreatedBy = "shipment temporal request"
            };
            await Client.HandlingScheduleConfigurations
            .Create(testData.HandlingScheduleGroupExtId, testData.HandlingScheduleExtId, handlingScheduleConfigurationRequest);

            //create shipping preference
            var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "temporal request",
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                UseCustomerCarrier = false,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                        ThresholdAmount  = 0
                    }
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            //get shipment request
            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000001",
                ShipFromAddress = new Address
                {
                    AddressLine1        = "sample street",
                    AddressLine2        = "apt 2",
                    City                = "boulder",
                    Country             = "us",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "co"
                },
                //no destination address
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        ProductSku            = "sample string",
                        CheckoutPriceExtended = 18.33m,
                        Quantity = 1,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 12,
                            IsFreeShip        = false,
                            Length            = 12,
                            IsFreightOnly     = false,
                            IsQuickShip       = false,
                            WeightDimensional = 12.5m,
                            WeightActual      = 17,
                            FreightClass      = 12
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //clear test entities
            await TestScenarioCleanUp(testData);

            //generic endpoint validations
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success, "Response status is not successful");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            //specific validations
            Assert.AreEqual(expectedCode, response.StatusCode);
            Assert.AreEqual(expectedDescription, response.Description);
        }
Ejemplo n.º 11
0
        public async Task GET_Shipment_FlatRateAndHandling_Success()
        {
            string identifier = "shipmentTestD104";

            ShipmentTestData testData = new ShipmentTestData
            {
                AccountMasterExtId         = identifier,
                FlatRateScheduleGroupExtId = identifier,
                HandlingScheduleGroupExtId = identifier,
                ShippingConfigExtId        = identifier,
                FlatRateScheduleExtId      = identifier,
                HandlingScheduleExtId      = identifier
            };

            //create flat rate schedule group
            FlatRateScheduleGroupsRequest flatRateScheduleGroupRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = identifier,
                ExternalIdentifier = identifier,
                Name = identifier
            };
            await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupRequest);

            //create handling schedule group
            HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                Name = "free handling"
            };
            await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest);

            //create a flat rate schedule
            FlatRateScheduleRequest flatRateScheduleRequest = new FlatRateScheduleRequest
            {
                CreatedBy          = "temporal test request",
                ServiceLevelCode   = (int)ServiceLevelCodesEnum.NextDay,
                ExternalIdentifier = testData.FlatRateScheduleExtId,
                Rate           = 150,
                OrderAmountMin = 100,
                OrderAmountMax = 1000
            };
            await Client.FlatRateSchedules.Create(flatRateScheduleRequest);

            //create a flat rate and group schedules
            FlatRateScheduleConfigurationRequest flatRateScheduleConfigurationRequest = new FlatRateScheduleConfigurationRequest
            {
                CreatedBy = "temporal test request"
            };
            await Client.FlatRateScheduleConfigurations.Create(testData.FlatRateScheduleGroupExtId, testData.FlatRateScheduleExtId, flatRateScheduleConfigurationRequest);

            //create handling schedule
            HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest
            {
                CreatedBy          = "temporal test request",
                ExternalIdentifier = testData.HandlingScheduleExtId,
                OrderAmountMin     = 100,
                OrderAmountMax     = 1000,
                Rate             = 50,
                ServiceLevelCode = (int)ServiceLevelCodesEnum.NextDay
            };
            await Client.HandlingSchedules.Create(handlingScheduleRequest);

            //link handling schedule with group
            HandlingSchedulesConfigurationRequest handlingSchedulesConfigurationRequest = new HandlingSchedulesConfigurationRequest
            {
                CreatedBy = "temporal test request"
            };
            await Client.HandlingScheduleConfigurations.Create(handlingScheduleGroupRequest.ExternalIdentifier, handlingScheduleRequest.ExternalIdentifier, handlingSchedulesConfigurationRequest);

            //create shipping configuration
            ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy               = "temporal test request",
                ExternalIdentifier      = testData.ShippingConfigExtId,
                DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Amount = 200,
                        CarrierRateDiscount = 0.5,
                        SortOrder           = 1,
                        Label             = "temporal label",
                        CalculationMethod = "nothing",
                        IsEnabled         = true,
                        CarrierCode       = "nothing",
                        Code = (int)ServiceLevelCodesEnum.NextDay
                    },
                    new SCServiceLevel
                    {
                        Amount = 300,
                        CarrierRateDiscount = 0.5,
                        SortOrder           = 0,
                        Label             = "temporal label",
                        CalculationMethod = "nothing",
                        IsEnabled         = true,
                        CarrierCode       = "nothing",
                        Code = (int)ServiceLevelCodesEnum.Local
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create shippingPreference for accountMaster
            ShippingAccountMasterPreferencesRequest shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy          = "temporal test request",
                UseCustomerCarrier = false,
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000002",
                ShipFromAddress = new Address
                {
                    AddressLine1        = "Denver Boulder Turnpike",
                    AddressLine2        = "",
                    City                = "Boulder",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "80014",
                    StateProvinceRegion = "CO"
                },
                ShipToAddress = new Address
                {
                    AddressLine1        = "Denver Boulder Turnpike",
                    AddressLine2        = string.Empty,
                    City                = "Boulder",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "CO"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        Quantity = 1,
                        CheckoutPriceExtended = 110,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 12,
                            IsFreeShip        = false,
                            Length            = 12,
                            IsFreightOnly     = false,
                            IsQuickShip       = false,
                            WeightDimensional = 12m,
                            WeightActual      = 2,
                            FreightClass      = 2
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //test data clean up
            await TestScenarioCleanUp(testData);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success, "Response status is not successful");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            //specific validations
            var shippingFlatRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == flatRateScheduleRequest.ServiceLevelCode);

            //this code checks all ServiceLevels, none of them is returning a handling value
            //date: 10/03/2020
            //int i = 0;
            //while(true)
            //{
            //    bool exists = Enum.IsDefined(typeof(ServiceLevelCodesEnum), i);
            //    if (exists)
            //    {
            //        flatRateScheduleRequest.ServiceLevelCode = i;
            //        shippingFlatRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == flatRateScheduleRequest.ServiceLevelCode);
            //    }
            //    i++;
            //    if (shippingFlatRate == null) continue;
            //    if (shippingFlatRate.Handling != null) break;
            //}

            //flat rate validations
            Assert.IsTrue(shippingFlatRate.IsFlatRate, $"{nameof(shippingFlatRate.IsFlatRate)} prop should be true");
            Assert.AreEqual(flatRateScheduleRequest.Rate, shippingFlatRate.Amount);

            //handling validations
            //Handlig value returned  = null
            //TO:DO  make handling don't return null
            Assert.AreEqual(null, shippingFlatRate.Handling);
            //Assert.AreEqual(handlingScheduleRequest.Rate, shippingFlatRate.Handling);
        }
Ejemplo n.º 12
0
        public async Task<HttpEssResponse<ShippingAccountMasterPreferencesResponse>> Update(string accountMasterExtId, ShippingAccountMasterPreferencesRequest request)
        {
            MethodUrl = $"/{accountMasterExtId}/shippingPreferences";
            string stringPayload = await Task.Run(() => JsonConvert.SerializeObject(request));
            var response = await Put("", stringPayload);

            return response;
        }
Ejemplo n.º 13
0
        public async Task GET_Shipment_NoDefaultServiceLevel()
        {
            ShipmentTestData testData = new ShipmentTestData
            {
                ShippingConfigExtId        = "postShippingConfig03",
                AccountMasterExtId         = "accountMasterA",
                FlatRateScheduleGroupExtId = "AflatRateScGroup",
                HandlingScheduleGroupExtId = "AhandlingScGroup",
                FlatRateScheduleExtId      = "AflatRateSchedule",
                HandlingScheduleExtId      = "AhandlingSchedule"
            };

            int    expectedServiceLevel = (int)ServiceLevelCodesEnum.Showroom;
            double expectedAmount       = 100;

            ShippingConfigurationRequest shippingConfigRequest = new ShippingConfigurationRequest
            {
                ExternalIdentifier = testData.ShippingConfigExtId,
                CreatedBy          = "C# requester",
                //No default service level code
                DefaultServiceLevelCode = null,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Code                = (int)ServiceLevelCodesEnum.Showroom,
                        Label               = "label showroom",
                        SortOrder           = 0,
                        Amount              = 200,
                        IsEnabled           = true,
                        CalculationMethod   = "string 1",
                        CarrierCode         = "some string",
                        CarrierRateDiscount = 0.1
                    },
                    new SCServiceLevel
                    {
                        CalculationMethod = "string",
                        Amount            = 100,
                        Code = (int)ServiceLevelCodesEnum.NextDay,
                        CarrierRateDiscount = .99,
                        CarrierCode         = "string",
                        IsEnabled           = true,
                        Label     = "string",
                        SortOrder = 1
                    },
                    new SCServiceLevel
                    {
                        Code                = (int)ServiceLevelCodesEnum.Ground,
                        Label               = "grounded temporal",
                        SortOrder           = 3,
                        Amount              = expectedAmount,
                        IsEnabled           = true,
                        CalculationMethod   = "string 1",
                        CarrierCode         = "some string",
                        CarrierRateDiscount = .99,
                    }
                }
            };
            var shippingConfResponse = await Client.ShippingConfigurations.Create(shippingConfigRequest);

            //check the sort order for the given service levels
            Assert.AreEqual(expectedServiceLevel, shippingConfResponse.Result.DefaultServiceLevelCode);

            //create flat rate group
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                CreatedBy          = "temporal request",
                Name = "shipment group"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            //create handling group
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                CreatedBy          = "temporal request",
                Name = "shipment group"
            };
            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            //create shipping preferences
            var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "temporal shipment request",
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                UseCustomerCarrier = false,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                ShipFromAddress = new Address
                {
                    AddressLine1        = "sample street",
                    AddressLine2        = "apt 2",
                    City                = "Denver",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "80019",
                    StateProvinceRegion = "CO"
                },
                ShipToAddress = new Address
                {
                    AddressLine1        = "any street",
                    AddressLine2        = string.Empty,
                    City                = "boulder",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "80019",
                    StateProvinceRegion = "CO"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        Quantity = 1,
                        CheckoutPriceExtended = 100,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 12,
                            IsFreeShip        = false,
                            Length            = 12,
                            IsFreightOnly     = false,
                            IsQuickShip       = false,
                            WeightDimensional = 12m,
                            WeightActual      = 2,
                            FreightClass      = 2
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //test scenario clean up
            await TestScenarioCleanUp(testData);

            //validations
            Assert.IsNotNull(response, "Response is null");
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success, "Response status is not successful");
            Assert.IsNotNull(response.Result);

            //specific validations
            Assert.AreEqual(expectedServiceLevel, response.Result.DefaultShipmentRate.ServiceLevelCode);
        }
Ejemplo n.º 14
0
        public async Task GET_Shipment_Warning313()
        {
            ShipmentTestData testData = new ShipmentTestData
            {
                ShippingConfigExtId        = "shippingConfigShipment03",
                AccountMasterExtId         = "accountM01Warning13",
                FlatRateScheduleGroupExtId = "flatRateGroupShipment03",
                HandlingScheduleGroupExtId = "hadnlingGroupShipment03"
            };

            int serviceLevelCode   = (int)ServiceLevelCodesEnum.Showroom;
            int rateTypePreference = 1;//Standard = 1?

            int    expectedCode        = 313;
            string expectedDescription = "Use Customer Carrier";

            await TestScenarioCleanUp(testData);

            //create shipping configuration
            var shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.ShippingConfigExtId,
                ServiceLevels      = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Label             = "sample label",
                        Amount            = 2,
                        CalculationMethod = "nothing",
                        CarrierCode       = "string",
                        Code                = (int)ServiceLevelCodesEnum.Showroom,
                        SortOrder           = 5,
                        IsEnabled           = true,
                        CarrierRateDiscount = 15
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create a flat rate group
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                Name = "shipment group flat rate"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            //create a handling group
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = "shipment temporal request",
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                Name = "shipment group handling"
            };
            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            //create an accountMaster shipping preference
            var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "shipment temporal request",
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                UseCustomerCarrier = true,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = serviceLevelCode,
                        ThresholdAmount  = 0
                    }
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000001",
                ShipFromAddress = new Address
                {
                    AddressLine1        = "sample street",
                    AddressLine2        = "apt 2",
                    City                = "boulder",
                    Country             = "us",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "co"
                },
                ShipToAddress = new Address
                {
                    AddressLine1        = "any street",
                    AddressLine2        = "C",
                    City                = "boulder",
                    Country             = "us",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "co"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        ProductSku            = "sample string",
                        CheckoutPriceExtended = 18.33m,
                        Quantity = 2,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 12,
                            IsFreeShip        = true,
                            Length            = 12,
                            IsFreightOnly     = true,
                            IsQuickShip       = true,
                            WeightDimensional = 12.5m,
                            WeightActual      = 12,
                            FreightClass      = 12
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //clear test scenario
            await TestScenarioCleanUp(testData);

            //validations
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success, "Response status is not successful");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            //specific validations
            Assert.AreEqual(expectedCode, response.StatusCode);
            Assert.AreEqual(expectedDescription, response.Description);
        }
Ejemplo n.º 15
0
        public async Task GET_Shipment_Warning310()
        {
            ShipmentTestData testData = new ShipmentTestData
            {
                AccountMasterExtId         = "accountM01Warning10",
                ShippingConfigExtId        = "shippingConfigShipment01",
                FlatRateScheduleGroupExtId = "flatRateGroupShipment01",
                HandlingScheduleGroupExtId = "handlingGroupShipment01",
            };

            string expectedDescription = ">150 lbs";
            int    expectedCode        = 310;

            //create shipping configuration
            var shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.ShippingConfigExtId,
                ServiceLevels      = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Label             = "sample label",
                        Amount            = 2,
                        CalculationMethod = "nothing",
                        CarrierCode       = "string",
                        Code                = (int)ServiceLevelCodesEnum.Showroom,
                        SortOrder           = 5,
                        IsEnabled           = true,
                        CarrierRateDiscount = 15
                    },
                    new SCServiceLevel
                    {
                        Amount              = 4,
                        CalculationMethod   = "nothing",
                        CarrierCode         = "nothing",
                        CarrierRateDiscount = 1,
                        Code      = (int)ServiceLevelCodesEnum.NextDay,
                        SortOrder = 3,
                        IsEnabled = true,
                        Label     = "temporal label"
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create flat rate group
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                CreatedBy          = "temporal request",
                Name = "shipment group"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            //create handling group
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                CreatedBy          = "temporal request",
                Name = "shipment group"
            };
            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            //create shipping preferences
            var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "temporal shipment request",
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                UseCustomerCarrier = false,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Threeday,
                        ThresholdAmount  = 1
                    }
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000002",
                ShipFromAddress = new Address
                {
                    AddressLine1        = "sample street",
                    AddressLine2        = "apt 2",
                    City                = "boulder",
                    Country             = "us",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "co"
                },
                ShipToAddress = new Address
                {
                    AddressLine1        = "sample street",
                    AddressLine2        = "apt 2",
                    City                = "mexico",
                    Country             = "mx",
                    Name                = "stk",
                    Postal              = "1234567",
                    StateProvinceRegion = "B.C"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        ProductSku            = "sample string",
                        CheckoutPriceExtended = 18.33m,
                        Quantity = 2,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 180,
                            Height            = 190,
                            IsFreeShip        = true,
                            Length            = 200,
                            IsFreightOnly     = true,
                            IsQuickShip       = true,
                            WeightDimensional = 19,
                            WeightActual      = 19,
                            FreightClass      = 15
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //clear all test entities
            await TestScenarioCleanUp(testData);

            //generic endpoint validations
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success, $"Response status is not successful ({response.StatusCode})");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            //specific validations
            Assert.AreEqual(expectedCode, response.StatusCode);
            Assert.AreEqual(expectedDescription, response.Description);
        }
Ejemplo n.º 16
0
        public async Task PATCH_ShippingAccountMaster_FreeHandlingRulesOnResponse_Success()
        {
            string identifier = "patchAmPreferenceFhRulesOnResponse04";
            string createdBy  = "temporal test request";

            var testData = new ShippingPreferenceTestData
            {
                AccountMasterExtId         = identifier,
                FlatRateScheduleGroupExtId = identifier,
                HandlingScheduleGroupExtId = identifier,
                ShippingConfigurationExtId = identifier
            };
            var expectedFhRule1 = new FreeHandlingRule
            {
                ServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                ThresholdAmount  = 150
            };
            var expectedFhRule2 = new FreeHandlingRule
            {
                ServiceLevelCode = (int)ServiceLevelCodesEnum.Ground,
                ThresholdAmount  = 500
            };

            //create groups
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = createdBy,
                ExternalIdentifier = identifier,
                Name = "flat rate group"
            };
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = createdBy,
                ExternalIdentifier = identifier,
                Name = "handling rate group",
            };
            var configurationRequest = new ShippingConfigurationRequest
            {
                ExternalIdentifier      = identifier,
                CreatedBy               = createdBy,
                DefaultServiceLevelCode = null,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Amount              = 0,
                        CarrierCode         = string.Empty,
                        CarrierRateDiscount = 0.05,
                        IsEnabled           = true,
                        Code      = (int)ServiceLevelCodesEnum.Local,
                        Label     = ServiceLevelCodesEnum.Local.ToString(),
                        SortOrder = 0
                    }
                }
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            await Client.ShippingConfigurations.Create(configurationRequest);

            var request = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = createdBy,
                FlatRateScheduleGroupExternalId   = flatRateGroupRequest.ExternalIdentifier,
                HandlingScheduleGroupExternalId   = handlingGroupRequest.ExternalIdentifier,
                FreeFreightForNonContiguousStates = false,
                UseCustomerCarrier = false,
                ShippingConfigurationExternalId = configurationRequest.ExternalIdentifier,
                FreeHandlingRules = new List <FreeHandlingRule>
                {
                    expectedFhRule1,
                    expectedFhRule2
                }
            };

            var response = await Client.ShippingAccountMasterPreferences.Create(identifier, request);

            //basic post validations
            Assert.IsNotNull(response, "response object should not ");
            Assert.IsNotNull(response.Result, "result object should not be null");

            //PATCH request
            var patchRequest  = new { UpdatedBy = "patch request" };
            var patchResponse = await Client.ShippingAccountMasterPreferences.PatchEntity(testData.AccountMasterExtId, patchRequest);

            //test data clean up
            await TestScenarioCleanUp(testData);

            //specific validations
            Assert.IsNotNull(patchResponse.Result.FreeFreightRules, "FreeHandlingRules are not in the response object");
            Assert.AreEqual(expectedFhRule1.ServiceLevelCode, patchResponse.Result.FreeHandlingRules.FirstOrDefault().ServiceLevelCode);
            Assert.AreEqual(expectedFhRule1.ThresholdAmount, patchResponse.Result.FreeHandlingRules.FirstOrDefault().ThresholdAmount);
            Assert.AreEqual(expectedFhRule2.ServiceLevelCode, patchResponse.Result.FreeHandlingRules.ElementAt(1).ServiceLevelCode);
            Assert.AreEqual(expectedFhRule2.ThresholdAmount, patchResponse.Result.FreeHandlingRules.ElementAt(1).ThresholdAmount);
        }
Ejemplo n.º 17
0
        public async Task GET_Shipment_OnlyHandling_Success()
        {
            string identifier = "shipmentFlatRate01";

            ShipmentTestData testData = new ShipmentTestData
            {
                AccountMasterExtId         = identifier,
                FlatRateScheduleGroupExtId = identifier,
                HandlingScheduleGroupExtId = identifier,
                ShippingConfigExtId        = identifier,
                HandlingScheduleExtId      = identifier
            };

            //create flat rate schedule group
            FlatRateScheduleGroupsRequest flatRateScheduleGroupRequest = new FlatRateScheduleGroupsRequest
            {
                CreatedBy          = "temporal test request",
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                Name = "cheap flat rate"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupRequest);

            //create handling schedule group
            HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest
            {
                CreatedBy          = "temporal request",
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                Name = "free handling"
            };
            await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest);

            //create handling schedule
            HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest
            {
                CreatedBy          = "temporal test request",
                ExternalIdentifier = testData.HandlingScheduleExtId,
                OrderAmountMin     = 0,
                OrderAmountMax     = 1000,
                Rate             = 50,
                ServiceLevelCode = (int)ServiceLevelCodesEnum.Local
            };
            await Client.HandlingSchedules.Create(handlingScheduleRequest);

            //link handling schedule with group
            HandlingSchedulesConfigurationRequest handlingSchedulesConfigurationRequest = new HandlingSchedulesConfigurationRequest
            {
                CreatedBy = "temporal test request"
            };
            await Client.HandlingScheduleConfigurations.Create(handlingScheduleGroupRequest.ExternalIdentifier, handlingScheduleRequest.ExternalIdentifier, handlingSchedulesConfigurationRequest);

            //create shipping configuration
            ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy               = "temporal test request",
                ExternalIdentifier      = testData.ShippingConfigExtId,
                DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Amount = 200,
                        CarrierRateDiscount = 0,
                        SortOrder           = 1,
                        Label             = "temporal label",
                        CalculationMethod = "nothing",
                        IsEnabled         = true,
                        CarrierCode       = "nothing",
                        Code = (int)ServiceLevelCodesEnum.NextDay
                    },
                    new SCServiceLevel
                    {
                        Amount = 200,
                        CarrierRateDiscount = 0,
                        SortOrder           = 0,
                        Label             = "temporal label",
                        CalculationMethod = "nothing",
                        IsEnabled         = true,
                        CarrierCode       = "nothing",
                        Code = (int)ServiceLevelCodesEnum.Local
                    },
                    new SCServiceLevel
                    {
                        Amount              = 0,
                        SortOrder           = 2,
                        Label               = "ground",
                        CarrierRateDiscount = 0,
                        Code              = (int)ServiceLevelCodesEnum.Ground,
                        IsEnabled         = true,
                        CalculationMethod = "nothing",
                        CarrierCode       = "nothing"
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create shippingPreference for accountMaster
            ShippingAccountMasterPreferencesRequest shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy          = "temporal test request",
                UseCustomerCarrier = false,
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                FreeFreightRules = new List <SAMFreeFreightRule>
                {
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000002",
                ShipFromAddress = new Address
                {
                    AddressLine1        = "Denver Boulder Turnpike",
                    AddressLine2        = "",
                    City                = "Boulder",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "80014",
                    StateProvinceRegion = "CO"
                },
                ShipToAddress = new Address
                {
                    AddressLine1        = "Denver Boulder Turnpike",
                    AddressLine2        = string.Empty,
                    City                = "Boulder",
                    Country             = "US",
                    Name                = "dfs",
                    Postal              = "1234567",
                    StateProvinceRegion = "CO"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        Quantity = 1,
                        CheckoutPriceExtended = 100,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 12,
                            IsFreeShip        = false,
                            Length            = 12,
                            IsFreightOnly     = false,
                            IsQuickShip       = false,
                            WeightDimensional = 12m,
                            WeightActual      = 2,
                            FreightClass      = 2
                        }
                    }
                }
            };

            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            //test data clean up
            await TestScenarioCleanUp(testData);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success, "Response status is not successful");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            //specific validations
            var shippingRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == handlingScheduleRequest.ServiceLevelCode);

            //handling validations
            //cannot have handling without flat rate schedule
            Assert.AreEqual(handlingScheduleRequest.Rate, shippingRate.Handling);
        }
Ejemplo n.º 18
0
        public async Task GET_Shipment_Warning311()
        {
            ShipmentTestData testData = new ShipmentTestData
            {
                AccountMasterExtId         = "getShipmentAccountMaster311",
                ShippingConfigExtId        = "getShipmentShippConfig311",
                FlatRateScheduleGroupExtId = "getShipmentFrGroup311",
                HandlingScheduleGroupExtId = "getShipmentHdGroup311"
            };

            string expectedDescription = "Non-Contiguous U.S";
            int    expectedCode        = 311;

            await TestScenarioCleanUp(testData);

            //create shipping configuration
            var shippingConfigurationRequest = new ShippingConfigurationRequest
            {
                CreatedBy               = "temporal shipment request",
                ExternalIdentifier      = testData.ShippingConfigExtId,
                DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Ground,
                ServiceLevels           = new List <SCServiceLevel>
                {
                    new SCServiceLevel
                    {
                        Label             = "sample label",
                        Amount            = 2,
                        CalculationMethod = "nothing",
                        CarrierCode       = "string",
                        Code                = (int)ServiceLevelCodesEnum.Ground,
                        SortOrder           = 5,
                        IsEnabled           = true,
                        CarrierRateDiscount = 15
                    }
                }
            };
            await Client.ShippingConfigurations.Create(shippingConfigurationRequest);

            //create flat rate group
            var flatRateGroupRequest = new FlatRateScheduleGroupsRequest
            {
                ExternalIdentifier = testData.FlatRateScheduleGroupExtId,
                CreatedBy          = "temporal shipment request",
                Name = "shipment group"
            };
            await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest);

            //create handling group
            var handlingGroupRequest = new HandlingScheduleGroupRequest
            {
                ExternalIdentifier = testData.HandlingScheduleGroupExtId,
                CreatedBy          = "temporal shipment request",
                Name = "shipment group"
            };
            await Client.HandlingScheduleGroups.Create(handlingGroupRequest);

            //create shipping preference
            var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest
            {
                CreatedBy = "temporal request",
                ShippingConfigurationExternalId = testData.ShippingConfigExtId,
                UseCustomerCarrier = false,
                FreeFreightRules   = new List <SAMFreeFreightRule>
                {
                    new SAMFreeFreightRule
                    {
                        ServiceLevelCode = (int)ServiceLevelCodesEnum.Local,
                        ThresholdAmount  = 0
                    }
                },
                FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId,
                HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId
            };
            await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest);

            ShipmentRequest request = new ShipmentRequest
            {
                OrderId         = "00000000000000000001",
                ShipFromAddress = new Address
                {
                    Country             = "MX",
                    AddressLine1        = "calle delante",
                    AddressLine2        = "12",
                    City                = "Ensenada",
                    Name                = "mexican address",
                    StateProvinceRegion = "B.C",
                    Postal              = "22770"
                },
                ShipToAddress = new Address
                {
                    Country             = "MX",
                    AddressLine1        = "valle dorado",
                    AddressLine2        = "349",
                    City                = "Ensenada",
                    Name                = "mexican address 2",
                    StateProvinceRegion = "B.C",
                    Postal              = "22780"
                },
                Products = new List <ShipmentProduct>
                {
                    new ShipmentProduct
                    {
                        CheckoutPriceExtended = 12,
                        ProductSku            = "temporal",
                        Quantity = 2,
                        Shipping = new ShipmentProductShipping
                        {
                            Width             = 12,
                            Height            = 20,
                            Length            = 10,
                            IsFreeShip        = false,
                            IsFreightOnly     = false,
                            WeightActual      = 3,
                            IsQuickShip       = false,
                            WeightDimensional = 6,
                            FreightClass      = 12
                        }
                    }
                }
            };
            HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request);

            Assert.IsNotNull(response, "Response object should not be null");
            Assert.IsTrue(response.Success, "Response status should be successful");
            Assert.IsNotNull(response.Result, "Result object should not be null");

            Assert.AreEqual(expectedCode, response.StatusCode);
            Assert.AreEqual(expectedDescription, response.Description);

            await TestScenarioCleanUp(testData);
        }