Class: Io::Flow::V0::Models::HarmonizedItem

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

Overview

A harmonized item stores explicit information about this item for the purposes of harmonization / classification. The harmonization process begins by creating a harmonized item; this kicks off the internal processes. Once assigned, codes will be available via the hs6 and hs10 resources

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedItem

Returns a new instance of HarmonizedItem.



17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17238

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :number, :name], 'HarmonizedItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @categories = HttpClient::Preconditions.assert_class('categories', (x = opts.delete(:categories); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) }
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def categories
  @categories
end

#descriptionObject (readonly)

Returns the value of attribute description.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



17236
17237
17238
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17236

def number
  @number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17253
17254
17255
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17253

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

#to_hashObject



17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17257

def to_hash
  {
    :id => id,
    :number => number,
    :name => name,
    :categories => categories,
    :attributes => attributes,
    :description => description
  }
end

#to_jsonObject



17249
17250
17251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17249

def to_json
  JSON.dump(to_hash)
end