Class: Io::Flow::V0::Models::Currency

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

ISO 4217 3-character currency code. See api.flow.io/reference/currencies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Currency

Returns a new instance of Currency.



14157
14158
14159
14160
14161
14162
14163
14164
14165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14157

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::V0::Models::CurrencySymbols) ? x : ::Io::Flow::V0::Models::CurrencySymbols.new(x)))
  @default_locale = (x = opts.delete(:default_locale); x.nil? ? nil : HttpClient::Preconditions.assert_class('default_locale', x, String))
end

Instance Attribute Details

#default_localeObject (readonly)

Returns the value of attribute default_locale.



14155
14156
14157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14155

def default_locale
  @default_locale
end

#iso_4217_3Object (readonly)

Returns the value of attribute iso_4217_3.



14155
14156
14157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14155

def iso_4217_3
  @iso_4217_3
end

#nameObject (readonly)

Returns the value of attribute name.



14155
14156
14157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14155

def name
  @name
end

#number_decimalsObject (readonly)

Returns the value of attribute number_decimals.



14155
14156
14157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14155

def number_decimals
  @number_decimals
end

#symbolsObject (readonly)

Returns the value of attribute symbols.



14155
14156
14157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14155

def symbols
  @symbols
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14171
14172
14173
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14171

def copy(incoming={})
  Currency.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



14175
14176
14177
14178
14179
14180
14181
14182
14183
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14175

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_jsonObject



14167
14168
14169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14167

def to_json
  JSON.dump(to_hash)
end