示例#1
0
        /// <summary>
        /// For Quick Test Get Method
        /// </summary>
        /// <typeparam name="TResult">Result to deserialize object type</typeparam>
        /// <param name="url">url to post</param>
        public static async Task <TResult> Get <TResult>(string url)
        {
            var response = await NotificationClientManager.GetClient().GetAsync(url).ConfigureAwait(false);

            var mobileResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <TResult>(mobileResult);

            return(result);
        }
示例#2
0
        /// <summary>
        /// For Quick Test Post Method
        /// </summary>
        /// <typeparam name="TResult">Result to deserialize object type</typeparam>
        /// <typeparam name="TPost">Type to be posted</typeparam>
        /// <param name="value">post value to be serialized</param>
        /// <param name="postUrl">Post url</param>
        public static async Task <TResult> Post <TResult, TPost>(TPost value, string postUrl)
        {
            var response = await NotificationClientManager.GetClient().PostAsync(postUrl,
                                                                                 new StringContent(JsonConvert.SerializeObject(value, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }),
                                                                                                   Encoding.UTF8, "application/json")).ConfigureAwait(false);

            var mobileResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <TResult>(mobileResult);

            return(result);
        }