Class: Io::Flow::V0::Models::HarmonizedItemForm

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 = {}) ⇒ HarmonizedItemForm

Returns a new instance of HarmonizedItemForm.



33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33384

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

#attributesObject (readonly)

Returns the value of attribute attributes.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def categories
  @categories
end

#currencyObject (readonly)

Returns the value of attribute currency.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def number
  @number
end

#priceObject (readonly)

Returns the value of attribute price.



33382
33383
33384
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33382

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33400
33401
33402
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33400

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

#to_hashObject



33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33404

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_jsonObject



33396
33397
33398
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33396

def to_json
  JSON.dump(to_hash)
end