Exemplo n.º 1
0
        /// <summary>
        /// Calls a POST request on the specified path, posting the model data as JSON.
        /// </summary>
        /// <typeparam name="T">Type to return deserialised JSON as.</typeparam>
        /// <param name="path">URL of the path to call as a string.</param>
        /// <param name="data">Model data to be serialised as JSON.</param>
        /// <returns></returns>
        public Task <HttpResponseMessage> PutAsync <T>(string path, T data)
        {
            CheckTokenExists();
            var content = CreateStringContent(JsonService.SerializeObjectToJson(data));

            return(_httpClient.PutAsync(path, content));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Helper method to serialize a HttpResponseMessage <paramref name="response"/> to an object of type <typeparamref name="T"/>
 /// </summary>
 /// <typeparam name="T">Object type to seralize to.</typeparam>
 /// <param name="response">The HttpResponseMessage to seralize.</param>
 /// <returns>Returns <paramref name="response"/> as seralized object of type <typeparamref name="T"/></returns>
 private async Task <T> Serialize <T>(HttpResponseMessage response)
 {
     return(JsonService.SerializeJsonToObject <T>(await response.Content.ReadAsStringAsync()));
 }