class Io::Flow::Reference::V0::Models::Province

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

Attributes

country[R]
id[R]
iso_3166_2[R]
name[R]
province_type[R]
translations[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_reference_v0_client.rb, line 805
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::Reference::V0::Models::ProvinceType) ? x : ::Io::Flow::Reference::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::Reference::V0::Models::LocalizedTranslation) ? x : ::Io::Flow::Reference::V0::Models::LocalizedTranslation.new(x)) })
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_reference_v0_client.rb, line 820
def copy(incoming={})
  Province.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_reference_v0_client.rb, line 824
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() click to toggle source
# File lib/flow_reference_v0_client.rb, line 816
def to_json
  JSON.dump(to_hash)
end