Class: Io::Flow::V0::Models::ItemForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ItemForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The item form defines the data required to create an item.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#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.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ItemForm
constructor
A new instance of ItemForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ItemForm
Returns a new instance of ItemForm.
18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18994 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:number, :locale, :name, :currency, :price], 'ItemForm') @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) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @price = HttpClient::Preconditions.assert_class('price', opts.delete(:price), Numeric) @categories = (x = opts.delete(:categories); x.nil? ? nil : HttpClient::Preconditions.assert_class('categories', 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 = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }) @dimensions = (x = opts.delete(:dimensions); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Dimensions) ? x : ::Io::Flow::V0::Models::Dimensions.new(x))) @images = (x = opts.delete(:images); x.nil? ? nil : HttpClient::Preconditions.assert_class('images', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ImageForm) ? x : ::Io::Flow::V0::Models::ImageForm.new(x)) }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def attributes @attributes end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def categories @categories end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def currency @currency end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def description @description end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def dimensions @dimensions end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def images @images end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def locale @locale end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def number @number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def price @price end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
19013 19014 19015 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19013 def copy(incoming={}) ItemForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19017 def to_hash { :number => number, :locale => locale, :name => name, :currency => currency, :price => price, :categories => categories.nil? ? nil : categories, :description => description, :attributes => attributes.nil? ? nil : attributes, :dimensions => dimensions.nil? ? nil : dimensions.to_hash, :images => images.nil? ? nil : images.map { |o| o.to_hash } } end |
#to_json ⇒ Object
19009 19010 19011 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19009 def to_json JSON.dump(to_hash) end |