Class: Io::Flow::V0::Models::ShopifyCartAddSingleForm

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

Instance Attribute Summary collapse

Attributes inherited from ShopifyCartAddForm

#discriminator

Instance Method Summary collapse

Methods inherited from ShopifyCartAddForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyCartAddSingleForm

Returns a new instance of ShopifyCartAddSingleForm.



50519
50520
50521
50522
50523
50524
50525
50526
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50519

def initialize(incoming={})
  super(:discriminator => ShopifyCartAddForm::Types::SHOPIFY_CART_ADD_SINGLE_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :quantity], 'ShopifyCartAddSingleForm')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), Integer)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @properties = (x = opts.delete(:properties); x.nil? ? nil : HttpClient::Preconditions.assert_class('properties', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('properties', d[1], String); h })
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



50517
50518
50519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50517

def id
  @id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



50517
50518
50519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50517

def properties
  @properties
end

#quantityObject (readonly)

Returns the value of attribute quantity.



50517
50518
50519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50517

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



50532
50533
50534
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50532

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

#subtype_to_hashObject



50536
50537
50538
50539
50540
50541
50542
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50536

def subtype_to_hash
  {
    :id => id,
    :quantity => quantity,
    :properties => properties.nil? ? nil : properties
  }
end

#to_jsonObject



50528
50529
50530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50528

def to_json
  JSON.dump(to_hash)
end