Esempio n. 1
0
        private async Task <YawatResult> PostProcessResponse(HttpResponseMessage response, YawatOptions options)
        {
            var stringData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var responseData = Activator.CreateInstance(options.ResponseType, stringData) as IYawatResponseData;

            var result = new YawatResult(responseData)
            {
                StatusCode = response.StatusCode
            };

            if (options.IncludeHeaders)
            {
                foreach (var header in response.Headers)
                {
                    result.Headers.Add(header.Key, header.Value);
                }

                foreach (var header in response.Content.Headers)
                {
                    result.Headers.Add(header.Key, header.Value);
                }
            }

            return(result);
        }
Esempio n. 2
0
        private YawatResult Request(HttpMethod verb, string endPoint, string jsonString = "",
                                    YawatOptions options = null)
        {
            YawatResult json = null;

            Task.Run(async() =>
            {
                json = await this.RequestAsync(verb, endPoint, jsonString, options);
            }).Wait();

            return(json);
        }