Class: Io::Flow::V0::Models::SessionGeo

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

Overview

The geolocated information for this session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ SessionGeo

Returns a new instance of SessionGeo.



37107
37108
37109
37110
37111
37112
37113
37114
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37107

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:country, :currency, :language, :locale], 'SessionGeo')
  @country = (x = opts.delete(:country); x.is_a?(::Io::Flow::V0::Models::Country) ? x : ::Io::Flow::V0::Models::Country.new(x))
  @currency = (x = opts.delete(:currency); x.is_a?(::Io::Flow::V0::Models::Currency) ? x : ::Io::Flow::V0::Models::Currency.new(x))
  @language = (x = opts.delete(:language); x.is_a?(::Io::Flow::V0::Models::Language) ? x : ::Io::Flow::V0::Models::Language.new(x))
  @locale = (x = opts.delete(:locale); x.is_a?(::Io::Flow::V0::Models::Locale) ? x : ::Io::Flow::V0::Models::Locale.new(x))
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



37105
37106
37107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37105

def country
  @country
end

#currencyObject (readonly)

Returns the value of attribute currency.



37105
37106
37107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37105

def currency
  @currency
end

#languageObject (readonly)

Returns the value of attribute language.



37105
37106
37107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37105

def language
  @language
end

#localeObject (readonly)

Returns the value of attribute locale.



37105
37106
37107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37105

def locale
  @locale
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37120
37121
37122
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37120

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

#to_hashObject



37124
37125
37126
37127
37128
37129
37130
37131
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37124

def to_hash
  {
    :country => country.to_hash,
    :currency => currency.to_hash,
    :language => language.to_hash,
    :locale => locale.to_hash
  }
end

#to_jsonObject



37116
37117
37118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37116

def to_json
  JSON.dump(to_hash)
end