Class: Io::Flow::V0::Models::ItemSalesMarginUpserted

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

Instance Attribute Summary collapse

Attributes inherited from Event

#discriminator

Instance Method Summary collapse

Methods inherited from Event

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ItemSalesMarginUpserted

Returns a new instance of ItemSalesMarginUpserted.



36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36700

def initialize(incoming={})
  super(:discriminator => Event::Types::ITEM_SALES_MARGIN_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :item_sales_margin_id, :organization_id, :experience_key, :name, :q, :fixed, :percent, :position], 'ItemSalesMarginUpserted')
  @event_id = HttpClient::Preconditions.assert_class('event_id', opts.delete(:event_id), String)
  @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
  @item_sales_margin_id = HttpClient::Preconditions.assert_class('item_sales_margin_id', opts.delete(:item_sales_margin_id), String)
  @organization_id = HttpClient::Preconditions.assert_class('organization_id', opts.delete(:organization_id), String)
  @experience_key = HttpClient::Preconditions.assert_class('experience_key', opts.delete(:experience_key), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String)
  @fixed = HttpClient::Preconditions.assert_class('fixed', HttpClient::Helper.to_big_decimal(opts.delete(:fixed)), BigDecimal)
  @percent = HttpClient::Preconditions.assert_class('percent', HttpClient::Helper.to_big_decimal(opts.delete(:percent)), BigDecimal)
  @position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer)
end

Instance Attribute Details

#event_idObject (readonly)

Returns the value of attribute event_id.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def event_id
  @event_id
end

#experience_keyObject (readonly)

Returns the value of attribute experience_key.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def experience_key
  @experience_key
end

#fixedObject (readonly)

Returns the value of attribute fixed.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def fixed
  @fixed
end

#item_sales_margin_idObject (readonly)

Returns the value of attribute item_sales_margin_id.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def item_sales_margin_id
  @item_sales_margin_id
end

#nameObject (readonly)

Returns the value of attribute name.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def name
  @name
end

#organization_idObject (readonly)

Returns the value of attribute organization_id.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def organization_id
  @organization_id
end

#percentObject (readonly)

Returns the value of attribute percent.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def q
  @q
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



36698
36699
36700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36698

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36720
36721
36722
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36720

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

#subtype_to_hashObject



36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36724

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :item_sales_margin_id => item_sales_margin_id,
    :organization_id => organization_id,
    :experience_key => experience_key,
    :name => name,
    :q => q,
    :fixed => fixed.to_f.to_s,
    :percent => percent.to_f.to_s,
    :position => position
  }
end

#to_jsonObject



36716
36717
36718
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36716

def to_json
  JSON.dump(to_hash)
end