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.



13190
13191
13192
13193
13194
13195
13196
13197
13198
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13190

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :number], 'HarmonizedItemForm')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @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.



13188
13189
13190
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13188

def attributes
  @attributes
end

#categories ⇒ Object (readonly)

Returns the value of attribute categories.



13188
13189
13190
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13188

def categories
  @categories
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



13188
13189
13190
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13188

def description
  @description
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



13188
13189
13190
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13188

def name
  @name
end

#number ⇒ Object (readonly)

Returns the value of attribute number.



13188
13189
13190
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13188

def number
  @number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13204
13205
13206
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13204

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

#to_hash ⇒ Object



13208
13209
13210
13211
13212
13213
13214
13215
13216
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13208

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

#to_json ⇒ Object



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def to_json
  JSON.dump(to_hash)
end