本文整理汇总了C#中Request.addBody方法的典型用法代码示例。如果您正苦于以下问题:C# Request.addBody方法的具体用法?C# Request.addBody怎么用?C# Request.addBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.addBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
/// <summary>
/// Create a Parcel.
/// </summary>
/// <param name="parameters">
/// Dictionary containing parameters to create the parcel with. Valid pairs:
/// * {"length", int}
/// * {"width", int}
/// * {"height", int}
/// * {"weight", double}
/// * {"predefined_package", string}
/// All invalid keys will be ignored.
/// </param>
/// <returns>EasyPost.Parcel instance.</returns>
public static Parcel Create(IDictionary<string, object> parameters)
{
Request request = new Request("parcels", Method.POST);
request.addBody(parameters, "parcel");
return request.Execute<Parcel>();
}
示例2: Create
/// <summary>
/// Create a CarrierAccount.
/// </summary>
/// <param name="parameters">
/// Optional dictionary containing parameters to create the carrier account with. Valid pairs:
/// * {"type", string} Required (e.g. EndiciaAccount, UPSAccount, etc.).
/// * {"reference", string} External reference for carrier account.
/// * {"description", string} Description of carrier account.
/// * {"credentials", Dictionary<string, string>}
/// * {"test_credentials", Dictionary<string, string>}
/// All invalid keys will be ignored.
/// </param>
/// <returns>EasyPost.CarrierAccount instance.</returns>
public static CarrierAccount Create(IDictionary<string, object> parameters)
{
Request request = new Request("carrier_accounts", Method.POST);
request.addBody(parameters, "carrier_account");
return request.Execute<CarrierAccount>();
}
示例3: Create
/// <summary>
/// Create a CustomsItem.
/// </summary>
/// <param name="parameters">
/// Dictionary containing parameters to create the customs item with. Valid pairs:
/// * {"description", string}
/// * {"quantity", int}
/// * {"weight", int}
/// * {"value", double}
/// * {"hs_tariff_number", string}
/// * {"origin_country", string}
/// All invalid keys will be ignored.
/// </param>
/// <returns>EasyPost.CustomsItem instance.</returns>
public static CustomsItem Create(IDictionary<string, object> parameters)
{
Request request = new Request("customs_items", Method.POST);
request.addBody(parameters, "customs_item");
return request.Execute<CustomsItem>();
}
示例4: TestAddBody
public void TestAddBody()
{
Request request = new Request("resource");
request.addBody(new Dictionary<string, object>() { { "foo", "bar" } }, "parent");
RestRequest restRequest = (RestRequest)request;
CollectionAssert.Contains(restRequest.Parameters.Select(parameter => parameter.ToString()).ToList(), "application/x-www-form-urlencoded=parent%5Bfoo%5D=bar");
}
示例5: Create
public static Tracker Create(string carrier, string trackingCode) {
Request request = new Request("trackers", RestSharp.Method.POST);
Dictionary<string, object> parameters = new Dictionary<string, object>() {
{ "tracking_code", trackingCode }, { "carrier", carrier }
};
request.addBody(parameters, "tracker");
return request.Execute<Tracker>();
}
示例6: Buy
/// <summary>
/// Purchase the shipments within this order with a carrier and service.
/// </summary>
/// <param name="carrier">The carrier to purchase a shipment from.</param>
/// <param name="service">The service to purchase.</param>
public void Buy(string carrier, string service)
{
Request request = new Request("orders/{id}/buy", Method.POST);
request.AddUrlSegment("id", id);
request.addBody(new List<Tuple<string, string>>() { new Tuple<string, string>("carrier", carrier), new Tuple<string, string>("service", service) });
this.Merge(request.Execute<Order>());
}
示例7: Create
/// <summary>
/// Create a child user for the account associated with the api_key specified.
/// </summary>
/// <param name="parameters">
/// Optional dictionary containing parameters to create the carrier account with. Valid pairs:
/// * {"name", string} Name on the account.
/// All invalid keys will be ignored.
/// </param>
/// <returns>EasyPost.User instance.</returns>
public static User Create(Dictionary<string, object> parameters)
{
Request request = new Request("users", Method.POST);
request.addBody(parameters, "user");
return request.Execute<User>();
}
示例8: Update
/// <summary>
/// Update the User associated with the api_key specified.
/// </summary>
/// <param name="parameters">
/// Optional dictionary containing parameters to create the carrier account with. Valid pairs:
/// * {"name", string} Name on the account.
/// * {"email", string} Email on the account. Can only be updated on the parent account.
/// * {"phone_number", string} Phone number on the account. Can only be updated on the parent account.
/// * {"recharge_amount", int} Recharge amount for the account in cents. Can only be updated on the parent account.
/// * {"secondary_recharge_amount", int} Secondary recharge amount for the account in cents. Can only be updated on the parent account.
/// * {"recharge_threshold", int} Recharge threshold for the account in cents. Can only be updated on the parent account.
/// All invalid keys will be ignored.
/// </param>
public void Update(IDictionary<string, object> parameters)
{
Request request = new Request("users/{id}", Method.PUT);
request.AddUrlSegment("id", id);
request.addBody(parameters, "user");
this.Merge(request.Execute<User>());
}
示例9: sendCreate
private static Shipment sendCreate(IDictionary<string, object> parameters)
{
Request request = new Request("shipments", Method.POST);
request.addBody(parameters, "shipment");
return request.Execute<Shipment>();
}
示例10: Update
/// <summary>
/// Update this CarrierAccount.
/// </summary>
/// <param name="parameters">See CarrierAccount.Create for more details.</param>
public void Update(IDictionary<string, object> parameters)
{
Request request = new Request("carrier_accounts/{id}", Method.PUT);
request.AddUrlSegment("id", id);
request.addBody(parameters, "carrier_account");
this.Merge(request.Execute<CarrierAccount>());
}
示例11: RemoveShipments
/// <summary>
/// Remove shipments from the batch.
/// </summary>
/// <param name="shipmentIds">List of shipment ids to be removed.</param>
public void RemoveShipments(IEnumerable<string> shipmentIds)
{
Request request = new Request("batches/{id}/remove_shipments", Method.POST);
request.AddUrlSegment("id", id);
List<Dictionary<string, object>> body = shipmentIds.Select(shipmentId => new Dictionary<string, object>() { { "id", shipmentId } }).ToList();
request.addBody(body, "shipments");
this.Merge(request.Execute<Batch>());
}
示例12: sendCreate
private static Address sendCreate(IDictionary<string, object> parameters)
{
Request request = new Request("addresses", Method.POST);
request.addBody(parameters, "address");
return request.Execute<Address>();
}
示例13: CreateAndVerify
/// <summary>
/// Create and verify an Address.
/// </summary>
/// <param name="parameters">
/// Optional dictionary containing parameters to create the address with. Valid pairs:
/// * {"name", string}
/// * {"company", string}
/// * {"stree1", string}
/// * {"street2", string}
/// * {"city", string}
/// * {"state", string}
/// * {"zip", string}
/// * {"country", string}
/// * {"phone", string}
/// * {"email", string}
/// All invalid keys will be ignored.
/// </param>
/// <returns>EasyPost.Address instance.</returns>
public static Address CreateAndVerify(IDictionary<string, object> parameters = null)
{
parameters = parameters ?? new Dictionary<string, object>();
Request request = new Request("addresses/create_and_verify", Method.POST);
request.RootElement = "address";
request.addBody(parameters, "address");
return request.Execute<Address>();
}
示例14: sendCreate
private static Pickup sendCreate(IDictionary<string, object> parameters)
{
Request request = new Request("pickups", Method.POST);
request.addBody(parameters, "pickup");
return request.Execute<Pickup>();
}
示例15: sendCreate
private static Order sendCreate(IDictionary<string, object> parameters)
{
Request request = new Request("orders", Method.POST);
request.addBody(parameters, "order");
return request.Execute<Order>();
}