当前位置: 首页>>代码示例>>C#>>正文


C# Request.addBody方法代码示例

本文整理汇总了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>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:20,代码来源:Parcel.cs

示例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>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:20,代码来源:CarrierAccount.cs

示例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>();
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:21,代码来源:CustomsItem.cs

示例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");
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:8,代码来源:RequestTest.cs

示例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>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:10,代码来源:Tracker.cs

示例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>());
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:13,代码来源:Order.cs

示例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>();
        }
开发者ID:swrhim,项目名称:EasyPostPoC,代码行数:16,代码来源:User.cs

示例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>());
        }
开发者ID:swrhim,项目名称:EasyPostPoC,代码行数:21,代码来源:User.cs

示例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>();
        }
开发者ID:swrhim,项目名称:EasyPostPoC,代码行数:7,代码来源:Shipment.cs

示例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>());
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:12,代码来源:CarrierAccount.cs

示例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>());
        }
开发者ID:swrhim,项目名称:EasyPostPoC,代码行数:14,代码来源:Batch.cs

示例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>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:7,代码来源:Address.cs

示例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>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:28,代码来源:Address.cs

示例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>();
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:7,代码来源:Pickup.cs

示例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>();
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:7,代码来源:Order.cs


注:本文中的Request.addBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。