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.



34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34276

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.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def amount
  @amount
end

#catalogObject (readonly)

Returns the value of attribute catalog.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def catalog
  @catalog
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def ends_at
  @ends_at
end

#priceObject (readonly)

Returns the value of attribute price.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def price
  @price
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def price_book_key
  @price_book_key
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



34274
34275
34276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34274

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34292
34293
34294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34292

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

#to_hashObject



34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34296

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



34288
34289
34290
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34288

def to_json
  JSON.dump(to_hash)
end