Class: Io::Flow::V0::Models::AddressConfiguration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AddressConfiguration

Returns a new instance of AddressConfiguration.



29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29537

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:country, :field_validation], 'AddressConfiguration')
  @country = HttpClient::Preconditions.assert_class('country', opts.delete(:country), String)
  @field_validation = (x = opts.delete(:field_validation); x.is_a?(::Io::Flow::V0::Models::AddressFieldValidation) ? x : ::Io::Flow::V0::Models::AddressFieldValidation.new(x))
  @provinces = HttpClient::Preconditions.assert_class('provinces', (x = opts.delete(:provinces); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AddressConfigurationProvince) ? x : ::Io::Flow::V0::Models::AddressConfigurationProvince.new(x)) }
  @formats = HttpClient::Preconditions.assert_class('formats', (x = opts.delete(:formats); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AddressConfigurationFormat) ? x : ::Io::Flow::V0::Models::AddressConfigurationFormat.new(x)) }
  @province_type = (x = opts.delete(:province_type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ProvinceType) ? x : ::Io::Flow::V0::Models::ProvinceType.apply(x)))
  @postal_type = (x = opts.delete(:postal_type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PostalType) ? x : ::Io::Flow::V0::Models::PostalType.apply(x)))
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def country
  @country
end

#field_validationObject (readonly)

Returns the value of attribute field_validation.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def field_validation
  @field_validation
end

#formatsObject (readonly)

Returns the value of attribute formats.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def formats
  @formats
end

#postal_typeObject (readonly)

Returns the value of attribute postal_type.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def postal_type
  @postal_type
end

#province_typeObject (readonly)

Returns the value of attribute province_type.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def province_type
  @province_type
end

#provincesObject (readonly)

Returns the value of attribute provinces.



29535
29536
29537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29535

def provinces
  @provinces
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



29552
29553
29554
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29552

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

#to_hashObject



29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29556

def to_hash
  {
    :country => country,
    :field_validation => field_validation.to_hash,
    :provinces => provinces.map { |o| o.to_hash },
    :formats => formats.map { |o| o.to_hash },
    :province_type => province_type.nil? ? nil : province_type.value,
    :postal_type => postal_type.nil? ? nil : postal_type.value
  }
end

#to_jsonObject



29548
29549
29550
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29548

def to_json
  JSON.dump(to_hash)
end