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.
24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24554 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.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def attributes @attributes end |
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def cart @cart end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def environment @environment end |
#experiments ⇒ Object (readonly)
Returns the value of attribute experiments.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def experiments @experiments end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def id @id end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def ip @ip end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def local @local end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def organization @organization end |
#shop ⇒ Object (readonly)
Returns the value of attribute shop.
24552 24553 24554 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24552 def shop @shop end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
24573 24574 24575 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24573 def copy(incoming={}) ShopifySession.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
24577 24578 24579 24580 24581 24582 24583 24584 24585 24586 24587 24588 24589 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24577 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
24569 24570 24571 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24569 def to_json JSON.dump(to_hash) end |