예제 #1
0
        public static async Task <Shipment> GetDefaultObject()
        {
            Address addressFrom = await AddressTest.GetDefaultObject();

            Address addressTo = await AddressTest.GetDefaultObject2();

            Parcel parcel = await ParcelTest.GetDefaultObject();

            var parameters = new CreateShipment
            {
                AddressFrom  = addressFrom.ObjectId,
                AddressTo    = addressTo.ObjectId,
                Async        = false,
                Metadata     = "Customer ID 123456",
                ShipmentDate = DateTime.Now
            };

            parameters.AddParcel(parcel.ObjectId);
            parameters.CustomsDeclaration = "";
            parameters.Extra = new ShipmentExtra
            {
                Insurance = new ShipmentExtraInsurance
                {
                    Amount   = 30,
                    Currency = "USD"
                },
                SignatureConfirmation = ShippoEnums.SignatureConfirmations.STANDARD
            };

            return(await GetShippoClient().CreateShipment(parameters));
        }
예제 #2
0
        public async Task TestValidRetrieve()
        {
            Parcel testObject = await ParcelTest.GetDefaultObject();

            Parcel retrievedObject;

            retrievedObject = await shippoClient.RetrieveParcel(testObject.ObjectId);

            Assert.AreEqual(testObject.ObjectId, retrievedObject.ObjectId);
        }
예제 #3
0
        public static async Task <Manifest> GetDefaultObject(BaseAddress addressTo)
        {
            var     parameters0 = new CreateShipment();
            Address addressFrom = await AddressTest.GetDefaultObject();

            Parcel parcel = await ParcelTest.GetDefaultObject();

            parameters0.AddressFrom = addressFrom.ObjectId;
            parameters0.AddressTo   = addressTo;
            parameters0.AddParcel(parcel.ObjectId);
            parameters0.ShipmentDate       = DateTime.Now;
            parameters0.CustomsDeclaration = "";
            parameters0.Extra = new ShipmentExtra
            {
                Insurance = new ShipmentExtraInsurance
                {
                    Amount   = 30,
                    Currency = "USD"
                },
                SignatureConfirmation = ShippoEnums.SignatureConfirmations.STANDARD
            };
            parameters0.Metadata = "Customer ID 123456";
            parameters0.Async    = false;

            Shipment shipment = await GetShippoClient().CreateShipment(parameters0);

            ShippoCollection <Rate> rateCollection = await GetShippoClient().GetShippingRatesSync(shipment.ObjectId, "USD");

            List <Rate> rateList = rateCollection.Data;

            Rate[] rateArray = rateList.ToArray();

            var createTransaction = new CreateTransaction
            {
                Rate     = rateArray[0].ObjectId,
                Metadata = "Customer ID 123456"
            };

            Transaction transaction = await GetShippoClient().CreateTransactionSync(createTransaction);

            var parameters2 = new CreateManifest
            {
                ShipmentDate        = DateTime.Now,
                AddressFromObjectId = addressFrom.ObjectId,
                Provider            = "usps"
            };

            var transactions = new List <string>();

            transactions.Add(transaction.ObjectId);
            parameters2.TransactionsIds = transactions.ToArray();

            return(await GetShippoClient().CreateManifest(parameters2));
        }
예제 #4
0
        public async Task TestValidCreate()
        {
            Parcel testObject = await ParcelTest.GetDefaultObject();

            Assert.AreEqual(ShippoEnums.ObjectStates.VALID, testObject.ObjectState);
        }