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.



36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36744

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 = (x = opts.delete(:customer); x.is_a?(::Io::Flow::V0::Models::OrderCustomer) ? x : ::Io::Flow::V0::Models::OrderCustomer.new(x))
  @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| (x = v; x.is_a?(::Io::Flow::V0::Models::LocalizedLineItem) ? x : ::Io::Flow::V0::Models::LocalizedLineItem.new(x)) }
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x))
  @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Delivery) ? x : ::Io::Flow::V0::Models::Delivery.from_json(x)) }
  @prices = HttpClient::Preconditions.assert_class('prices', opts.delete(:prices), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x)) }
  @order_id = (x = opts.delete(:order_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_id', x, String))
  @payments = (x = opts.delete(:payments); x.nil? ? nil : HttpClient::Preconditions.assert_class('payments', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPayment) ? x : ::Io::Flow::V0::Models::OrderPayment.new(x)) })
  @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)))
  @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : HttpClient::Preconditions.assert_class('delivered_duty', x, String))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x))
  @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| (x = v; x.is_a?(::Io::Flow::V0::Models::Line) ? x : ::Io::Flow::V0::Models::Line.new(x)) })
  @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 })
  @geo = (x = opts.delete(:geo); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderGeo) ? x : ::Io::Flow::V0::Models::OrderGeo.new(x)))
  @merchant_of_record = (x = opts.delete(:merchant_of_record); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderMerchantOfRecord) ? x : ::Io::Flow::V0::Models::OrderMerchantOfRecord.apply(x)))
  @tax_registration = (x = opts.delete(:tax_registration); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::TaxRegistration) ? x : ::Io::Flow::V0::Models::TaxRegistration.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def attributes
  @attributes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def created_at
  @created_at
end

#customerObject (readonly)

Returns the value of attribute customer.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def customer
  @customer
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def delivered_duty
  @delivered_duty
end

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def deliveries
  @deliveries
end

#destinationObject (readonly)

Returns the value of attribute destination.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def destination
  @destination
end

#discountObject (readonly)

Returns the value of attribute discount.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def discount
  @discount
end

#environmentObject (readonly)

Returns the value of attribute environment.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def environment
  @environment
end

#event_idObject (readonly)

Returns the value of attribute event_id.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def event_id
  @event_id
end

#experience_idObject (readonly)

Returns the value of attribute experience_id.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def experience_id
  @experience_id
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def expires_at
  @expires_at
end

#geoObject (readonly)

Returns the value of attribute geo.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def geo
  @geo
end

#itemsObject (readonly)

Returns the value of attribute items.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def items
  @items
end

#linesObject (readonly)

Returns the value of attribute lines.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def lines
  @lines
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def merchant_of_record
  @merchant_of_record
end

#numberObject (readonly)

Returns the value of attribute number.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def number
  @number
end

#order_idObject (readonly)

Returns the value of attribute order_id.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def order_id
  @order_id
end

#organizationObject (readonly)

Returns the value of attribute organization.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def organization
  @organization
end

#paymentsObject (readonly)

Returns the value of attribute payments.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def payments
  @payments
end

#pricesObject (readonly)

Returns the value of attribute prices.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def prices
  @prices
end

#selectionsObject (readonly)

Returns the value of attribute selections.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def selections
  @selections
end

#submitted_atObject (readonly)

Returns the value of attribute submitted_at.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def 
  @submitted_at
end

#tax_registrationObject (readonly)

Returns the value of attribute tax_registration.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def tax_registration
  @tax_registration
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def timestamp
  @timestamp
end

#totalObject (readonly)

Returns the value of attribute total.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def total
  @total
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



36742
36743
36744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36742

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



36780
36781
36782
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36780

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

#subtype_to_hashObject



36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36784

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.to_hash,
    :selections => selections,
    :items => items.map { |o| o.to_hash },
    :destination => destination.to_hash,
    :deliveries => deliveries.map { |o| o.to_hash },
    :prices => prices.map { |o| o.to_hash },
    :order_id => order_id,
    :payments => payments.nil? ? nil : payments.map { |o| o.to_hash },
    :discount => discount.nil? ? nil : discount.to_hash,
    :delivered_duty => delivered_duty,
    :total => total.to_hash,
    :created_at => created_at,
    :updated_at => updated_at,
    :submitted_at => ,
    :lines => lines.nil? ? nil : lines.map { |o| o.to_hash },
    :attributes => attributes.nil? ? nil : attributes,
    :geo => geo.nil? ? nil : geo.to_hash,
    :merchant_of_record => merchant_of_record.nil? ? nil : merchant_of_record.value,
    :tax_registration => tax_registration.nil? ? nil : tax_registration.to_hash
  }
end

#to_jsonObject



36776
36777
36778
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 36776

def to_json
  JSON.dump(to_hash)
end