Example #1
0
 public Task <Response <TResponse> > PutJsonAsync <TRequest, TResponse>(TRequest model, string url, HttpOptions options, params Header[] headers)
 {
     return(Json.Response.FromModel(model)
            .BindAsync(json =>
                       HypertextTransferProtocol.SendAsync(json, url, "application/json", options, Http.AddJsonAccept(headers), HttpMethod.Put)
                       .ContinueWith(x => x.Result.Match(y => Json.Response.ToModel <TResponse>(y), ex => { ex.LogValue(ex.ToString()); return new Response <TResponse>(); }))
                       ));
 }
 public Task <Maybe <TResponse> > PutJsonAsync <TRequest, TResponse>(TRequest model, string url, HttpOptions options, params Header[] headers)
 {
     return(Json.Maybe.FromModel(model).MatchAsync(
                json => HypertextTransferProtocol
                .SendAsync(json, url, "application/json", options, Http.AddJsonAccept(headers), HttpMethod.Put)
                .ContinueWith(x => x.Result.Match(y => Json.Maybe.ToModel <TResponse>(y)
                                                  .Match(z => new Maybe <TResponse>(z), ex => new Maybe <TResponse>(ex)), ex => new Maybe <TResponse>(ex))),
                ex => new Maybe <TResponse>(ex)
                ));
 }
Example #3
0
 public static Task <TResponse> DeleteJsonAsync <TResponse>(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, AddJsonAccept(headers), HttpMethod.Delete).ContinueWith(x => x.Result.Match(y => Json.ToModel <TResponse>(y), ex => throw ex)));
 }
Example #4
0
 public static Task <string> DeleteAsync(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, headers, HttpMethod.Delete).ContinueWith(x => x.Result.Match(y => y, ex => throw ex)));
 }
Example #5
0
 public static Task <TResponse> PutJsonAsync <TRequest, TResponse>(TRequest model, string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(Json.FromModel(model), url, "application/json", options, AddJsonAccept(headers), HttpMethod.Put).ContinueWith(x => x.Result.Match(y => Json.ToModel <TResponse>(y), ex => throw ex)));
 }
Example #6
0
 public static Task <string> PutAsync(string body, string url, string contentType, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(body, url, contentType, options, headers, HttpMethod.Put).ContinueWith(x => x.Result.Match(y => y, ex => throw ex)));
 }
Example #7
0
 public Task <Response <TResponse> > DeleteAsync <TResponse>(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, Http.AddJsonAccept(headers), HttpMethod.Delete).ContinueWith(x => x.Result.Match(y => Json.Response.ToModel <TResponse>(y), ex => { ex.LogValue(ex.ToString()); return new Response <TResponse>(); })));
 }
Example #8
0
 public Task <Response <string> > DeleteAsync(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, headers, HttpMethod.Delete).ContinueWith(x => x.Result.Match(y => Response.Create(y), ex => { ex.LogValue(ex.ToString()); return new Response <string>(); })));
 }
Example #9
0
 public Task <Response <string> > PostAsync(string body, string url, string contentType, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(body, url, contentType, options, headers, HttpMethod.Post).ContinueWith(x => x.Result.Match(y => Response.Create(y), ex => { ex.LogValue(ex.ToString()); return new Response <string>(); })));
 }
 public Task <Maybe <string, HttpException> > DeleteAsync(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, headers, HttpMethod.Delete).ContinueWith(x => x.Result.Match(y => new Maybe <string, HttpException>(y), ex => new Maybe <string, HttpException>(ex))));
 }
 public Task <Maybe <TResponse> > GetJsonAsync <TResponse>(string url, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(string.Empty, url, string.Empty, options, Http.AddJsonAccept(headers), HttpMethod.Get).ContinueWith(x => x.Result.Match(y => Json.Maybe.ToModel <TResponse>(y).Match(z => new Maybe <TResponse>(z), ex => new Maybe <TResponse>(ex)), ex => new Maybe <TResponse>(ex))));
 }
 public Task <Maybe <string, HttpException> > PutAsync(string body, string url, string contentType, HttpOptions options, params Header[] headers)
 {
     return(HypertextTransferProtocol.SendAsync(body, url, contentType, options, headers, HttpMethod.Put).ContinueWith(x => x.Result.Match(y => new Maybe <string, HttpException>(y), ex => new Maybe <string, HttpException>(ex))));
 }