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.



44993
44994
44995
44996
44997
44998
44999
45000
45001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44993

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.



44991
44992
44993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44991

def amount
  @amount
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



44991
44992
44993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44991

def item_attributes
  @item_attributes
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



44991
44992
44993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44991

def item_number
  @item_number
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



44991
44992
44993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44991

def price_book_key
  @price_book_key
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



44991
44992
44993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 44991

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



45007
45008
45009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45007

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

#to_hashObject



45011
45012
45013
45014
45015
45016
45017
45018
45019
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45011

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



45003
45004
45005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45003

def to_json
  JSON.dump(to_hash)
end