Class: Io::Flow::V0::Models::CatalogPriceBookItemDocument

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

Overview

Represents the returned information for searching particular price book items

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CatalogPriceBookItemDocument

Returns a new instance of CatalogPriceBookItemDocument.



31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31685

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price_book_key, :price_book_item_key, :catalog, :amount, :starts_at], 'CatalogPriceBookItemDocument')
  @price_book_key = HttpClient::Preconditions.assert_class('price_book_key', opts.delete(:price_book_key), String)
  @price_book_item_key = HttpClient::Preconditions.assert_class('price_book_item_key', opts.delete(:price_book_item_key), String)
  @catalog = (x = opts.delete(:catalog); x.is_a?(::Io::Flow::V0::Models::CatalogItemSummary) ? x : ::Io::Flow::V0::Models::CatalogItemSummary.new(x))
  @price = (x = opts.delete(:price); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @starts_at = HttpClient::Preconditions.assert_class('starts_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:starts_at)), DateTime)
  @ends_at = (x = opts.delete(:ends_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('ends_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def amount
  @amount
end

#catalogObject (readonly)

Returns the value of attribute catalog.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def catalog
  @catalog
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def ends_at
  @ends_at
end

#priceObject (readonly)

Returns the value of attribute price.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def price
  @price
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def price_book_key
  @price_book_key
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



31683
31684
31685
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31683

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31701
31702
31703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31701

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

#to_hashObject



31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31705

def to_hash
  {
    :price_book_key => price_book_key,
    :price_book_item_key => price_book_item_key,
    :catalog => catalog.to_hash,
    :price => price.nil? ? nil : price.to_hash,
    :amount => amount.to_f.to_s,
    :starts_at => starts_at,
    :ends_at => ends_at
  }
end

#to_jsonObject



31697
31698
31699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31697

def to_json
  JSON.dump(to_hash)
end