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.



41431
41432
41433
41434
41435
41436
41437
41438
41439
41440
41441
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41431

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.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def categories
  @categories
end

#currencyObject (readonly)

Returns the value of attribute currency.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def number
  @number
end

#priceObject (readonly)

Returns the value of attribute price.



41429
41430
41431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41429

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41447
41448
41449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41447

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

#to_hashObject



41451
41452
41453
41454
41455
41456
41457
41458
41459
41460
41461
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41451

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



41443
41444
41445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41443

def to_json
  JSON.dump(to_hash)
end