Class: Io::Flow::V0::Models::ShopifySession
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#cart ⇒ Object
readonly
Returns the value of attribute cart.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#experiments ⇒ Object
readonly
Returns the value of attribute experiments.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#shop ⇒ Object
readonly
Returns the value of attribute shop.
Attributes inherited from Session
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ShopifySession
constructor
A new instance of ShopifySession.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Session
Constructor Details
#initialize(incoming = {}) ⇒ ShopifySession
Returns a new instance of ShopifySession.
23217 23218 23219 23220 23221 23222 23223 23224 23225 23226 23227 23228 23229 23230 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23217 def initialize(incoming={}) super(:discriminator => Session::Types::SHOPIFY_SESSION) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :organization, :environment, :attributes, :shop, :cart], 'ShopifySession') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String) @environment = (x = opts.delete(:environment); x.is_a?(::Io::Flow::V0::Models::Environment) ? x : ::Io::Flow::V0::Models::Environment.apply(x)) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h } @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String)) @local = (x = opts.delete(:local); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalSession) ? x : ::Io::Flow::V0::Models::LocalSession.new(x))) @shop = HttpClient::Preconditions.assert_class('shop', opts.delete(:shop), String) @cart = (x = opts.delete(:cart); x.is_a?(::Io::Flow::V0::Models::CartReference) ? x : ::Io::Flow::V0::Models::CartReference.new(x)) @experiments = HttpClient::Preconditions.assert_class('experiments', (x = opts.delete(:experiments); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = (x = d[1]; x.is_a?(::Io::Flow::V0::Models::ExperimentStatus) ? x : ::Io::Flow::V0::Models::ExperimentStatus.new(x)); h } end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def attributes @attributes end |
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def cart @cart end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def environment @environment end |
#experiments ⇒ Object (readonly)
Returns the value of attribute experiments.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def experiments @experiments end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def id @id end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def ip @ip end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def local @local end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def organization @organization end |
#shop ⇒ Object (readonly)
Returns the value of attribute shop.
23215 23216 23217 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23215 def shop @shop end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
23236 23237 23238 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23236 def copy(incoming={}) ShopifySession.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
23240 23241 23242 23243 23244 23245 23246 23247 23248 23249 23250 23251 23252 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23240 def subtype_to_hash { :id => id, :organization => organization, :environment => environment.value, :attributes => attributes, :ip => ip, :local => local.nil? ? nil : local.to_hash, :shop => shop, :cart => cart.to_hash, :experiments => experiments.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash } } end |
#to_json ⇒ Object
23232 23233 23234 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23232 def to_json JSON.dump(to_hash) end |