Class: Io::Flow::V0::Models::OrderUpserted

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 = {}) ⇒ OrderUpserted

Returns a new instance of OrderUpserted.



24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24816

def initialize(incoming={})
  super(:discriminator => Event::Types::ORDER_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :number, :environment, :experience_id, :expires_at, :customer, :selections, :items, :destination, :deliveries, :prices, :total], 'OrderUpserted')
  @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)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @environment = HttpClient::Preconditions.assert_class('environment', opts.delete(:environment), String)
  @experience_id = HttpClient::Preconditions.assert_class('experience_id', opts.delete(:experience_id), String)
  @expires_at = HttpClient::Preconditions.assert_class('expires_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expires_at)), DateTime)
  @customer = HttpClient::Preconditions.assert_class('customer', HttpClient::Helper.to_object(opts.delete(:customer)), Hash)
  @selections = HttpClient::Preconditions.assert_class('selections', opts.delete(:selections), Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) }
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| HttpClient::Preconditions.assert_class('items', HttpClient::Helper.to_object(v), Hash) }
  @destination = HttpClient::Preconditions.assert_class('destination', HttpClient::Helper.to_object(opts.delete(:destination)), Hash)
  @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| HttpClient::Preconditions.assert_class('deliveries', HttpClient::Helper.to_object(v), Hash) }
  @prices = HttpClient::Preconditions.assert_class('prices', opts.delete(:prices), Array).map { |v| HttpClient::Preconditions.assert_class('prices', HttpClient::Helper.to_object(v), Hash) }
  @payments = (x = opts.delete(:payments); x.nil? ? nil : HttpClient::Preconditions.assert_class('payments', x, Array).map { |v| HttpClient::Preconditions.assert_class('payments', HttpClient::Helper.to_object(v), Hash) })
  @discount = (x = opts.delete(:discount); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount', HttpClient::Helper.to_object(x), Hash))
  @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : HttpClient::Preconditions.assert_class('delivered_duty', x, String))
  @total = HttpClient::Preconditions.assert_class('total', HttpClient::Helper.to_object(opts.delete(:total)), Hash)
  @created_at = (x = opts.delete(:created_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @updated_at = (x = opts.delete(:updated_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @submitted_at = (x = opts.delete(:submitted_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('submitted_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @lines = (x = opts.delete(:lines); x.nil? ? nil : HttpClient::Preconditions.assert_class('lines', x, Array).map { |v| HttpClient::Preconditions.assert_class('lines', HttpClient::Helper.to_object(v), Hash) })
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def attributes
  @attributes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def created_at
  @created_at
end

#customerObject (readonly)

Returns the value of attribute customer.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def customer
  @customer
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def delivered_duty
  @delivered_duty
end

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def deliveries
  @deliveries
end

#destinationObject (readonly)

Returns the value of attribute destination.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def discount
  @discount
end

#environmentObject (readonly)

Returns the value of attribute environment.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def environment
  @environment
end

#event_idObject (readonly)

Returns the value of attribute event_id.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def event_id
  @event_id
end

#experience_idObject (readonly)

Returns the value of attribute experience_id.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def experience_id
  @experience_id
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def expires_at
  @expires_at
end

#itemsObject (readonly)

Returns the value of attribute items.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def items
  @items
end

#linesObject (readonly)

Returns the value of attribute lines.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def lines
  @lines
end

#numberObject (readonly)

Returns the value of attribute number.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def organization
  @organization
end

#paymentsObject (readonly)

Returns the value of attribute payments.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def payments
  @payments
end

#pricesObject (readonly)

Returns the value of attribute prices.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def prices
  @prices
end

#selectionsObject (readonly)

Returns the value of attribute selections.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def selections
  @selections
end

#submitted_atObject (readonly)

Returns the value of attribute submitted_at.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def 
  @submitted_at
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def timestamp
  @timestamp
end

#totalObject (readonly)

Returns the value of attribute total.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def total
  @total
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



24814
24815
24816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24814

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24848
24849
24850
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24848

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

#subtype_to_hashObject



24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24852

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :number => number,
    :environment => environment,
    :experience_id => experience_id,
    :expires_at => expires_at,
    :customer => customer,
    :selections => selections,
    :items => items,
    :destination => destination,
    :deliveries => deliveries,
    :prices => prices,
    :payments => payments.nil? ? nil : payments,
    :discount => discount,
    :delivered_duty => delivered_duty,
    :total => total,
    :created_at => created_at,
    :updated_at => updated_at,
    :submitted_at => ,
    :lines => lines.nil? ? nil : lines,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



24844
24845
24846
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24844

def to_json
  JSON.dump(to_hash)
end