예제 #1
0
        public async Task <QuoteRootObject> GetQuoteAsJsonAsync(string queryString)
        {
            Assert.AreEqual(2, creds.Length);
            AccessToken = creds[0];
            Uri         = creds[1];

            httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
            httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {AccessToken}");

            using (httpResponseMessage = await httpClient.GetAsync($"{Uri}{queryString}"))
            {
                string content = await httpResponseMessage.Content.ReadAsStringAsync();

                if (httpResponseMessage.IsSuccessStatusCode)
                {
                    // QuoteRootObject quoteRootObject = JsonConvert.DeserializeObject<QuoteRootObject>(content);
                    QuoteRootObject quoteRootObject = ResponseDataHelper.DeserializeStringToJson <QuoteRootObject>(content);
                    return(quoteRootObject);
                }

                return(new QuoteRootObject());
            }
        }