Class: Io::Flow::V0::Models::PriceSourcePriceBook

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

Instance Attribute Summary collapse

Attributes inherited from PriceSource

#discriminator

Instance Method Summary collapse

Methods inherited from PriceSource

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PriceSourcePriceBook

Returns a new instance of PriceSourcePriceBook.



44843
44844
44845
44846
44847
44848
44849
44850
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44843

def initialize(incoming={})
  super(:discriminator => PriceSource::Types::PRICE_SOURCE_PRICE_BOOK)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price, :includes, :price_book_reference], 'PriceSourcePriceBook')
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))
  @includes = (x = opts.delete(:includes); x.is_a?(::Io::Flow::V0::Models::IncludedLevies) ? x : ::Io::Flow::V0::Models::IncludedLevies.new(x))
  @price_book_reference = (x = opts.delete(:price_book_reference); x.is_a?(::Io::Flow::V0::Models::PriceSourcePriceBookReference) ? x : ::Io::Flow::V0::Models::PriceSourcePriceBookReference.new(x))
end

Instance Attribute Details

#includesObject (readonly)

Returns the value of attribute includes.



44841
44842
44843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44841

def includes
  @includes
end

#priceObject (readonly)

Returns the value of attribute price.



44841
44842
44843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44841

def price
  @price
end

#price_book_referenceObject (readonly)

Returns the value of attribute price_book_reference.



44841
44842
44843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44841

def price_book_reference
  @price_book_reference
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



44856
44857
44858
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44856

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

#subtype_to_hashObject



44860
44861
44862
44863
44864
44865
44866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44860

def subtype_to_hash
  {
    :price => price.to_hash,
    :includes => includes.to_hash,
    :price_book_reference => price_book_reference.to_hash
  }
end

#to_jsonObject



44852
44853
44854
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44852

def to_json
  JSON.dump(to_hash)
end