Projekt

Obecné

Profil

Stáhnout (879 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Net.Http.Json;
5
using System.Text;
6
using System.Text.Json;
7
using System.Text.Json.Serialization;
8
using System.Threading.Tasks;
9
using LDClient.network.data;
10

    
11
namespace LDClient.network {
12
    public class HttpClient : IHttpClient{
13

    
14
        private readonly System.Net.Http.HttpClient _httpClient;
15

    
16
        private readonly string _uri;
17
        public HttpClient(string uri) {
18

    
19
            _httpClient = new System.Net.Http.HttpClient();
20
            _uri = uri;
21
        }
22

    
23
        public Task<HttpResponseMessage> PostAsJsonAsync(Payload payload) {
24
            return _httpClient.PostAsJsonAsync(_uri, payload, new JsonSerializerOptions {
25
                Converters = {
26
                    new JsonStringEnumConverter( JsonNamingPolicy.CamelCase)
27
                }
28
            });
29

    
30
        }
31
    }
32
}
(2-2/4)