Example #1
0
 public static RestRequestBuilder WithHeaders(this RestRequestBuilder builder, IEnumerable <KeyValuePair <string, string> > headers)
 {
     foreach (var header in headers)
     {
         builder.Headers[header.Key] = header.Value;
     }
     return(builder);
 }
Example #2
0
 public static RestRequestBuilder WithCookies(this RestRequestBuilder builder, IEnumerable <KeyValuePair <string, string> > cookies)
 {
     foreach (var cookie in cookies)
     {
         builder.Cookies[cookie.Key] = cookie.Value;
     }
     return(builder);
 }
Example #3
0
 public static RestRequestBuilder WithQueryParams(this RestRequestBuilder builder, IEnumerable <KeyValuePair <string, string> > queryParams)
 {
     foreach (var param in queryParams)
     {
         builder.QueryParams.Add(param.Key, param.Value);
     }
     return(builder);
 }
Example #4
0
 public static RestRequestBuilder WithQueryParam(this RestRequestBuilder builder, string key, string value)
 {
     builder.QueryParams.Add(key, value);
     return(builder);
 }
Example #5
0
 public static RestRequestBuilder WithRequestTimeout(this RestRequestBuilder builder, TimeSpan timeout)
 {
     builder.Timeout = timeout;
     return(builder);
 }
Example #6
0
 public static RestRequestBuilder WithRequestTimeout(this RestRequestBuilder builder, int seconds)
 {
     return(builder.WithRequestTimeout(TimeSpan.FromSeconds(seconds)));
 }
Example #7
0
 public static RestRequestBuilder WithOAuthBearerToken(this RestRequestBuilder builder, string token)
 {
     return(builder.WithAuthentication("Bearer", token));
 }
Example #8
0
 public static RestRequestBuilder WithHeader(this RestRequestBuilder builder, string key, string value)
 {
     builder.Headers[key] = value;
     return(builder);
 }
Example #9
0
 public static RestRequestBuilder WithCookie(this RestRequestBuilder builder, string key, string value)
 {
     builder.Cookies[key] = value;
     return(builder);
 }
Example #10
0
 public static RestRequestBuilder WithContent(this RestRequestBuilder builder, string content)
 {
     builder.Content = new StringContent(content);
     return(builder);
 }
Example #11
0
 public static RestRequestBuilder WithContent(this RestRequestBuilder builder, HttpContent content)
 {
     builder.Content = content;
     return(builder);
 }
Example #12
0
 public static RestRequestBuilder WithBasicAuthentication(this RestRequestBuilder builder, string token)
 {
     return(builder.WithAuthentication("Basic", token));
 }
Example #13
0
        public static RestRequestBuilder WithBasicAuthentication(this RestRequestBuilder builder, string username, string password)
        {
            var token = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));

            return(builder.WithBasicAuthentication(token));
        }
Example #14
0
 public static RestRequestBuilder WithAuthentication(this RestRequestBuilder builder, string scheme, string token)
 {
     builder.Request.Headers.Authorization = new AuthenticationHeaderValue(scheme, token);
     return(builder);
 }
Example #15
0
 public static RestRequestBuilder UsingRoute(this RestRequestBuilder builder, string route)
 {
     builder.Route = route;
     return(builder);
 }
Example #16
0
 public static RestRequestBuilder WithQueryParams(this RestRequestBuilder builder, NameValueCollection queryParams)
 {
     builder.QueryParams.Add(queryParams);
     return(builder);
 }