示例#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 CollectionBuilder AddCustomsInfo(string keyBase, CustomsInfo info)
        {
            if (!string.IsNullOrEmpty(info.Id))
            {
                return(Add("[id]".ToKvp(keyBase, info.Id)));
            }

            AddRequired("[customs_certify]".ToKvp(keyBase, info.CustomsCertify.ToString()));
            AddRequired("[contents_type]".ToKvp(keyBase, info.ContentsType));
            AddRequired("[contents_explanation]".ToKvp(keyBase, info.ContentsExplanation));
            AddRequired("[restriction_type]".ToKvp(keyBase, info.RestrictionType));
            AddRequired("[eel_pfc]".ToKvp(keyBase, info.EelPfc));
            Add("[customs_signer]".ToKvp(keyBase, info.CustomsSigner));
            Add("[non_delivery_option]".ToKvp(keyBase, info.NonDeliveryOption));
            Add("[restriction_comments]".ToKvp(keyBase, info.RestrictionComments));

            if (info.CustomsItems != null)
            {
                for (var i = 0; i < info.CustomsItems.Count; i++)
                {
                    AddCustomsItem(string.Format("{0}[customs_items][{1}]", keyBase, i), info.CustomsItems[i]);
                }
            }

            return(this);
        }
        public void TestCreateWithIResource()
        {
            CustomsItem item = new CustomsItem
            {
                description = "description",
                quantity    = 1
            };
            CustomsInfo info = CustomsInfo.Create(
                new Dictionary <string, object>
            {
                {
                    "customs_certify", true
                },
                {
                    "eel_pfc", "NOEEI 30.37(a)"
                },
                {
                    "customs_items", new List <IResource>
                    {
                        item
                    }
                }
            }
                );

            Assert.IsNotNull(info.id);
            Assert.AreEqual(info.customs_items.Count, 1);
            Assert.AreEqual(info.customs_items[0].description, item.description);
        }
示例#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"));
            }
        }
示例#5
0
        private Shipment CreateShipmentResource()
        {
            Address to = new Address
            {
                company = "Simpler Postage Inc",
                street1 = "164 Townsend Street",
                street2 = "Unit 1",
                city    = "San Francisco",
                state   = "CA",
                country = "US",
                zip     = "94107"
            };
            Address from = new Address
            {
                name    = "Andrew Tribone",
                street1 = "480 Fell St",
                street2 = "#3",
                city    = "San Francisco",
                state   = "CA",
                country = "US",
                zip     = "94102"
            };
            Parcel parcel = new Parcel
            {
                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
                }
            };


            return(new Shipment
            {
                to_address = to,
                from_address = from,
                parcel = parcel,
                customs_info = info
            });
        }
示例#6
0
    void InitBattle()
    {
        CustomsInfo info = Constants.Instance.LevelInfo;

        Log.I("本关为id={1}, name={2}, fc={0}, desc={3}", info.Fc, info.id, info.name, info.description);
        ejectors = info.launch.Select(l => {
            GameObject go = Instantiate(ejectorPrefab);
            var ejector   = go.GetComponent <Ejector>();
            ejector.Init(l.id, l.value, (float)l.initialPosition, (float)l.delay);
            return(ejector);
        }).ToArray();
    }
示例#7
0
        public WaybillItemValidationResult Validate()
        {
            var monetaryValueValidationResult = MonetaryValue.Validate();
            var customsInfoValidationResult   = CustomsInfo.Validate();

            return(new WaybillItemValidationResult(
                       hasEmptyItemId: ItemId == null,
                       hasEmptyCode: string.IsNullOrWhiteSpace(Code),
                       hasEmptyName: string.IsNullOrWhiteSpace(Name),
                       hasEmptyOkeiUnitCode: string.IsNullOrWhiteSpace(Unit.OkeiCode),
                       hasEmptyUnitName: string.IsNullOrWhiteSpace(Unit.Name),
                       monetaryValueValidationResult,
                       customsInfoValidationResult
                       ));
        }
