Class: Io::Flow::V0::Models::Province

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

Overview

A subdivision/province/state within a country. These conform to the ISO 3166-2 standard for country subdivisions. See api.flow.io/reference/provinces

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Province

Returns a new instance of Province.



61064
61065
61066
61067
61068
61069
61070
61071
61072
61073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61064

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :iso_3166_2, :name, :country, :province_type], 'Province')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @iso_3166_2 = HttpClient::Preconditions.assert_class('iso_3166_2', opts.delete(:iso_3166_2), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @country = HttpClient::Preconditions.assert_class('country', opts.delete(:country), String)
  @province_type = (x = opts.delete(:province_type); x.is_a?(::Io::Flow::V0::Models::ProvinceType) ? x : ::Io::Flow::V0::Models::ProvinceType.apply(x))
  @translations = (x = opts.delete(:translations); x.nil? ? nil : HttpClient::Preconditions.assert_class('translations', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LocalizedTranslation) ? x : ::Io::Flow::V0::Models::LocalizedTranslation.new(x)) })
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def country
  @country
end

#idObject (readonly)

Returns the value of attribute id.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def id
  @id
end

#iso_3166_2Object (readonly)

Returns the value of attribute iso_3166_2.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def iso_3166_2
  @iso_3166_2
end

#nameObject (readonly)

Returns the value of attribute name.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def name
  @name
end

#province_typeObject (readonly)

Returns the value of attribute province_type.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def province_type
  @province_type
end

#translationsObject (readonly)

Returns the value of attribute translations.



61062
61063
61064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61062

def translations
  @translations
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



61079
61080
61081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61079

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

#to_hashObject



61083
61084
61085
61086
61087
61088
61089
61090
61091
61092
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61083

def to_hash
  {
    :id => id,
    :iso_3166_2 => iso_3166_2,
    :name => name,
    :country => country,
    :province_type => province_type.value,
    :translations => translations.nil? ? nil : translations.map { |o| o.to_hash }
  }
end

#to_jsonObject



61075
61076
61077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61075

def to_json
  JSON.dump(to_hash)
end