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.



31253
31254
31255
31256
31257
31258
31259
31260
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31253

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

Instance Attribute Details

#item_numberObject (readonly)

Returns the value of attribute item_number.



31251
31252
31253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31251

def item_number
  @item_number
end

#priceObject (readonly)

Returns the value of attribute price.



31251
31252
31253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31251

def price
  @price
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



31251
31252
31253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31251

def price_book_key
  @price_book_key
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



31251
31252
31253
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31251

def schedule
  @schedule
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31266
31267
31268
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31266

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

#to_hashObject



31270
31271
31272
31273
31274
31275
31276
31277
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31270

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

#to_jsonObject



31262
31263
31264
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31262

def to_json
  JSON.dump(to_hash)
end