Class: Io::Flow::V0::Models::Province
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Province
- 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
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#iso_3166_2 ⇒ Object
readonly
Returns the value of attribute iso_3166_2.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#province_type ⇒ Object
readonly
Returns the value of attribute province_type.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Province
constructor
A new instance of Province.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Province
Returns a new instance of Province.
35406 35407 35408 35409 35410 35411 35412 35413 35414 35415 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35406 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
#country ⇒ Object (readonly)
Returns the value of attribute country.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def country @country end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def id @id end |
#iso_3166_2 ⇒ Object (readonly)
Returns the value of attribute iso_3166_2.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def iso_3166_2 @iso_3166_2 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def name @name end |
#province_type ⇒ Object (readonly)
Returns the value of attribute province_type.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def province_type @province_type end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
35404 35405 35406 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35404 def translations @translations end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
35421 35422 35423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35421 def copy(incoming={}) Province.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
35425 35426 35427 35428 35429 35430 35431 35432 35433 35434 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35425 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_json ⇒ Object
35417 35418 35419 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35417 def to_json JSON.dump(to_hash) end |