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.



34773
34774
34775
34776
34777
34778
34779
34780
34781
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34773

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price_book_key, :price, :item_number, :schedule], 'PriceBookItemForm')
  @price_book_key = HttpClient::Preconditions.assert_class('price_book_key', opts.delete(:price_book_key), String)
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.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

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34771

def item_attributes
  @item_attributes
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34771

def item_number
  @item_number
end

#priceObject (readonly)

Returns the value of attribute price.



34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34771

def price
  @price
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34771

def price_book_key
  @price_book_key
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



34771
34772
34773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34771

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34787
34788
34789
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34787

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

#to_hashObject



34791
34792
34793
34794
34795
34796
34797
34798
34799
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34791

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

#to_jsonObject



34783
34784
34785
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34783

def to_json
  JSON.dump(to_hash)
end