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.



22625
22626
22627
22628
22629
22630
22631
22632
22633
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22625

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))
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



22623
22624
22625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22623

def country
  @country
end

#idObject (readonly)

Returns the value of attribute id.



22623
22624
22625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22623

def id
  @id
end

#iso_3166_2Object (readonly)

Returns the value of attribute iso_3166_2.



22623
22624
22625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22623

def iso_3166_2
  @iso_3166_2
end

#nameObject (readonly)

Returns the value of attribute name.



22623
22624
22625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22623

def name
  @name
end

#province_typeObject (readonly)

Returns the value of attribute province_type.



22623
22624
22625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22623

def province_type
  @province_type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22639
22640
22641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22639

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

#to_hashObject



22643
22644
22645
22646
22647
22648
22649
22650
22651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22643

def to_hash
  {
    :id => id,
    :iso_3166_2 => iso_3166_2,
    :name => name,
    :country => country,
    :province_type => province_type.value
  }
end

#to_jsonObject



22635
22636
22637
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22635

def to_json
  JSON.dump(to_hash)
end