public static async Task <HttpResponseMessage> PostAsync(WilmaContext context, string path, ICollection <KeyValuePair <string, string> > parameters = default, IDictionary <string, object> queryParameters = default) { using var request = CreateRequest(context, HttpMethod.Post, path, queryParameters, parameters); return(await _client.SendAsync(request).ConfigureAwait(false)); }
public WilmaSession(WilmaContext context, IndexResponse data) { Context = context; Roles = data.Roles; FormKey = data.FormKey; ApiVersion = data.ApiVersion; }
public static async Task <T> GetAsync <T>(WilmaContext context, string path, ICollection <KeyValuePair <string, object> > queryParameters = default, Func <HttpContent, Task <T> > contentDeserializer = default) { using var request = CreateRequest(context, HttpMethod.Get, path, queryParameters); using var response = await _client.SendAsync(request).ConfigureAwait(false); return(await DeserializeContentAsync(response, contentDeserializer).ConfigureAwait(false)); }
public static HttpRequestMessage CreateRequest(WilmaContext context, HttpMethod method, string path, ICollection <KeyValuePair <string, object> > queryParameters = default, ICollection <KeyValuePair <string, string> > parameters = default) { queryParameters ??= new Dictionary <string, object>(); queryParameters.Add(new KeyValuePair <string, object>("LangID", (int)context.Language)); queryParameters.Add(new KeyValuePair <string, object>("format", "json")); var request = new HttpRequestMessage(method, context.Url + path + GetQueryString(queryParameters)); if (parameters?.Count > 0) { request.Content = new FormUrlEncodedContent(parameters); } return(request); }
public UserApi(WilmaContext context) { _context = context; }