Class: Io::Flow::V0::Models::CsvPriceBookItemExportRow

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

Overview

Represents the format used to export price book item documents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ CsvPriceBookItemExportRow

Returns a new instance of CsvPriceBookItemExportRow.



27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27317

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

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def ends_at
  @ends_at
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def item_attributes
  @item_attributes
end

#item_nameObject (readonly)

Returns the value of attribute item_name.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def item_name
  @item_name
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def item_number
  @item_number
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def price_book_key
  @price_book_key
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



27315
27316
27317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27315

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



27334
27335
27336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27334

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

#to_hashObject



27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27338

def to_hash
  {
    :price_book_key => price_book_key,
    :price_book_item_key => price_book_item_key,
    :item_number => item_number,
    :item_name => item_name,
    :amount => amount.to_f.to_s,
    :item_attributes => item_attributes.nil? ? nil : item_attributes,
    :starts_at => starts_at,
    :ends_at => ends_at
  }
end

#to_jsonObject



27330
27331
27332
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27330

def to_json
  JSON.dump(to_hash)
end