Class: Io::Flow::V0::Models::PriceBookItemForm

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

Overview

Represents the form to create an item in a pricebook.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PriceBookItemForm

Returns a new instance of PriceBookItemForm.



41733
41734
41735
41736
41737
41738
41739
41740
41741
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41733

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price_book_key, :item_number, :amount], 'PriceBookItemForm')
  @price_book_key = HttpClient::Preconditions.assert_class('price_book_key', opts.delete(:price_book_key), String)
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @schedule = (x = opts.delete(:schedule); x.nil? ? nil : (x = x; 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

#amountObject (readonly)

Returns the value of attribute amount.



41731
41732
41733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41731

def amount
  @amount
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



41731
41732
41733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41731

def item_attributes
  @item_attributes
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



41731
41732
41733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41731

def item_number
  @item_number
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



41731
41732
41733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41731

def price_book_key
  @price_book_key
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



41731
41732
41733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41731

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41747
41748
41749
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41747

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

#to_hashObject



41751
41752
41753
41754
41755
41756
41757
41758
41759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41751

def to_hash
  {
    :price_book_key => price_book_key,
    :item_number => item_number,
    :amount => amount.to_f.to_s,
    :schedule => schedule.nil? ? nil : schedule.to_hash,
    :item_attributes => item_attributes.nil? ? nil : item_attributes
  }
end

#to_jsonObject



41743
41744
41745
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41743

def to_json
  JSON.dump(to_hash)
end