Пример #1
0
        public async Task CreateShipmentTest()
        {
            var client = new EasyPostClient(Configuration.GetSetting("EasyPostToken"));

            var request = new CreateShipmentRequest
            {
                shipment = new Shipment
                {
                    options = new Options {
                        invoice_number = "17729NVXPBDK"
                    },
                    from_address = new Address {
                        id = "adr_c2004b0f3e864571823f955f5d421b33"
                    },
                    to_address = new Address {
                        id = "adr_db2c673615994177ae9ba5915d562a69"
                    },
                    parcel = new Parcel {
                        weight = 34.0f
                    },
                    reference        = "17729NVXPBDK",
                    carrier_accounts = new List <string>
                    {
                        "ca_da797b3cd75a46eb9fdecf633be774fe",
                        "ca_cc0e5d15e7954effbb62f858619588a3"
                    }
                }
            };
            var shipment = await client.CreateShipmentAsync(request);

            Assert.NotNull(shipment);
        }
Пример #2
0
        public async Task Initialize()
        {
            _client  = new EasyPostClient("WzJHJ6SoPnBVYu0ae4aIHA");
            _address = new Address
            {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
                Phone   = "1234567890"
            };
            _toAddress = new Address
            {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            _fromAddress = new Address
            {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };

            _shipment = await _client.CreateShipment(new Shipment
            {
                Parcel = new Parcel
                {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Reference   = "ShipmentRef",
            });

            await _client.BuyShipment(_shipment.Id, _shipment.LowestRate().Id);

            _testPickup = new Pickup
            {
                IsAccountAddress = false,
                Address          = _address,
                Shipment         = _shipment,
                MinDatetime      = DateTime.Now,
                MaxDatetime      = DateTime.Now,
            };
        }
Пример #3
0
        public async Task CreateLabelTest()
        {
            var client = new EasyPostClient(Configuration.GetSetting("EasyPostToken"));

            var label = await client.GetShipmentLabelAsync("shp_8b3c1fc9fe7847e8b379513c0e76da94", "ZPL");

            Assert.NotNull(label);
        }
        public void TestPrepareRequestWithOptions()
        {
            var client  = new EasyPostClient(new ClientConfiguration("someapikey", "http://foobar.com"));
            var request = new EasyPostRequest("resource");

            var parameters = client.PrepareRequest(request).Parameters.Select(parameter => parameter.ToString()).ToList();

            CollectionAssert.Contains(parameters, "user_agent=EasyPost/CSharpASync/" + client.Version);
            CollectionAssert.Contains(parameters, "authorization=Bearer someapikey");
            CollectionAssert.Contains(parameters, "content_type=application/x-www-form-urlencoded");
        }
        public void TestPrepareRequest()
        {
            var client  = new EasyPostClient("apiKey");
            var request = new EasyPostRequest("resource");

            var parameters = client.PrepareRequest(request).Parameters.Select(parameter => parameter.ToString()).ToList();

            CollectionAssert.Contains(parameters, "user_agent=EasyPost/CSharpASync/" + client.Version);
            CollectionAssert.Contains(parameters, "authorization=Bearer apiKey");
            CollectionAssert.Contains(parameters, "content_type=application/x-www-form-urlencoded");
        }
        public async Task CreateTrackerTest()
        {
            var client = new EasyPostClient(Configuration.GetSetting("EasyPostToken"));

            var tracker = await client.CreateTrackerAsync(new Tracker
            {
                tracking_code = "1Z9336190371284586",
                carrier       = "UPS"
            });

            Assert.NotNull(tracker);
        }
Пример #7
0
 public void Initialize()
 {
     _client      = new EasyPostClient("cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi");
     _testAddress = new Address {
         Company = "Simpler Postage Inc",
         Street1 = "164 Townsend Street",
         Street2 = "Unit 1",
         City    = "San Francisco",
         State   = "CA",
         Country = "US",
         Zip     = "94107"
     };
 }
Пример #8
0
        public void Initialize()
        {
            _client = new EasyPostClient("cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi");

            _toAddress = new Address
            {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            _fromAddress = new Address
            {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };
            _testShipment = new Shipment
            {
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Parcel      = new Parcel
                {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
                Reference   = "ShipmentRef",
                CustomsInfo = new CustomsInfo
                {
                    CustomsCertify = true,
                    EelPfc         = "NOEEI 30.37(a)",
                    CustomsItems   = new List <CustomsItem> {
                        new CustomsItem {
                            Description = "description",
                            Quantity    = 1
                        }
                    }
                },
                Options = new Options()
            };
        }
Пример #9
0
        public void Initialize()
        {
            _client = new EasyPostClient("cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi");

            _toAddress = new Address {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            _fromAddress = new Address {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };
            _testShipments = new List <Shipment> {
                new Shipment {
                    Parcel = new Parcel {
                        Length = 8,
                        Width  = 6,
                        Height = 5,
                        Weight = 18,
                    },
                },
                new Shipment {
                    Parcel = new Parcel {
                        Length = 9,
                        Width  = 5,
                        Height = 4,
                        Weight = 18,
                    },
                },
            };
            _testOrder = new Order {
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Reference   = "OrderRef",
                Shipments   = _testShipments,
            };
        }
Пример #10
0
        public void Initialize()
        {
            _client = new EasyPostClient("cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi");

            _toAddress = new Address {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            _fromAddress = new Address {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };
            _testShipment = new Shipment {
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Parcel      = new Parcel {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
            };
            _testBatchShipment = new Shipment {
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Parcel      = new Parcel {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
                Carrier = "USPS",
                Service = "Priority",
            };
        }
Пример #11
0
 public void Initialize()
 {
     _client = new EasyPostClient("cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi");
 }
Пример #12
0
 public void Initialize()
 {
     _client = new EasyPostClient("VJ63zukvLyxz92NKP1k0EQ");
 }
Пример #13
0
        public void TestRestClientWithOptions()
        {
            var client = new EasyPostClient(new ClientConfiguration("someapikey", "http://apiBase.com"));

            Assert.AreEqual(new Uri("http://apiBase.com"), client.RestClient.BaseUrl);
        }
Пример #14
0
        public void TestRestClient()
        {
            var client = new EasyPostClient(new ClientConfiguration("apiKey"));

            Assert.AreEqual(client.RestClient.BaseUrl, "https://api.easypost.com/v2");
        }
Пример #15
0
        public void TestApiBase()
        {
            var client = new EasyPostClient(new ClientConfiguration("apiKey", "https://foobar.com"));

            Assert.AreEqual(new Uri("https://foobar.com"), client.RestClient.BaseUrl);
        }