Class: Io::Flow::V0::Models::ShopifySession

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

Instance Attribute Summary collapse

Attributes inherited from Session

#discriminator

Instance Method Summary collapse

Methods inherited from Session

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ShopifySession

Returns a new instance of ShopifySession.



20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20528

def initialize(incoming={})
  super(:discriminator => Session::Types::SHOPIFY_SESSION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :organization, :attributes, :shop, :cart], 'ShopifySession')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @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))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def attributes
  @attributes
end

#cartObject (readonly)

Returns the value of attribute cart.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def cart
  @cart
end

#idObject (readonly)

Returns the value of attribute id.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def id
  @id
end

#localObject (readonly)

Returns the value of attribute local.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def local
  @local
end

#organizationObject (readonly)

Returns the value of attribute organization.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def organization
  @organization
end

#shopObject (readonly)

Returns the value of attribute shop.



20526
20527
20528
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20526

def shop
  @shop
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20544
20545
20546
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20544

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

#subtype_to_hashObject



20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20548

def subtype_to_hash
  {
    :id => id,
    :organization => organization,
    :attributes => attributes,
    :local => local.nil? ? nil : local.to_hash,
    :shop => shop,
    :cart => cart.to_hash
  }
end

#to_jsonObject



20540
20541
20542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20540

def to_json
  JSON.dump(to_hash)
end