Class: Io::Flow::V0::Models::HarmonizedItemPutForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedItemPutForm

Returns a new instance of HarmonizedItemPutForm.



34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34745

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :currency, :price], 'HarmonizedItemPutForm')
  @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 })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def categories
  @categories
end

#currencyObject (readonly)

Returns the value of attribute currency.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



34743
34744
34745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34743

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34760
34761
34762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34760

def copy(incoming={})
  HarmonizedItemPutForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34764

def to_hash
  {
    :name => name,
    :currency => currency,
    :price => price,
    :categories => categories.nil? ? nil : categories,
    :description => description,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



34756
34757
34758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34756

def to_json
  JSON.dump(to_hash)
end