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


C# Request.Execute方法代码示例

本文整理汇总了C#中Request.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Request.Execute方法的具体用法?C# Request.Execute怎么用?C# Request.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: RetrieveReference

        /// <summary>
        /// Retrieve a Item from a custom reference.
        /// </summary>
        /// <param name="name">String containing the name of the custom reference to search for.</param>
        /// <param name="value">String containing the value of the custom reference to search for.</param>
        /// <returns>EasyPost.Item instance.</returns>
        public static Item RetrieveReference(string name, string value) {
            Request request = new Request("items/retrieve_reference/?{name}={value}");
            request.AddUrlSegment("name", name);
            request.AddUrlSegment("value", value);

            return request.Execute<Item>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:13,代码来源:Item.cs

示例3: 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

示例4: Create

        /// <summary>
        /// Create a Batch.
        /// </summary>
        /// <param name="parameters">
        /// Optional dictionary containing parameters to create the batch with. Valid pairs:
        ///   * {"shipments", List<Dictionary<string, object>>} See Shipment.Create for a list of valid keys.
        ///   * {"reference", string}
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Batch instance.</returns>
        public static Batch Create(IDictionary<string, object> parameters = null) {
            parameters = parameters ?? new Dictionary<string, object>();

            Request request = new Request("batches", Method.POST);
            request.AddBody(parameters, "batch");

            return request.Execute<Batch>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:18,代码来源:Batch.cs

示例5: AddShipments

        /// <summary>
        /// Add shipments to the batch.
        /// </summary>
        /// <param name="shipmentIds">List of shipment ids to be added.</param>
        public void AddShipments(IEnumerable<string> shipmentIds) {
            Request request = new Request("batches/{id}/add_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:andyfengc,项目名称:Demo_.Net,代码行数:13,代码来源:Batch.cs

示例6: 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

示例7: ShouldDeserializePostJsonToObject

        public void ShouldDeserializePostJsonToObject()
        {
            var request = new Request();
            var user = new User {username = "Bob",password = "password"};

            var response = (Httpresponse)request.Execute<Httpresponse>("http://localhost:1234/",user,"POST");

            Console.WriteLine(response.Statuscode);
            Console.WriteLine(response.Location);

            Assert.IsNotNull(response);
        }
开发者ID:robertogonzalez08,项目名称:JsonRequest,代码行数:12,代码来源:JsonRequestTests.cs

示例8: ShouldDeserializeJsonToObjectFromConstructor

        public void ShouldDeserializeJsonToObjectFromConstructor()
        {
            var request = new Request("http://localhost:1234/","GET");
            var response = (Httpresponse)request.Execute<Httpresponse>();

            Console.WriteLine(response.Statuscode);
            Console.WriteLine(response.Location);

            Assert.IsNotNull(response);
            Assert.IsNotEmpty(response.Statuscode.ToString());
            Assert.AreEqual(200, response.Statuscode);
        }
开发者ID:robertogonzalez08,项目名称:JsonRequest,代码行数:12,代码来源:JsonRequestTests.cs

示例9: ShouldDeserializeJsonToString

        public void ShouldDeserializeJsonToString()
        {
            var request = new Request();
            request.Verb = "GET";
            request.URL = "http://localhost:1234/";

            var response = request.Execute();

            Console.WriteLine(response);

            Assert.IsNotNull(response);
            Assert.IsNotEmpty((string) response);
        }
开发者ID:robertogonzalez08,项目名称:JsonRequest,代码行数:13,代码来源:JsonRequestTests.cs

示例10: Should_deserialize_Twitter_response

        public void Should_deserialize_Twitter_response()
        {
            var request = new Request { URL = "http://search.twitter.com/search.json?q=brazil&rpp=5&include_entities=true&result_type=mixed" };

            var response = (SearchResults)request.Execute<SearchResults>();

            Assert.IsNotNull(response);

            foreach (SearchResult r in response.results)
            {
                Console.WriteLine("From User: " + r.from_user);
                Console.WriteLine("Created At: " + r.created_at);
                Console.WriteLine("Twitt Text: " + r.text + "\n");
            }
        }
开发者ID:robertogonzalez08,项目名称:JsonRequest,代码行数:15,代码来源:JsonRequestTwitterTests.cs

示例11: Retrieve

        /// <summary>
        /// Retrieve a Order from its id or reference.
        /// </summary>
        /// <param name="id">String representing a Order. Starts with "order_" if passing an id.</param>
        /// <returns>EasyPost.Order instance.</returns>
        public static Order Retrieve(string id)
        {
            Request request = new Request("orders/{id}");
            request.AddUrlSegment("id", id);

            return request.Execute<Order>();
        }
开发者ID:LeeHester,项目名称:easypost-csharp,代码行数:12,代码来源:Order.cs

示例12: Cancel

        /// <summary>
        /// Cancel this pickup.
        /// </summary>
        public void Cancel() {
            Request request = new Request("pickups/{id}/cancel", Method.POST);
            request.AddUrlSegment("id", id);

            this.Merge(request.Execute<Pickup>());
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:9,代码来源:Pickup.cs

示例13: 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:andyfengc,项目名称:Demo_.Net,代码行数:6,代码来源:Pickup.cs

示例14: Retrieve

        /// <summary>
        /// Retrieve a Pickup from its id.
        /// </summary>
        /// <param name="id">String representing a Pickup. Starts with "pickup_".</param>
        /// <returns>EasyPost.Pickup instance.</returns>
        public static Pickup Retrieve(string id) {
            Request request = new Request("pickups/{id}");
            request.AddUrlSegment("id", id);

            return request.Execute<Pickup>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:11,代码来源:Pickup.cs

示例15: GenerateLabel

        /// <summary>
        /// Asynchronously generate a label containing all of the Shimpent labels belonging to the batch.
        /// </summary>
        /// <param name="fileFormat">Format to generate the label in. Valid formats: "pdf", "zpl" and "epl2".</param>
        /// <param name="orderBy">Optional parameter to order the generated label. Ex: "reference DESC"</param>
        public void GenerateLabel(string fileFormat, string orderBy = null)
        {
            Request request = new Request("batches/{id}/label", Method.POST);
            request.AddUrlSegment("id", id);

            List<Tuple<string, string>> body = new List<Tuple<string, string>>() {
                new Tuple<string, string>("file_format", fileFormat)
            };

            if (orderBy != null)
                body.Add(new Tuple<string, string>("order_by", orderBy));

            request.addBody(body);
            this.Merge(request.Execute<Batch>());
        }
开发者ID:swrhim,项目名称:EasyPostPoC,代码行数:20,代码来源:Batch.cs


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