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.



13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13202

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.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def customer
  @customer
end

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def deliveries
  @deliveries
end

#destinationObject (readonly)

Returns the value of attribute destination.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def discount
  @discount
end

#environmentObject (readonly)

Returns the value of attribute environment.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def environment
  @environment
end

#event_idObject (readonly)

Returns the value of attribute event_id.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def event_id
  @event_id
end

#experience_idObject (readonly)

Returns the value of attribute experience_id.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def experience_id
  @experience_id
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def expires_at
  @expires_at
end

#itemsObject (readonly)

Returns the value of attribute items.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def items
  @items
end

#numberObject (readonly)

Returns the value of attribute number.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def organization
  @organization
end

#pricesObject (readonly)

Returns the value of attribute prices.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def prices
  @prices
end

#selectionsObject (readonly)

Returns the value of attribute selections.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def selections
  @selections
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def timestamp
  @timestamp
end

#totalObject (readonly)

Returns the value of attribute total.



13200
13201
13202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13200

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13227
13228
13229
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13227

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

#subtype_to_hashObject



13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13231

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



13223
13224
13225
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13223

def to_json
  JSON.dump(to_hash)
end