Class: Io::Flow::V0::Models::PriceBookItem
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::PriceBookItem
- 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
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item_attributes ⇒ Object
readonly
Returns the value of attribute item_attributes.
-
#item_number ⇒ Object
readonly
Returns the value of attribute item_number.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#price_book ⇒ Object
readonly
Returns the value of attribute price_book.
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ PriceBookItem
constructor
A new instance of PriceBookItem.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ PriceBookItem
Returns a new instance of PriceBookItem.
43423 43424 43425 43426 43427 43428 43429 43430 43431 43432 43433 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43423 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
#id ⇒ Object (readonly)
Returns the value of attribute id.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def id @id end |
#item_attributes ⇒ Object (readonly)
Returns the value of attribute item_attributes.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def item_attributes @item_attributes end |
#item_number ⇒ Object (readonly)
Returns the value of attribute item_number.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def item_number @item_number end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def key @key end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def price @price end |
#price_book ⇒ Object (readonly)
Returns the value of attribute price_book.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def price_book @price_book end |
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
43421 43422 43423 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43421 def schedule @schedule end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
43439 43440 43441 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43439 def copy(incoming={}) PriceBookItem.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
43443 43444 43445 43446 43447 43448 43449 43450 43451 43452 43453 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43443 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_json ⇒ Object
43435 43436 43437 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43435 def to_json JSON.dump(to_hash) end |