public void TrackShipmentTest()
        {
            string         trackingNumber      = "122816215025810";
            CarrierAccount fedexCarrierAccount = new CarrierAccount();

            fedexCarrierAccount.id      = fedexShippingAccountId;
            fedexCarrierAccount.carrier = "fedex";

            zkService.Test = true;
            ShipmentStatus shipmentStatus = zkService.TrackShipment(trackingNumber, fedexCarrierAccount);

            Assert.IsTrue(shipmentStatus != null);
        }
        //[Fact] // Need to have UPS account
        public void TestRegistration()
        {
            var license = new CarrierLicense();

            license.Carrier           = Carrier.UPS;
            license.OriginCountryCode = "US";

            var licResponse = Api.CarrierLicenseAgreements(license, Globals.DefaultSession).GetAwaiter().GetResult();

            var responseLicense = licResponse.ResponseObject as CarrierLicense;

            var registration = new CarrierAccount();

            registration.DeveloperId           = Globals.DefaultSession.GetConfigItem("DeveloperID");
            registration.Carrier               = Carrier.UPS;
            registration.PostalReportingNumber = "123456789";
            registration.TransactionId         = Guid.NewGuid().ToString().Substring(15);
            registration.AccountNumber         = "56V7A6";

            var accountAddress = AddressFluent <Address> .Create()
                                 .Company("Widgets")
                                 .Name("James Smith")
                                 .Phone("303-555-1213")
                                 .Email("*****@*****.**")
                                 .Residential(false)
                                 .AddressLines("4750 Walnut Street")
                                 .CityTown("Boulder")
                                 .StateProvince("CO")
                                 .PostalCode("80301")
                                 .CountryCode("US");

            registration.AccountAddress     = (Address)accountAddress;
            registration.ContactAddress     = (Address)accountAddress;
            registration.AccountPostalCode  = "80301";
            registration.AccountCountryCode = "US";
            registration.ContactTitle       = "Manager";
            registration.EndUserIP          = "10.100.20.20";
            registration.DeviceIdentity     = "84315tr3M5e4n";
            registration.LicenseText        = responseLicense.LicenseText;

            var response = Api.RegisterCarrierAccount(registration, Globals.DefaultSession).GetAwaiter().GetResult();

            Assert.True(response.Success);
            var responseAccount = response.ResponseObject as CarrierAccount;

            Assert.NotNull(responseAccount);
        }
示例#3
0
        public void TestCRUD()
        {
            CarrierAccount account = CarrierAccount.Create(new Dictionary <string, object>()
            {
                { "type", "EndiciaAccount" },
                { "description", "description" }
            });

            Assert.IsNotNull(account.id);

            account.Update(new Dictionary <string, object>()
            {
                { "reference", "new-reference" }
            });
            Assert.AreEqual("new-reference", account.reference);

            account.Destroy();
        }
示例#4
0
        public CarrierAccount AddCarrierAccount(string carrierJson)
        {
            CarrierAccount carrierAccount = null;

            try
            {
                string jsonResponse = DataLayer.getResponseFromApi(ApiKey, DataLayer.WebMethod.POST, "/shippingaccount", carrierJson);

                if (!string.IsNullOrEmpty(jsonResponse))
                {
                    ZkSuccess zkSuccess = GetApiCallSuccess(jsonResponse);
                    if (zkSuccess.success == true)
                    {
                        JObject dataObj           = JObject.Parse(jsonResponse);
                        JObject carrierAccountObj = JObject.Parse(dataObj["shipping_account"].ToString());
                        carrierAccount              = new CarrierAccount();
                        carrierAccount.auth         = carrierAccountObj["auth"].ToString();
                        carrierAccount.name         = carrierAccountObj["name"].ToString();
                        carrierAccount.id           = Int64.Parse(carrierAccountObj["id"].ToString());
                        carrierAccount.carrier      = carrierAccountObj["carrier"].ToString();
                        carrierAccount.dim_units    = carrierAccountObj["dim_units"].ToString();
                        carrierAccount.weight_units = carrierAccountObj["weight_units"].ToString();
                        carrierAccount.currency     = carrierAccountObj["currency"].ToString();
                    }
                    else
                    {
                        throw new Exception(zkSuccess.error_message + " " + zkSuccess.detail);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(carrierAccount);
        }
示例#5
0
        public void TestCRUD()
        {
            CarrierAccount account = CarrierAccount.Create(new Dictionary <string, object>()
            {
                { "type", "UspsAccount" },
                { "description", "description" }
            });

            Assert.IsNotNull(account.id);
            Assert.AreEqual(account.type, "UspsAccount");

            account.Update(new Dictionary <string, object>()
            {
                { "reference", "new-reference" }
            });
            Assert.AreEqual("new-reference", account.reference);

            account.Destroy();
            try {
                CarrierAccount.Retrieve(account.id);
                Assert.Fail();
            }
            catch (HttpException) { }
        }
        public void TestRetrieve()
        {
            CarrierAccount account = CarrierAccount.Retrieve("ca_7642d249fdcf47bcb5da9ea34c96dfcf");

            Assert.AreEqual("ca_7642d249fdcf47bcb5da9ea34c96dfcf", account.id);
        }
        public void TestAll()
        {
            List <CarrierAccount> accounts = CarrierAccount.All();

            Assert.AreEqual(accounts[0].id, "ca_7642d249fdcf47bcb5da9ea34c96dfcf");
        }
        public void TestList()
        {
            List <CarrierAccount> accounts = CarrierAccount.List();

            Assert.AreEqual(accounts[0].id, "ca_7c7X1XzO");
        }
        public void TestRetrieve()
        {
            CarrierAccount account = CarrierAccount.Retrieve("ca_7c7X1XzO");

            Assert.AreEqual("ca_7c7X1XzO", account.id);
        }