/// <summary> /// Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions: /// </summary> /// <param name="locationId">Required parameter: The ID of the order's associated location.</param> /// <param name="orderId">Required parameter: The order's Square-issued ID. You obtain this value from Order objects returned by the List Orders endpoint</param> /// <param name="body">Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.</param> /// <return>Returns the Models.V1Order response from the API call</return> public Models.V1Order UpdateOrder(string locationId, string orderId, Models.V1UpdateOrderRequest body) { Task <Models.V1Order> t = UpdateOrderAsync(locationId, orderId, body); ApiHelper.RunTaskSynchronously(t); return(t.Result); }
/// <summary> /// Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions: /// </summary> /// <param name="locationId">Required parameter: The ID of the order's associated location.</param> /// <param name="orderId">Required parameter: The order's Square-issued ID. You obtain this value from Order objects returned by the List Orders endpoint</param> /// <param name="body">Required parameter: An object containing the fields to POST for the request. See the corresponding object definition for field details.</param> /// <return>Returns the Models.V1Order response from the API call</return> public async Task <Models.V1Order> UpdateOrderAsync(string locationId, string orderId, Models.V1UpdateOrderRequest body, CancellationToken cancellationToken = default) { //the base uri for api requests string _baseUri = config.GetBaseUri(); //prepare query string for API call StringBuilder _queryBuilder = new StringBuilder(_baseUri); _queryBuilder.Append("/v1/{location_id}/orders/{order_id}"); //process optional template parameters ApiHelper.AppendUrlWithTemplateParameters(_queryBuilder, new Dictionary <string, object>() { { "location_id", locationId }, { "order_id", orderId } }); //append request with appropriate headers and parameters var _headers = new Dictionary <string, string>() { { "user-agent", userAgent }, { "accept", "application/json" }, { "content-type", "application/json; charset=utf-8" }, { "Square-Version", config.SquareVersion } }; //append body params var _body = ApiHelper.JsonSerialize(body); //prepare the API call request to fetch the response HttpRequest _request = GetClientInstance().PutBody(_queryBuilder.ToString(), _headers, _body); if (HttpCallBack != null) { HttpCallBack.OnBeforeHttpRequestEventHandler(GetClientInstance(), _request); } _request = await authManagers["global"].ApplyAsync(_request).ConfigureAwait(false); //invoke request and get response HttpStringResponse _response = await GetClientInstance().ExecuteAsStringAsync(_request, cancellationToken).ConfigureAwait(false); HttpContext _context = new HttpContext(_request, _response); if (HttpCallBack != null) { HttpCallBack.OnAfterHttpResponseEventHandler(GetClientInstance(), _response); } //handle errors defined at the API level base.ValidateResponse(_response, _context); var _responseModel = ApiHelper.JsonDeserialize <Models.V1Order>(_response.Body); _responseModel.Context = _context; return(_responseModel); }