Class: Io::Flow::V0::Models::HarmonizedItemForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::HarmonizedItemForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
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.
-
#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 = {}) ⇒ HarmonizedItemForm
constructor
A new instance of HarmonizedItemForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ HarmonizedItemForm
Returns a new instance of HarmonizedItemForm.
34707 34708 34709 34710 34711 34712 34713 34714 34715 34716 34717 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34707 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name, :number, :currency, :price], 'HarmonizedItemForm') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), 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 }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def attributes @attributes end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def categories @categories end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def currency @currency end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def number @number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
34705 34706 34707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34705 def price @price end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
34723 34724 34725 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34723 def copy(incoming={}) HarmonizedItemForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
34727 34728 34729 34730 34731 34732 34733 34734 34735 34736 34737 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34727 def to_hash { :name => name, :number => number, :currency => currency, :price => price, :categories => categories.nil? ? nil : categories, :description => description, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
34719 34720 34721 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34719 def to_json JSON.dump(to_hash) end |