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.



27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27985

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.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def ends_at
  @ends_at
end

#item_attributesObject (readonly)

Returns the value of attribute item_attributes.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def item_attributes
  @item_attributes
end

#item_nameObject (readonly)

Returns the value of attribute item_name.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def item_name
  @item_name
end

#item_numberObject (readonly)

Returns the value of attribute item_number.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def item_number
  @item_number
end

#price_book_item_keyObject (readonly)

Returns the value of attribute price_book_item_key.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def price_book_item_key
  @price_book_item_key
end

#price_book_keyObject (readonly)

Returns the value of attribute price_book_key.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def price_book_key
  @price_book_key
end

#skuObject (readonly)

Returns the value of attribute sku.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def sku
  @sku
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



27983
27984
27985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27983

def starts_at
  @starts_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28003
28004
28005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28003

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

#to_hashObject



28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28007

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



27999
28000
28001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 27999

def to_json
  JSON.dump(to_hash)
end