public static Currency Get(eCurrencyCode currencyCodeCode) { if (CurrencyDictionary.ContainsKey(currencyCodeCode)) { return(CurrencyDictionary[currencyCodeCode]); } return(null); }
public async Task <APIExchangeRate> GetExchangeRate(eCurrencyCode Code, DateTime?AsOfDate = null) { if (!AsOfDate.HasValue) { AsOfDate = DateTime.Now; } var querystring = $"sourcecurrencycode={Code}&asofdate={AsOfDate.Value.ToString("yyyy-MM-dd")}"; var response = this.HttpService.GET($"{this.Config.BaseURL}company/{this.Config.CompanyId}/exchangerate", querystring, new Dictionary <string, string> { ["Accept"] = "application/json", ["Content-Type"] = "application/text", ["Authorization"] = $"Bearer {this.Config.AccessToken}" }); // Unauthorized (401) - refresh token and try again if (!response.Success && response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { await this.RefreshToken(); response = this.HttpService.GET($"{this.Config.BaseURL}company/{this.Config.CompanyId}/exchangerate", querystring, new Dictionary <string, string> { ["Accept"] = "application/json", ["Content-Type"] = "application/text", ["Authorization"] = $"Bearer {this.Config.AccessToken}" }); } if (!response.Success) { throw new APIException(this.ParseError(response.Content)); } var modelSchema = new { ExchangeRate = new { SourceCurrencyCode = string.Empty, TargetCurrencyCode = string.Empty, Rate = 0.0F, AsOfDate = string.Empty } }; var responseData = JsonConvert.DeserializeAnonymousType(response.Content, modelSchema); return(new APIExchangeRate { Source = (eCurrencyCode)Enum.Parse(typeof(eCurrencyCode), responseData.ExchangeRate.SourceCurrencyCode, true), Target = (eCurrencyCode)Enum.Parse(typeof(eCurrencyCode), responseData.ExchangeRate.TargetCurrencyCode, true), Rate = responseData.ExchangeRate.Rate, AsOfDate = responseData.ExchangeRate.AsOfDate }); }
/// <summary> /// Constructs a currency object with a NumberFormatInfo. /// </summary> /// <param name="currencyCode"></param> public Currency(eCurrencyCode currencyCode) { CurrencyCode = currencyCode; Code = Enum.GetName(typeof(eCurrencyCode), CurrencyCode); var cultureInfo = CultureInfoFromCurrencyISO(Code); NumberFormat = cultureInfo.NumberFormat; var region = new RegionInfo(cultureInfo.LCID); Symbol = region?.CurrencySymbol; EnglishName = region?.CurrencyEnglishName; NativeName = region?.CurrencyNativeName; }
public static bool Exists(eCurrencyCode currencyCodeCode) { return(CurrencyDictionary.ContainsKey(currencyCodeCode)); }
public MoneyAmount(eCurrencyCode currencyCode, decimal amount) { this.CurrencyCode = currencyCode; this.Amount = amount; }