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.
-
#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
21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21831 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 } @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.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def attributes @attributes end |
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def cart @cart end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def environment @environment end |
#experiments ⇒ Object (readonly)
Returns the value of attribute experiments.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def experiments @experiments end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def id @id end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def local @local end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def organization @organization end |
#shop ⇒ Object (readonly)
Returns the value of attribute shop.
21829 21830 21831 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21829 def shop @shop end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
21849 21850 21851 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21849 def copy(incoming={}) ShopifySession.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21853 def subtype_to_hash { :id => id, :organization => organization, :environment => environment.value, :attributes => attributes, :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
21845 21846 21847 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21845 def to_json JSON.dump(to_hash) end |