Class: Io::Flow::V0::Models::ShopifyCart
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ShopifyCart
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Representation of a Shopify cart exactly as defined by shopify.com
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item_count ⇒ Object
readonly
Returns the value of attribute item_count.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#requires_shipping ⇒ Object
readonly
Returns the value of attribute requires_shipping.
-
#total_price ⇒ Object
readonly
Returns the value of attribute total_price.
-
#total_weight ⇒ Object
readonly
Returns the value of attribute total_weight.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ShopifyCart
constructor
A new instance of ShopifyCart.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ShopifyCart
Returns a new instance of ShopifyCart.
67081 67082 67083 67084 67085 67086 67087 67088 67089 67090 67091 67092 67093 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67081 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :items, :item_count, :total_price, :local], 'ShopifyCart') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShopifyCartItem) ? x : ::Io::Flow::V0::Models::ShopifyCartItem.new(x)) } @item_count = HttpClient::Preconditions.assert_class('item_count', opts.delete(:item_count), Integer) @total_price = HttpClient::Preconditions.assert_class('total_price', opts.delete(:total_price), Integer) @local = (x = opts.delete(:local); x.is_a?(::Io::Flow::V0::Models::ShopifyLocalCartMetadata) ? x : ::Io::Flow::V0::Models::ShopifyLocalCartMetadata.new(x)) @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', HttpClient::Helper.to_object(x), Hash)) @note = (x = opts.delete(:note); x.nil? ? nil : HttpClient::Preconditions.assert_class('note', x, String)) @requires_shipping = HttpClient::Preconditions.assert_boolean('requires_shipping', (x = opts.delete(:requires_shipping); x.nil? ? true : x)) @total_weight = (x = opts.delete(:total_weight); x.nil? ? nil : HttpClient::Preconditions.assert_class('total_weight', x, Integer)) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def id @id end |
#item_count ⇒ Object (readonly)
Returns the value of attribute item_count.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def item_count @item_count end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def items @items end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def local @local end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def note @note end |
#requires_shipping ⇒ Object (readonly)
Returns the value of attribute requires_shipping.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def requires_shipping @requires_shipping end |
#total_price ⇒ Object (readonly)
Returns the value of attribute total_price.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def total_price @total_price end |
#total_weight ⇒ Object (readonly)
Returns the value of attribute total_weight.
67079 67080 67081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67079 def total_weight @total_weight end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
67099 67100 67101 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67099 def copy(incoming={}) ShopifyCart.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
67103 67104 67105 67106 67107 67108 67109 67110 67111 67112 67113 67114 67115 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67103 def to_hash { :id => id, :items => items.map { |o| o.to_hash }, :item_count => item_count, :total_price => total_price, :local => local.to_hash, :attributes => attributes, :note => note, :requires_shipping => requires_shipping, :total_weight => total_weight } end |
#to_json ⇒ Object
67095 67096 67097 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67095 def to_json JSON.dump(to_hash) end |