Class: Io::Flow::V0::Models::Order
- Inherits:
-
ExpandableOrder
- Object
- ExpandableOrder
- Io::Flow::V0::Models::Order
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
An order represents all of the information about a particular set of line items, including pricing, currency rates, delivery options, etc. All information in an order is guaranteed by Flow - if an order is submitted before its expiration. The intended use case is to create an order as a consumer enters checkout, then to submit that order as part of the user submitting their order. Note that Flow will automatically mark an order submitted if we see payment authorization(s) covering the full balance of an order.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#deliveries ⇒ Object
readonly
Returns the value of attribute deliveries.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#experience ⇒ Object
readonly
Returns the value of attribute experience.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#geo ⇒ Object
readonly
Returns the value of attribute geo.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#merchant_of_record ⇒ Object
readonly
Returns the value of attribute merchant_of_record.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#payments ⇒ Object
readonly
Returns the value of attribute payments.
-
#prices ⇒ Object
readonly
Returns the value of attribute prices.
-
#promotions ⇒ Object
readonly
Returns the value of attribute promotions.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#selections ⇒ Object
readonly
Returns the value of attribute selections.
-
#submitted_at ⇒ Object
readonly
Returns the value of attribute submitted_at.
-
#tax_registration ⇒ Object
readonly
Returns the value of attribute tax_registration.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from ExpandableOrder
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Order
constructor
A new instance of Order.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from ExpandableOrder
Constructor Details
#initialize(incoming = {}) ⇒ Order
Returns a new instance of Order.
40281 40282 40283 40284 40285 40286 40287 40288 40289 40290 40291 40292 40293 40294 40295 40296 40297 40298 40299 40300 40301 40302 40303 40304 40305 40306 40307 40308 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40281 def initialize(incoming={}) super(:discriminator => ExpandableOrder::Types::ORDER) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :number, :customer, :delivered_duty, :destination, :expires_at, :items, :deliveries, :selections, :prices, :total, :attributes], 'Order') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String) @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))) @experience = (x = opts.delete(:experience); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ExpandableExperience) ? x : ::Io::Flow::V0::Models::ExpandableExperience.from_json(x))) @customer = (x = opts.delete(:customer); x.is_a?(::Io::Flow::V0::Models::OrderCustomer) ? x : ::Io::Flow::V0::Models::OrderCustomer.new(x)) @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)) @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x)) @expires_at = HttpClient::Preconditions.assert_class('expires_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:expires_at)), DateTime) @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)) } @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)) } @selections = HttpClient::Preconditions.assert_class('selections', opts.delete(:selections), Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) } @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)) } @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x)) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h } @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)) }) @identifiers = (x = opts.delete(:identifiers); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifiers', x, Array).map { |v| HttpClient::Preconditions.assert_class('identifiers', v, String) }) @promotions = (x = opts.delete(:promotions); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Promotions) ? x : ::Io::Flow::V0::Models::Promotions.new(x))) @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)) }) @balance = (x = opts.delete(:balance); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x))) @rules = (x = opts.delete(:rules); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderRulesSummary) ? x : ::Io::Flow::V0::Models::OrderRulesSummary.new(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))) @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))) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def attributes @attributes end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def balance @balance end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def customer @customer end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def delivered_duty @delivered_duty end |
#deliveries ⇒ Object (readonly)
Returns the value of attribute deliveries.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def deliveries @deliveries end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def destination @destination end |
#experience ⇒ Object (readonly)
Returns the value of attribute experience.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def experience @experience end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def expires_at @expires_at end |
#geo ⇒ Object (readonly)
Returns the value of attribute geo.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def geo @geo end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def id @id end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def identifiers @identifiers end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def items @items end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def lines @lines end |
#merchant_of_record ⇒ Object (readonly)
Returns the value of attribute merchant_of_record.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def merchant_of_record @merchant_of_record end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def number @number end |
#payments ⇒ Object (readonly)
Returns the value of attribute payments.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def payments @payments end |
#prices ⇒ Object (readonly)
Returns the value of attribute prices.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def prices @prices end |
#promotions ⇒ Object (readonly)
Returns the value of attribute promotions.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def promotions @promotions end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def rules @rules end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def selections @selections end |
#submitted_at ⇒ Object (readonly)
Returns the value of attribute submitted_at.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def submitted_at @submitted_at end |
#tax_registration ⇒ Object (readonly)
Returns the value of attribute tax_registration.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def tax_registration @tax_registration end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
40279 40280 40281 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40279 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
40314 40315 40316 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40314 def copy(incoming={}) Order.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
40318 40319 40320 40321 40322 40323 40324 40325 40326 40327 40328 40329 40330 40331 40332 40333 40334 40335 40336 40337 40338 40339 40340 40341 40342 40343 40344 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40318 def subtype_to_hash { :id => id, :number => number, :merchant_of_record => merchant_of_record.nil? ? nil : merchant_of_record.value, :experience => experience.nil? ? nil : experience.to_hash, :customer => customer.to_hash, :delivered_duty => delivered_duty.value, :destination => destination.to_hash, :expires_at => expires_at, :items => items.map { |o| o.to_hash }, :deliveries => deliveries.map { |o| o.to_hash }, :selections => selections, :prices => prices.map { |o| o.to_hash }, :total => total.to_hash, :attributes => attributes, :submitted_at => submitted_at, :lines => lines.nil? ? nil : lines.map { |o| o.to_hash }, :identifiers => identifiers.nil? ? nil : identifiers, :promotions => promotions.nil? ? nil : promotions.to_hash, :payments => payments.nil? ? nil : payments.map { |o| o.to_hash }, :balance => balance.nil? ? nil : balance.to_hash, :rules => rules.nil? ? nil : rules.to_hash, :tax_registration => tax_registration.nil? ? nil : tax_registration.to_hash, :geo => geo.nil? ? nil : geo.to_hash } end |
#to_json ⇒ Object
40310 40311 40312 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40310 def to_json JSON.dump(to_hash) end |