Class: Io::Flow::V0::Models::Item
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Item
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The Flow item defines a specific item that can be purchased by a consumer. For many clients, this will map to a Sku.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Item
constructor
A new instance of Item.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Item
Returns a new instance of Item.
46913 46914 46915 46916 46917 46918 46919 46920 46921 46922 46923 46924 46925 46926 46927 46928 46929 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46913 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :number, :locale, :name, :price, :dimensions], 'Item') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String) @locale = HttpClient::Preconditions.assert_class('locale', opts.delete(:locale), String) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)) @categories = HttpClient::Preconditions.assert_class('categories', (x = opts.delete(:categories); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) } @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String)) @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h } @dimensions = (x = opts.delete(:dimensions); x.is_a?(::Io::Flow::V0::Models::Dimensions) ? x : ::Io::Flow::V0::Models::Dimensions.new(x)) @images = HttpClient::Preconditions.assert_class('images', (x = opts.delete(:images); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Image) ? x : ::Io::Flow::V0::Models::Image.new(x)) } @local = (x = opts.delete(:local); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Local) ? x : ::Io::Flow::V0::Models::Local.new(x))) @created_at = (x = opts.delete(:created_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime)) @updated_at = (x = opts.delete(:updated_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime)) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def attributes @attributes end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def categories @categories end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def description @description end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def dimensions @dimensions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def id @id end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def images @images end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def local @local end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def locale @locale end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def number @number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def price @price end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
46911 46912 46913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46911 def updated_at @updated_at end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
46935 46936 46937 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46935 def copy(incoming={}) Item.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
46939 46940 46941 46942 46943 46944 46945 46946 46947 46948 46949 46950 46951 46952 46953 46954 46955 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46939 def to_hash { :id => id, :number => number, :locale => locale, :name => name, :price => price.to_hash, :categories => categories, :description => description, :attributes => attributes, :dimensions => dimensions.to_hash, :images => images.map { |o| o.to_hash }, :local => local.nil? ? nil : local.to_hash, :created_at => created_at, :updated_at => updated_at } end |
#to_json ⇒ Object
46931 46932 46933 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46931 def to_json JSON.dump(to_hash) end |