/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <param name="item_id">The eBay RESTful identifier of an item you want to bid on. This ID is returned by the Browse and Feed API methods. RESTful Item ID Example: v1|272394640372|0 For more information about item ID for RESTful APIs, see the Legacy API compatibility section of the Buy APIs Overview.</param> /// <param name="x_EBAY_C_MARKETPLACE_ID">The ID of the eBay marketplace where the buyer is based. Note: This value is case sensitive. For example: &nbsp;&nbsp;X-EBAY-C-MARKETPLACE-ID = EBAY_US For a list of supported sites see, API Restrictions.</param> /// <returns>OK</returns> /// <exception cref="eBayApi.ApiException">A server side error occurred.</exception> public async System.Threading.Tasks.Task <PlaceProxyBidResponse> PlaceProxyBidAsync(string item_id, string x_EBAY_C_MARKETPLACE_ID, PlaceProxyBidRequest body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { if (item_id == null) { throw new System.ArgumentNullException("item_id"); } var urlBuilder_ = new System.Text.StringBuilder(); urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/bidding/{item_id}/place_proxy_bid"); urlBuilder_.Replace("{item_id}", System.Uri.EscapeDataString(ConvertToString(item_id, System.Globalization.CultureInfo.InvariantCulture))); var client_ = _httpClient; try { using (var request_ = new System.Net.Http.HttpRequestMessage()) { if (x_EBAY_C_MARKETPLACE_ID == null) { throw new System.ArgumentNullException("x_EBAY_C_MARKETPLACE_ID"); } request_.Headers.TryAddWithoutValidation("X-EBAY-C-MARKETPLACE-ID", ConvertToString(x_EBAY_C_MARKETPLACE_ID, System.Globalization.CultureInfo.InvariantCulture)); var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value)); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); PrepareRequest(client_, request_, urlBuilder_); var url_ = urlBuilder_.ToString(); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); PrepareRequest(client_, request_, url_); var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); try { var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); if (response_.Content != null && response_.Content.Headers != null) { foreach (var item_ in response_.Content.Headers) { headers_[item_.Key] = item_.Value; } } ProcessResponse(client_, response_); var status_ = ((int)response_.StatusCode).ToString(); if (status_ == "200") { var objectResponse_ = await ReadObjectResponseAsync <PlaceProxyBidResponse>(response_, headers_).ConfigureAwait(false); return(objectResponse_.Object); } else if (status_ == "400") { string responseText_ = (response_.Content == null) ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new eBayApi.ApiException("Bad request", (int)response_.StatusCode, responseText_, headers_, null); } else if (status_ == "404") { string responseText_ = (response_.Content == null) ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new eBayApi.ApiException("Not found", (int)response_.StatusCode, responseText_, headers_, null); } else if (status_ == "409") { string responseText_ = (response_.Content == null) ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new eBayApi.ApiException("Conflict", (int)response_.StatusCode, responseText_, headers_, null); } else if (status_ == "500") { string responseText_ = (response_.Content == null) ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new eBayApi.ApiException("Internal Server Error", (int)response_.StatusCode, responseText_, headers_, null); } else if (status_ != "200" && status_ != "204") { var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); throw new eBayApi.ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); } return(default(PlaceProxyBidResponse)); } finally { if (response_ != null) { response_.Dispose(); } } } } finally { } }
/// <param name="item_id">The eBay RESTful identifier of an item you want to bid on. This ID is returned by the Browse and Feed API methods. RESTful Item ID Example: v1|272394640372|0 For more information about item ID for RESTful APIs, see the Legacy API compatibility section of the Buy APIs Overview.</param> /// <param name="x_EBAY_C_MARKETPLACE_ID">The ID of the eBay marketplace where the buyer is based. Note: This value is case sensitive. For example: &nbsp;&nbsp;X-EBAY-C-MARKETPLACE-ID = EBAY_US For a list of supported sites see, API Restrictions.</param> /// <returns>OK</returns> /// <exception cref="eBayApi.ApiException">A server side error occurred.</exception> public PlaceProxyBidResponse PlaceProxyBid(string item_id, string x_EBAY_C_MARKETPLACE_ID, PlaceProxyBidRequest body = null) { return(System.Threading.Tasks.Task.Run(async() => await PlaceProxyBidAsync(item_id, x_EBAY_C_MARKETPLACE_ID, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult()); }