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



26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26165

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))
  @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.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def amount
  @amount
end

#catalogObject (readonly)

Returns the value of attribute catalog.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def catalog
  @catalog
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def ends_at
  @ends_at
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def price_book_key
  @price_book_key
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



26163
26164
26165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26163

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26180
26181
26182
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26180

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

#to_hashObject



26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26184

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

#to_jsonObject



26176
26177
26178
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26176

def to_json
  JSON.dump(to_hash)
end