Esempio n. 1
0
 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));
 }
Esempio n. 2
0
        public WilmaSession(WilmaContext context, IndexResponse data)
        {
            Context = context;

            Roles      = data.Roles;
            FormKey    = data.FormKey;
            ApiVersion = data.ApiVersion;
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public UserApi(WilmaContext context)
 {
     _context = context;
 }