12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using OASystem.Domain.ViewModels.JuHeExchangeRate;
- using System.Net.Http;
- using System.Net.Http.Json;
- using Ubiety.Dns.Core;
- namespace OASystem.API.OAMethodLib.JuHeAPI
- {
-
-
-
- public class JuHeApiService: IJuHeApiService
- {
- private readonly HttpClient _httpClient;
- private readonly string _appKey = "0f5429e9fbb8637c0ff3f14bbb42c732";
-
-
-
-
- public JuHeApiService(HttpClient httpClient)
- {
- _httpClient = httpClient;
- _httpClient.BaseAddress = new Uri("http://web.juhe.cn:8080");
- }
-
-
-
-
-
- public async Task<string> GetExchangeRateAsync()
- {
- string url = string.Format("/finance/exchange/rmbquot");
- var parameters2 = new Dictionary<string, string>();
- parameters2.Add("key", _appKey);
- parameters2.Add("type", "0");
- parameters2.Add("bank", "3");
- var httpContent = new StringContent(JsonConvert.SerializeObject(parameters2), Encoding.UTF8, "application/json");
- var exchangeReq = await _httpClient.PostAsync(url, httpContent);
- if (exchangeReq.IsSuccessStatusCode)
- {
- var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
- }
- else {
-
- }
- throw new HttpRequestException(exchangeReq.ReasonPhrase);
- }
- }
- }
|