Module: CDEKApiClient::Entities::CurrencyMapper

Defined in:
lib/cdek_api_client/entities/currency_mapper.rb

Overview

CurrencyMapper is a utility module that maps currency codes to their respective integer representations.

Constant Summary collapse

CURRENCY_CODES =
{
  'RUB' => 1,
  'KZT' => 2,
  'USD' => 3,
  'EUR' => 4,
  'GBP' => 5,
  'CNY' => 6,
  'BYR' => 7,
  'UAH' => 8,
  'KGS' => 9,
  'AMD' => 10,
  'TRY' => 11,
  'THB' => 12,
  'KRW' => 13,
  'AED' => 14,
  'UZS' => 15,
  'MNT' => 16,
  'PLN' => 17,
  'AZN' => 18,
  'GEL' => 19,
  'JPY' => 55
}.freeze

Class Method Summary collapse

Class Method Details

.to_code(currency) ⇒ Integer

Converts a currency code to its corresponding integer representation.

Parameters:

  • currency (String)

    the currency code to convert.

Returns:

  • (Integer)

    the integer representation of the currency code.

Raises:

  • (ArgumentError)

    if the currency code is invalid.



35
36
37
# File 'lib/cdek_api_client/entities/currency_mapper.rb', line 35

def self.to_code(currency)
  CURRENCY_CODES[currency] || (raise ArgumentError, "Invalid currency code: #{currency}")
end