/// <summary> /// Create a CustomsItem. /// </summary> /// <param name="customsItem">Customs item parameters</param> /// <returns>EasyPost.CustomsItem instance.</returns> public async Task <CustomsItem> CreateCustomsItem( CustomsItem customsItem) { var request = new EasyPostRequest("customs_items", Method.POST); request.AddBody(customsItem.AsDictionary(), "customs_item"); return(await Execute <CustomsItem>(request)); }
public void TestCreateWithIResource() { CustomsItem item = new CustomsItem() { description = "description" }; 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); }
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 }; }
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")); }
/// <summary> /// Creates a new CustomsItem /// </summary> /// <param name="model">The CustomsItem to be created on the server</param> /// <returns>A fully populated CustomsItem, included the new Id</returns> /// <seealso cref="http://www.easypost.com/docs#customs"/> public CustomsItem CreateCustomsItem(CustomsItem model) { return(Execute <CustomsItem>(model, EasyPostUrls.CUSTOM_ITEMS)); }