Class: Io::Flow::V0::Models::HarmonizationDocument

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

Instance Attribute Summary collapse

Attributes inherited from Document

#discriminator

Instance Method Summary collapse

Methods inherited from Document

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizationDocument

Returns a new instance of HarmonizationDocument.



29697
29698
29699
29700
29701
29702
29703
29704
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29697

def initialize(incoming={})
  super(:discriminator => Document::Types::HARMONIZATION_DOCUMENT)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:code, :categories], 'HarmonizationDocument')
  @code = HttpClient::Preconditions.assert_class('code', opts.delete(:code), String)
  @categories = HttpClient::Preconditions.assert_class('categories', opts.delete(:categories), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::CategorySummary) ? x : ::Io::Flow::V0::Models::CategorySummary.new(x)) }
  @origin = (x = opts.delete(:origin); x.nil? ? nil : HttpClient::Preconditions.assert_class('origin', x, String))
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



29695
29696
29697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29695

def categories
  @categories
end

#codeObject (readonly)

Returns the value of attribute code.



29695
29696
29697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29695

def code
  @code
end

#originObject (readonly)

Returns the value of attribute origin.



29695
29696
29697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29695

def origin
  @origin
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



29710
29711
29712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29710

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

#subtype_to_hashObject



29714
29715
29716
29717
29718
29719
29720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29714

def subtype_to_hash
  {
    :code => code,
    :categories => categories.map { |o| o.to_hash },
    :origin => origin
  }
end

#to_jsonObject



29706
29707
29708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29706

def to_json
  JSON.dump(to_hash)
end