示例#8
0
        /// <summary>
        /// Check whether two object instances are matches
        /// </summary>
        /// <param name="customsInfo">Customs info</param>
        /// <param name="customsInfo1">Customs info</param>
        /// <returns>Result</returns>
        public static bool Matches(this CustomsInfo customsInfo, CustomsInfo customsInfo1)
        {
            if (customsInfo1 is null)
            {
                return(false);
            }

            return(string.Equals(customsInfo.contents_type, customsInfo1.contents_type, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.restriction_type, customsInfo1.restriction_type, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.non_delivery_option, customsInfo1.non_delivery_option, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.contents_explanation, customsInfo1.contents_explanation, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.restriction_comments, customsInfo1.restriction_comments, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.customs_certify, customsInfo1.customs_certify, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.customs_signer, customsInfo1.customs_signer, System.StringComparison.InvariantCultureIgnoreCase) &&
                   string.Equals(customsInfo.eel_pfc, customsInfo1.eel_pfc, System.StringComparison.InvariantCultureIgnoreCase));
        }
示例#9
0
        protected void AppendVariable(string name, CustomsInfo value, bool alwaysinclude, ref string output)
        {
            string body = null;

            if (value != null)
            {
                if (string.IsNullOrWhiteSpace(value.id))
                {
                    AppendVariable(name + "[customs_certify]", value.customs_certify, false, ref body);
                    AppendVariable(name + "[customs_signer]", value.customs_signer, false, ref body);
                    AppendVariable(name + "[contents_type]", value.contents_type, false, ref body);
                    AppendVariable(name + "[contents_explanation]", value.contents_explanation, false, ref body);
                    AppendVariable(name + "[restriction_type]", value.restriction_type, false, ref body);
                    AppendVariable(name + "[restriction_comments]", value.restriction_comments, false, ref body);
                    AppendVariable(name + "[eel_pfc]", value.eel_pfc, false, ref body);
                    if (value.customs_items != null && value.customs_items.Length > 0)
                    {
                        for (var i = 0; i < value.customs_items.Length; i++)
                        {
                            AppendVariable(name + "[customs_items][" + i + "]", value.customs_items[i], false, ref body);
                        }
                    }
                }
                else
                {
                    AppendVariable(name + "[id]", value.id, false, ref body);
                }
            }
            else if (alwaysinclude)
            {
                body = name + "=";
            }
            if (body != null)
            {
                if (output != null && output.Length > 0)
                {
                    output += "&";
                }
                output += body;
            }
        }
示例#10
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"));
            }
        }
        public void TestCreateAndRetrieve()
        {
            Dictionary <string, object> item = new Dictionary <string, object>()
            {
                { "description", "TShirt" }, { "quantity", 1 }, { "weight", 8 }, { "origin_country", "US" }
            };

            CustomsInfo info = CustomsInfo.Create(new Dictionary <string, object>()
            {
                { "customs_certify", true }, { "eel_pfc", "NOEEI 30.37(a)" },
                { "customs_items", new List <Dictionary <string, object> >()
                  {
                      item
                  } }
            });

            CustomsInfo retrieved = CustomsInfo.Retrieve(info.id);

            Assert.AreEqual(info.id, retrieved.id);
            Assert.IsNotNull(retrieved.customs_items);
        }
