Class: Io::Flow::V0::Models::Country

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

Overview

ISO 3166 country codes. Note Flow APIs will accept either the 2 or 3 character country code, but internally we normalize data and store as the 3 character, upper case ISO code. See api.flow.io/reference/countries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Country

Returns a new instance of Country.



33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33951

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :iso_3166_2, :iso_3166_3, :languages, :measurement_system, :timezones], 'Country')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @iso_3166_2 = HttpClient::Preconditions.assert_class('iso_3166_2', opts.delete(:iso_3166_2), String)
  @iso_3166_3 = HttpClient::Preconditions.assert_class('iso_3166_3', opts.delete(:iso_3166_3), String)
  @languages = HttpClient::Preconditions.assert_class('languages', opts.delete(:languages), Array).map { |v| HttpClient::Preconditions.assert_class('languages', v, String) }
  @measurement_system = HttpClient::Preconditions.assert_class('measurement_system', opts.delete(:measurement_system), String)
  @default_currency = (x = opts.delete(:default_currency); x.nil? ? nil : HttpClient::Preconditions.assert_class('default_currency', x, String))
  @default_language = (x = opts.delete(:default_language); x.nil? ? nil : HttpClient::Preconditions.assert_class('default_language', x, String))
  @timezones = HttpClient::Preconditions.assert_class('timezones', opts.delete(:timezones), Array).map { |v| HttpClient::Preconditions.assert_class('timezones', v, String) }
  @default_delivered_duty = (x = opts.delete(:default_delivered_duty); x.nil? ? nil : HttpClient::Preconditions.assert_class('default_delivered_duty', x, String))
end

Instance Attribute Details

#default_currencyObject (readonly)

Returns the value of attribute default_currency.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def default_currency
  @default_currency
end

#default_delivered_dutyObject (readonly)

Returns the value of attribute default_delivered_duty.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def default_delivered_duty
  @default_delivered_duty
end

#default_languageObject (readonly)

Returns the value of attribute default_language.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def default_language
  @default_language
end

#iso_3166_2Object (readonly)

Returns the value of attribute iso_3166_2.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def iso_3166_2
  @iso_3166_2
end

#iso_3166_3Object (readonly)

Returns the value of attribute iso_3166_3.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def iso_3166_3
  @iso_3166_3
end

#languagesObject (readonly)

Returns the value of attribute languages.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def languages
  @languages
end

#measurement_systemObject (readonly)

Returns the value of attribute measurement_system.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def measurement_system
  @measurement_system
end

#nameObject (readonly)

Returns the value of attribute name.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def name
  @name
end

#timezonesObject (readonly)

Returns the value of attribute timezones.



33949
33950
33951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33949

def timezones
  @timezones
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33969
33970
33971
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33969

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

#to_hashObject



33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33973

def to_hash
  {
    :name => name,
    :iso_3166_2 => iso_3166_2,
    :iso_3166_3 => iso_3166_3,
    :languages => languages,
    :measurement_system => measurement_system,
    :default_currency => default_currency,
    :default_language => default_language,
    :timezones => timezones,
    :default_delivered_duty => default_delivered_duty
  }
end

#to_jsonObject



33965
33966
33967
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33965

def to_json
  JSON.dump(to_hash)
end