protected async Task <T> Post <T>(Endpoint endPoint, UrlParameters parameters, BodyData bodyData) { string url = this.BuildUrl(this.baseApiUrl + endPoint.GetUrl(), parameters); //Console.WriteLine("url : {0}", url); HttpResponseMessage response = await client.PostAsync(url, bodyData.GetStringContent()); string result = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { ResponseObject err = JsonConvert.DeserializeObject <ResponseObject>(result); throw new ApiException(response.StatusCode, err.status_code, err.status_message); } return(JsonConvert.DeserializeObject <T>(result)); }
protected async Task <T> Delete <T>(Endpoint endPoint, UrlParameters parameters, BodyData bodyData) { string url = this.BuildUrl(this.baseApiUrl + endPoint.GetUrl(), parameters); var request = new HttpRequestMessage { Method = HttpMethod.Delete, RequestUri = new Uri(url), Content = bodyData.GetStringContent() }; HttpResponseMessage response = await client.SendAsync(request); string result = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { ResponseObject err = JsonConvert.DeserializeObject <ResponseObject>(result); throw new ApiException(response.StatusCode, err.status_code, err.status_message); } return(JsonConvert.DeserializeObject <T>(result)); }