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

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizationDocument

Returns a new instance of HarmonizationDocument.



12776
12777
12778
12779
12780
12781
12782
12783
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12776

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

#categories ⇒ Object (readonly)

Returns the value of attribute categories.



12774
12775
12776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12774

def categories
  @categories
end

#code ⇒ Object (readonly)

Returns the value of attribute code.



12774
12775
12776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12774

def code
  @code
end

#origin ⇒ Object (readonly)

Returns the value of attribute origin.



12774
12775
12776
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12774

def origin
  @origin
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12789
12790
12791
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12789

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

#subtype_to_hash ⇒ Object



12793
12794
12795
12796
12797
12798
12799
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12793

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

#to_json ⇒ Object



12785
12786
12787
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12785

def to_json
  JSON.dump(to_hash)
end