protected async Task Get( string url, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> response = null) { await MakeRequest(HttpMethod.Get, url, null, headers, response); }
protected async Task Put(string url, object data = null, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> outResponse = null) { await MakeRequest(HttpMethod.Put, url, data, headers, outResponse); }
protected async Task <T> Put <T>(string url, object data = null, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> outResponse = null) { var result = await MakeRequest(HttpMethod.Put, url, data, headers, outResponse); return(await DeserializeOrDefault <T>(result)); }
private async Task <HttpResponseMessage> MakeRequest( HttpMethod method, string url, object data = null, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> outResponse = null) { var message = GetMessage(method, url, headers); HttpResponseMessage result; using (message.Content = GetMessageContent(data)) { using (var client = GetClient()) { // Console.WriteLine("DEBUG MODE: Request\n" // + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" // + method + ": " + url + "\n" // + "Headers: " + headers + "\n" // + "Payout: " + json + "\n"); result = await client.SendAsync(message); // Console.WriteLine("DEBUG MODE: Response\n" // + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" // + "Code: " + result.StatusCode + "\n" // + "Headers: " + Serialize(result.Headers) + "\n" // + "Body: " + await result.Content.ReadAsStringAsync() + "\n"); await ThrowIfError(result); } } if (outResponse != null) { outResponse.Value = result; } return(result); }
protected Task Delete(string url, object data = null, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> outResponse = null) { return(MakeRequest(HttpMethod.Delete, url, data, headers, outResponse)); }
protected Task Patch(string url, object data = null, IDictionary <string, string> headers = null, Ref <HttpResponseMessage> outResponse = null) { return(MakeRequest(new HttpMethod("PATCH"), url, data, headers, outResponse)); }