class Io::Flow::V0::Models::ShopifyCartItem

Attributes

gift_card[R]
handle[R]
id[R]
image[R]
line_price[R]
local[R]
price[R]
product_description[R]
product_id[R]
product_title[R]
product_type[R]
properties[R]
quantity[R]
requires_shipping[R]
sku[R]
title[R]
url[R]
variant_id[R]
variant_options[R]
variant_title[R]
vendor[R]

Public Class Methods

new(incoming={}) click to toggle source
# 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

Public Instance Methods

copy(incoming={}) click to toggle source
# 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_hash() click to toggle source
# 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_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 67324
def to_json
  JSON.dump(to_hash)
end