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.



28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28536

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price_book_key, :price_book_item_key, :item_number, :sku, :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)
  @sku = HttpClient::Preconditions.assert_class('sku', opts.delete(:sku), 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.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def ends_at
  @ends_at
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def item_attributes
  @item_attributes
end

#item_nameObject (readonly)

Returns the value of attribute item_name.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def item_name
  @item_name
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def item_number
  @item_number
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def price_book_key
  @price_book_key
end

#skuObject (readonly)

Returns the value of attribute sku.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def sku
  @sku
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



28534
28535
28536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28534

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28554
28555
28556
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28554

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

#to_hashObject



28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28558

def to_hash
  {
    :price_book_key => price_book_key,
    :price_book_item_key => price_book_item_key,
    :item_number => item_number,
    :sku => sku,
    :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



28550
28551
28552
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28550

def to_json
  JSON.dump(to_hash)
end