示例#1
0
        public async Task <T> Put <T>(string route, BaseRequestResponse baseRequest) where T : BaseRequestResponse
        {
            StringContent       jsonRequest = new StringContent(JsonUtility.ToJson(baseRequest), Encoding.UTF8, "application/json");
            HttpResponseMessage response    = await _client.PutAsync(route, jsonRequest);

            await ProcessResponse(response);

            return(JsonUtility.FromJson <T>(await response.Content.ReadAsStringAsync()));
        }
示例#2
0
        public async Task <T> Patch <T>(string route, BaseRequestResponse baseRequest) where T : BaseRequestResponse
        {
            HttpMethod         method      = new HttpMethod("PATCH");
            StringContent      content     = new StringContent(JsonUtility.ToJson(baseRequest), Encoding.UTF8, "application/json");
            HttpRequestMessage httpRequest = new HttpRequestMessage(method, new Uri(_baseUri, route))
            {
                Content = content
            };
            HttpResponseMessage response = await _client.SendAsync(httpRequest);

            await ProcessResponse(response);

            return(JsonUtility.FromJson <T>(await response.Content.ReadAsStringAsync()));
        }
示例#3
0
        public async Task <T> Get <T>(string route, BaseRequestResponse baseRequest = null) where T : BaseRequestResponse
        {
            string query = "";

            if (baseRequest != null)
            {
                query = baseRequest.GetQueryString();
                Debug.Log(query);
            }

            HttpResponseMessage response = await _client.GetAsync($"{route}{query}");

            await ProcessResponse(response);

            return(JsonUtility.FromJson <T>(await response.Content.ReadAsStringAsync()));
        }