Sha256: c4fd3448b0330a5990172e1c6f346bcd162512d213680b503243c0addcb6b502

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 Bytes

Contents

require 'mint/fixer_currency/version'
require 'mint/fixer_currency/exceptions'
require 'mint/fixer_currency/request'

module Mint
  # Access to foreign exchange rates from Fixer.io
  #
  # @author Renat Ibragimov <renat@aomega.co>
  #
  # @see https://github.com/mpakus/mint-fixer_currency
  module FixerCurrency
    # Gets you currency exchange rates
    # @param currency [Symbol, String] based currency
    # @param date [String] YYYY-MM-DD optional date or latest by default
    # @return [Hash]
    def self.rates(currency = :USD, date = nil)
      currency = currency.to_s.upcase.to_sym
      raise(WrongCurrencyError, currency) unless currencies.include? currency
      Request.new(currency, date).perform!
    end

    # List of available currencies
    # @return [Array<Symbols>]
    def self.currencies
      %i[AUD BGN BRL CAD CHF CNY CZK DKK GBP HKD HRK HUF IDR ILS INR JPY KRW MXN MYR NOK NZD PHP PLN RON RUB
         SEK SGD TRY USD ZAR EUR]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mint-fixer_currency-0.1.0 lib/mint/fixer_currency.rb