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.



26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26775

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))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def id
  @id
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def item_number
  @item_number
end

#keyObject (readonly)

Returns the value of attribute key.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def key
  @key
end

#priceObject (readonly)

Returns the value of attribute price.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def price
  @price
end

#price_bookObject (readonly)

Returns the value of attribute price_book.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def price_book
  @price_book
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26790
26791
26792
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26790

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

#to_hashObject



26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26794

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
  }
end

#to_jsonObject



26786
26787
26788
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26786

def to_json
  JSON.dump(to_hash)
end