示例#12
0
        public static LabelRequest ConstructLabelRequest(ILabelRequestRequest request)
        {
            DateTime     shipDateTime;
            LabelRequest labelRequest = new LabelRequest()
            {
                Test            = ToolsClass.ParseBoolYESNO(request.PrintSandbox),
                LabelType       = Parsers.ParseLabelType(request.LabelType),
                LabelSize       = Parsers.ParseLabelSize(request.LabelSize, request.LabelType),
                ImageFormat     = ConfigManager.Current.DefaultImageFormat,
                ImageResolution = "300",
                ImageRotation   = "None",
                RequesterID     = ToolsClass.GetRequesterID,
                AccountID       = request.AccountID,
                PassPhrase      = request.PassPhrase,
                MailClass       = Parsers.ParseMailClass(request.MailClass),
                DateAdvance     = ConfigManager.Current.DefaultDateAdvance,
                WeightOz        = request.PackageDetails.WeightOz
            };
            Dimensions dimension = new Dimensions()
            {
                Length = request.PackageDetails.Length,
                Width  = request.PackageDetails.Width,
                Height = request.PackageDetails.Height
            };

            labelRequest.MailpieceDimensions   = dimension;
            labelRequest.PackageTypeIndicator  = ConfigManager.Current.DefaultPackageTypeIndicator;
            labelRequest.Machinable            = ConfigManager.Current.DefaultMachinable;
            labelRequest.SignatureWaiver       = ConfigManager.Current.DefaultSignatureWaiver;
            labelRequest.NoWeekendDelivery     = ConfigManager.Current.DefaultNoWeekendDelivery;
            labelRequest.SundayHolidayDelivery = ConfigManager.Current.DefaultSundayHolidayDelivery;
            labelRequest.EntryFacility         = ConfigManager.Current.DefaultEntryFacility;
            labelRequest.POZipCode             = request.PoZipCode;
            bool includePostage = request.IncludePostage;

            labelRequest.IncludePostage    = includePostage.ToString().ToUpper();
            labelRequest.ReplyPostage      = ConfigManager.Current.DefaultReplayPostage;
            labelRequest.ShowReturnAddress = ConfigManager.Current.DefaultShowReturnAddress;
            includePostage = request.ValidateAddress;
            labelRequest.ValidateAddress = includePostage.ToString().ToUpper();
            SpecialServices specialService = new SpecialServices()
            {
                DeliveryConfirmation    = ToolsClass.ParseBoolONOFF(request.DeliveryConfirmation),
                SignatureConfirmation   = ToolsClass.ParseBoolONOFF(request.SignatureConfirmation),
                CertifiedMail           = ConfigManager.Current.DefaultCertifiedMail,
                RestrictedDelivery      = ConfigManager.Current.DefaultRestrictedDelivery,
                ReturnReceipt           = ConfigManager.Current.DefaultReturnReceipt,
                ElectronicReturnReceipt = ConfigManager.Current.DefaultElectornicReturnReceipt,
                HoldForPickup           = ConfigManager.Current.DefaultHoldForPickup,
                OpenAndDistribute       = ConfigManager.Current.DefaultOpenAndDistribute,
                COD            = ConfigManager.Current.DefaultCOD,
                InsuredMail    = Parsers.ParseInsuredMail(request.InsuredMail),
                AdultSignature = ConfigManager.Current.DefaultAdultSignature,
                AdultSignatureRestrictedDelivery = ConfigManager.Current.DefaultAdultSignatureRestrictedDelivery
            };

            labelRequest.Services             = specialService;
            labelRequest.InsuredValue         = request.OrderValueForInsurance;
            labelRequest.Value                = (float)Convert.ToDouble(request.OrderValueForInsurance);
            labelRequest.CostCenter           = 123;
            labelRequest.PartnerCustomerID    = request.AccountID;
            labelRequest.PartnerTransactionID = request.TransactionId.ToString();
            labelRequest.ReferenceID          = request.OrderId.ToString();
            labelRequest.RubberStamp1         = request.RubberStamp;
            ResponseOptions responseOption = new ResponseOptions()
            {
                PostagePrice = ConfigManager.Current.DefaultResponseOptions
            };

            labelRequest.ResponseOptions = responseOption;
            labelRequest.FromName        = request.SenderDetails.Name;
            labelRequest.FromCompany     = request.SenderDetails.Company;
            labelRequest.ReturnAddress1  = request.SenderDetails.Address1;
            labelRequest.ReturnAddress2  = request.SenderDetails.Address2;
            labelRequest.FromCity        = request.SenderDetails.City;
            labelRequest.FromState       = request.SenderDetails.State;
            labelRequest.FromPostalCode  = request.SenderDetails.PostalCode;
            labelRequest.FromCountry     = request.SenderDetails.Country;
            labelRequest.FromPhone       = request.SenderDetails.Phone;
            labelRequest.FromEMail       = request.SenderDetails.Email;
            labelRequest.ToName          = request.TargetAddress.Name;
            labelRequest.ToCompany       = request.TargetAddress.Company;
            labelRequest.ToAddress1      = request.TargetAddress.Address1;
            labelRequest.ToAddress2      = request.TargetAddress.Address2;
            labelRequest.ToCity          = request.TargetAddress.City;
            labelRequest.ToState         = request.TargetAddress.State;
            labelRequest.ToPostalCode    = request.TargetAddress.PostalCode;
            labelRequest.ToCountry       = request.TargetAddress.Country;
            labelRequest.ToCountryCode   = request.TargetAddress.CountryCode;
            labelRequest.ToPhone         = request.TargetAddress.Phone;
            labelRequest.ToEMail         = request.TargetAddress.Email;

            //labelRequest.LabelTemplate = "abc.ly";

            LabelRequest result = labelRequest;

            if (!request.IsInternationalOrder)
            {
                result.MailpieceShape     = null;
                result.LabelSubtype       = ConfigManager.Current.DefaultDomesticLabelSubType;
                result.IntegratedFormType = null;
            }
            else
            {
                result.MailpieceShape     = Parsers.ParseMailpieceShape(request.MailPieceShape);
                result.LabelSubtype       = ConfigManager.Current.DefaultInternationalLabelSubType;
                result.IntegratedFormType = PrintLabelsClass.GetIntegratedFormType(request.IsInternationalOrder, request.MailClass, request.MailPieceShape);
            }
            if ((request.PackageDetails.Items == null ? false : request.PackageDetails.Items.Count > 0))
            {
                if (request.IsInternationalOrder)
                {
                    result.CustomsCertify = ConfigManager.Current.DefaultCustomsCertify;
                    result.CustomsSigner  = request.CustomSigner;
                    CustomsInfo customsInfo = new CustomsInfo()
                    {
                        CertificateNumber = request.CustomCertificateNumber,
                        ContentsType      = ConfigManager.Current.DefaultMerchandise,
                        RestrictionType   = ConfigManager.Current.DefaultRestrictionType,
                        InvoiceNumber     = request.InvoiceNumber,
                        NonDeliveryOption = ConfigManager.Current.DefaultNonDeliveryOption
                    };
                    result.CustomsInfo = customsInfo;
                    List <CustomsItem> items = new List <CustomsItem>();
                    foreach (IPackageItem item in request.PackageDetails.Items)
                    {
                        CustomsItem cItem = new CustomsItem()
                        {
                            CountryOfOrigin = item.CustomCountry,
                            Description     = item.Description,
                            Quantity        = item.Quantity,
                            Value           = item.Value,
                            Weight          = item.WeightOz
                        };
                        items.Add(cItem);
                    }
                    result.CustomsInfo.CustomsItems = items.ToArray <CustomsItem>();
                }
            }
            try
            {
                shipDateTime    = request.ShipDateTime;
                result.ShipDate = shipDateTime.ToString("MM/dd/yyyy");
            }
            catch
            {
                shipDateTime    = DateTime.Now;
                result.ShipDate = shipDateTime.ToString("MM/dd/yyyy");
            }
            try
            {
                shipDateTime    = request.ShipDateTime;
                result.ShipTime = shipDateTime.ToString("hh:mm tt");
            }
            catch
            {
                shipDateTime    = DateTime.Now;
                result.ShipDate = shipDateTime.ToString("hh:mm tt");
            }
            return(result);
        }
示例#13
0
        public Shipment Create(Address to_address, Address from_address, Parcel parcel, CustomsInfo customs_info, Options options)
        {
            string body = "";

            AppendVariable("shipment[to_address]", to_address, true, ref body);
            AppendVariable("shipment[from_address]", from_address, true, ref body);
            AppendVariable("shipment[parcel]", parcel, true, ref body);
            AppendVariable("shipment[customs_info]", customs_info, false, ref body);
            AppendVariable("shipment[options]", options, false, ref body);

            var client   = GetHttpClient();
            var response = client.PostAsync("shipments", GetBody(body)).Result;

            return(response.Content.ReadAsAsync <Shipment>().Result);
        }