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

Instance Method Summary collapse

Methods inherited from Event

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OrderUpserted

Returns a new instance of OrderUpserted.



13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13748

def initialize(incoming={})
  super(:name => 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) }
  @discount = (x = opts.delete(:discount); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount', HttpClient::Helper.to_object(x), Hash))
  @total = HttpClient::Preconditions.assert_class('total', HttpClient::Helper.to_object(opts.delete(:total)), Hash)
end

Instance Attribute Details

#customerObject (readonly)

Returns the value of attribute customer.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def customer
  @customer
end

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def deliveries
  @deliveries
end

#destinationObject (readonly)

Returns the value of attribute destination.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def discount
  @discount
end

#environmentObject (readonly)

Returns the value of attribute environment.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def environment
  @environment
end

#event_idObject (readonly)

Returns the value of attribute event_id.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def event_id
  @event_id
end

#experience_idObject (readonly)

Returns the value of attribute experience_id.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def experience_id
  @experience_id
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def expires_at
  @expires_at
end

#itemsObject (readonly)

Returns the value of attribute items.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def items
  @items
end

#numberObject (readonly)

Returns the value of attribute number.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def organization
  @organization
end

#pricesObject (readonly)

Returns the value of attribute prices.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def prices
  @prices
end

#selectionsObject (readonly)

Returns the value of attribute selections.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def selections
  @selections
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def timestamp
  @timestamp
end

#totalObject (readonly)

Returns the value of attribute total.



13746
13747
13748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13746

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13773
13774
13775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13773

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

#subtype_to_hashObject



13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13777

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,
    :discount => discount,
    :total => total
  }
end

#to_jsonObject



13769
13770
13771
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13769

def to_json
  JSON.dump(to_hash)
end