class Io::Flow::Reference::V0::Models::Currency
ISO 4217 3-character currency code. See api.flow.io/reference/currencies
Attributes
default_locale[R]
iso_4217_3[R]
name[R]
number_decimals[R]
symbols[R]
Public Class Methods
new(incoming={})
click to toggle source
# File lib/flow_reference_v0_client.rb, line 521 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name, :iso_4217_3, :number_decimals], 'Currency') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @iso_4217_3 = HttpClient::Preconditions.assert_class('iso_4217_3', opts.delete(:iso_4217_3), String) @number_decimals = HttpClient::Preconditions.assert_class('number_decimals', opts.delete(:number_decimals), Integer) @symbols = (x = opts.delete(:symbols); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::Reference::V0::Models::CurrencySymbols) ? x : ::Io::Flow::Reference::V0::Models::CurrencySymbols.new(x))) @default_locale = (x = opts.delete(:default_locale); x.nil? ? nil : HttpClient::Preconditions.assert_class('default_locale', x, String)) end
Public Instance Methods
copy(incoming={})
click to toggle source
# File lib/flow_reference_v0_client.rb, line 535 def copy(incoming={}) Currency.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end
to_cents(amount_in)
click to toggle source
# File lib/flowcommerce-reference.rb, line 104 def to_cents(amount_in) (amount_in * (10**number_decimals)).round(0) end
to_hash()
click to toggle source
# File lib/flow_reference_v0_client.rb, line 539 def to_hash { :name => name, :iso_4217_3 => iso_4217_3, :number_decimals => number_decimals, :symbols => symbols.nil? ? nil : symbols.to_hash, :default_locale => default_locale } end
to_json()
click to toggle source
# File lib/flow_reference_v0_client.rb, line 531 def to_json JSON.dump(to_hash) end