Class: Io::Flow::V0::Models::PriceBookItem

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

Overview

Represents the price of a single item within a price book.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PriceBookItem

Returns a new instance of PriceBookItem.



35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35205

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :price_book, :price, :item_number, :schedule], 'PriceBookItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @price_book = (x = opts.delete(:price_book); x.is_a?(::Io::Flow::V0::Models::PriceBookReference) ? x : ::Io::Flow::V0::Models::PriceBookReference.new(x))
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @schedule = (x = opts.delete(:schedule); x.is_a?(::Io::Flow::V0::Models::PriceBookItemSchedule) ? x : ::Io::Flow::V0::Models::PriceBookItemSchedule.new(x))
  @item_attributes = (x = opts.delete(:item_attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('item_attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('item_attributes', d[1], String); h })
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def id
  @id
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def item_attributes
  @item_attributes
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def item_number
  @item_number
end

#keyObject (readonly)

Returns the value of attribute key.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def key
  @key
end

#priceObject (readonly)

Returns the value of attribute price.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def price
  @price
end

#price_bookObject (readonly)

Returns the value of attribute price_book.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def price_book
  @price_book
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



35203
35204
35205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35203

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35221
35222
35223
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35221

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

#to_hashObject



35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35225

def to_hash
  {
    :id => id,
    :key => key,
    :price_book => price_book.to_hash,
    :price => price.to_hash,
    :item_number => item_number,
    :schedule => schedule.to_hash,
    :item_attributes => item_attributes.nil? ? nil : item_attributes
  }
end

#to_jsonObject



35217
35218
35219
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35217

def to_json
  JSON.dump(to_hash)
end