Class: Io::Flow::V0::Models::ShopifyCartItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyCartItem

Returns a new instance of ShopifyCartItem.



67298
67299
67300
67301
67302
67303
67304
67305
67306
67307
67308
67309
67310
67311
67312
67313
67314
67315
67316
67317
67318
67319
67320
67321
67322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67298

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :handle, :line_price, :price, :product_id, :product_title, :quantity, :title, :url, :variant_id, :local], 'ShopifyCartItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @handle = HttpClient::Preconditions.assert_class('handle', opts.delete(:handle), String)
  @line_price = HttpClient::Preconditions.assert_class('line_price', opts.delete(:line_price), Numeric)
  @price = HttpClient::Preconditions.assert_class('price', opts.delete(:price), Integer)
  @product_id = HttpClient::Preconditions.assert_class('product_id', opts.delete(:product_id), Integer)
  @product_title = HttpClient::Preconditions.assert_class('product_title', opts.delete(:product_title), String)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @title = HttpClient::Preconditions.assert_class('title', opts.delete(:title), String)
  @url = HttpClient::Preconditions.assert_class('url', opts.delete(:url), String)
  @variant_id = HttpClient::Preconditions.assert_class('variant_id', opts.delete(:variant_id), Integer)
  @local = (x = opts.delete(:local); x.is_a?(::Io::Flow::V0::Models::ShopifyLocalCartItemMetadata) ? x : ::Io::Flow::V0::Models::ShopifyLocalCartItemMetadata.new(x))
  @gift_card = HttpClient::Preconditions.assert_boolean('gift_card', (x = opts.delete(:gift_card); x.nil? ? false : x))
  @image = (x = opts.delete(:image); x.nil? ? nil : HttpClient::Preconditions.assert_class('image', x, String))
  @product_description = (x = opts.delete(:product_description); x.nil? ? nil : HttpClient::Preconditions.assert_class('product_description', x, String))
  @product_type = (x = opts.delete(:product_type); x.nil? ? nil : HttpClient::Preconditions.assert_class('product_type', x, String))
  @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 })
  @requires_shipping = HttpClient::Preconditions.assert_boolean('requires_shipping', (x = opts.delete(:requires_shipping); x.nil? ? true : x))
  @sku = (x = opts.delete(:sku); x.nil? ? nil : HttpClient::Preconditions.assert_class('sku', x, String))
  @variant_title = (x = opts.delete(:variant_title); x.nil? ? nil : HttpClient::Preconditions.assert_class('variant_title', x, String))
  @variant_options = (x = opts.delete(:variant_options); x.nil? ? nil : HttpClient::Preconditions.assert_class('variant_options', x, Array).map { |v| HttpClient::Preconditions.assert_class('variant_options', v, String) })
  @vendor = (x = opts.delete(:vendor); x.nil? ? nil : HttpClient::Preconditions.assert_class('vendor', x, String))
end

Instance Attribute Details

#gift_cardObject (readonly)

Returns the value of attribute gift_card.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def gift_card
  @gift_card
end

#handleObject (readonly)

Returns the value of attribute handle.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def handle
  @handle
end

#idObject (readonly)

Returns the value of attribute id.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def image
  @image
end

#line_priceObject (readonly)

Returns the value of attribute line_price.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def line_price
  @line_price
end

#localObject (readonly)

Returns the value of attribute local.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def local
  @local
end

#priceObject (readonly)

Returns the value of attribute price.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def price
  @price
end

#product_descriptionObject (readonly)

Returns the value of attribute product_description.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def product_description
  @product_description
end

#product_idObject (readonly)

Returns the value of attribute product_id.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def product_id
  @product_id
end

#product_titleObject (readonly)

Returns the value of attribute product_title.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def product_title
  @product_title
end

#product_typeObject (readonly)

Returns the value of attribute product_type.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def product_type
  @product_type
end

#propertiesObject (readonly)

Returns the value of attribute properties.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def properties
  @properties
end

#quantityObject (readonly)

Returns the value of attribute quantity.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def quantity
  @quantity
end

#requires_shippingObject (readonly)

Returns the value of attribute requires_shipping.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def requires_shipping
  @requires_shipping
end

#skuObject (readonly)

Returns the value of attribute sku.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def sku
  @sku
end

#titleObject (readonly)

Returns the value of attribute title.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def url
  @url
end

#variant_idObject (readonly)

Returns the value of attribute variant_id.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def variant_id
  @variant_id
end

#variant_optionsObject (readonly)

Returns the value of attribute variant_options.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def variant_options
  @variant_options
end

#variant_titleObject (readonly)

Returns the value of attribute variant_title.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def variant_title
  @variant_title
end

#vendorObject (readonly)

Returns the value of attribute vendor.



67296
67297
67298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67296

def vendor
  @vendor
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



67328
67329
67330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67328

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

#to_hashObject



67332
67333
67334
67335
67336
67337
67338
67339
67340
67341
67342
67343
67344
67345
67346
67347
67348
67349
67350
67351
67352
67353
67354
67355
67356
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67332

def to_hash
  {
    :id => id,
    :handle => handle,
    :line_price => line_price,
    :price => price,
    :product_id => product_id,
    :product_title => product_title,
    :quantity => quantity,
    :title => title,
    :url => url,
    :variant_id => variant_id,
    :local => local.to_hash,
    :gift_card => gift_card,
    :image => image,
    :product_description => product_description,
    :product_type => product_type,
    :properties => properties.nil? ? nil : properties,
    :requires_shipping => requires_shipping,
    :sku => sku,
    :variant_title => variant_title,
    :variant_options => variant_options.nil? ? nil : variant_options,
    :vendor => vendor
  }
end

#to_jsonObject



67324
67325
67326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67324

def to_json
  JSON.dump(to_hash)
end