示例#1
0
        private Shipment createShipmentResource()
        {
            Address to     = Address.Create(toAddress);
            Address from   = Address.Create(fromAddress);
            Parcel  parcel = Parcel.Create(new Dictionary <string, object>()
            {
                { "length", 8 }, { "width", 6 }, { "height", 5 }, { "weight", 10 }
            });
            CustomsItem item = new CustomsItem()
            {
                description = "description"
            };
            CustomsInfo info = new CustomsInfo()
            {
                customs_certify = "TRUE",
                eel_pfc         = "NOEEI 30.37(a)",
                customs_items   = new List <CustomsItem>()
                {
                    item
                }
            };


            return(new Shipment()
            {
                to_address = to,
                from_address = from,
                parcel = parcel,
                customs_info = info
            });
        }
示例#2
0
        public async Task <Guid> Handle(CreateParcelCommand request, CancellationToken cancellationToken)
        {
            var parcel = Parcel.Create(request.Description, request.Weight, (ParcelSize)request.Size);

            await _parcelRepository.CreateParcelAsync(parcel);

            return(parcel.Id);
        }
示例#3
0
        public void TestCreateAndRetrieve()
        {
            Parcel parcel = Parcel.Create(new Dictionary <string, object>()
            {
                { "length", 10 }, { "width", 20 }, { "height", 5 }, { "weight", 1.8 }
            });
            Parcel retrieved = Parcel.Retrieve(parcel.id);

            Assert.AreEqual(parcel.id, retrieved.id);
        }
示例#4
0
        public void TestCarrierAccounts()
        {
            Address to     = Address.Create(toAddress);
            Address from   = Address.Create(fromAddress);
            Parcel  parcel = Parcel.Create(new Dictionary <string, object>
            {
                {
                    "length", 8
                },
                {
                    "width", 6
                },
                {
                    "height", 5
                },
                {
                    "weight", 10
                }
            });
            CustomsItem item = new CustomsItem
            {
                description = "description",
                quantity    = 1
            };
            CustomsInfo info = new CustomsInfo
            {
                customs_certify = "TRUE",
                eel_pfc         = "NOEEI 30.37(a)",
                customs_items   = new List <CustomsItem>
                {
                    item
                }
            };

            Shipment shipment = new Shipment
            {
                to_address       = to,
                from_address     = from,
                parcel           = parcel,
                carrier_accounts = new List <CarrierAccount>
                {
                    new CarrierAccount
                    {
                        id = "ca_7642d249fdcf47bcb5da9ea34c96dfcf"
                    }
                }
            };

            shipment.Create();
            if (shipment.rates.Count > 0)
            {
                Assert.IsTrue(shipment.rates.TrueForAll(r =>
                                                        r.carrier_account_id == "ca_7642d249fdcf47bcb5da9ea34c96dfcf"));
            }
        }
        public async Task <Unit> Handle(AddParcelToLockerCommand request, CancellationToken cancellationToken)
        {
            var parcelLocker = await _parcelLockersRepository.GetParcelLockerAsync(request.ParcelLockerId);

            if (parcelLocker is null)
            {
                throw new ApplicationException($"Parcel locker with id '{request.ParcelLockerId}' does not exist");
            }

            // TODO: Validate if parcels with given ids exists.
            foreach (var parcel in request.ParcelsIds)
            {
                parcelLocker.AddParcel(Parcel.Create(parcel));
            }

            await _parcelLockersRepository.UpdateParcelLockerAsync(parcelLocker);

            return(Unit.Value);
        }
示例#6
0
        public void TestCarrierAccounts()
        {
            Address to     = Address.Create(toAddress);
            Address from   = Address.Create(fromAddress);
            Parcel  parcel = Parcel.Create(new Dictionary <string, object>()
            {
                { "length", 8 },
                { "width", 6 },
                { "height", 5 },
                { "weight", 10 }
            });
            CustomsItem item = new CustomsItem()
            {
                description = "description"
            };
            CustomsInfo info = new CustomsInfo()
            {
                customs_certify = "TRUE",
                eel_pfc         = "NOEEI 30.37(a)",
                customs_items   = new List <CustomsItem>()
                {
                    item
                }
            };

            Shipment shipment = new Shipment();

            shipment.to_address       = to;
            shipment.from_address     = from;
            shipment.parcel           = parcel;
            shipment.carrier_accounts = new List <CarrierAccount> {
                new CarrierAccount {
                    id = "ca_qn6QC6fd"
                }
            };
            shipment.Create();
            if (shipment.rates.Count > 0)
            {
                Assert.IsTrue(shipment.rates.TrueForAll(r => r.carrier_account_id == "ca_qn6QC6fd"));
            }
        }