Class: Io::Flow::V0::Models::B2bInvoice
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::B2bInvoice
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The b2b invoice represents a transaction between Flow and one of our clients (e.g. Flow purchasing inventory to resell to a consumer).
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#b2b_invoice_type ⇒ Object
readonly
Returns the value of attribute b2b_invoice_type.
-
#buyer ⇒ Object
readonly
Returns the value of attribute buyer.
-
#center ⇒ Object
readonly
Returns the value of attribute center.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#economic_title_location ⇒ Object
readonly
Returns the value of attribute economic_title_location.
-
#estimated_delivery_date ⇒ Object
readonly
Returns the value of attribute estimated_delivery_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#seller ⇒ Object
readonly
Returns the value of attribute seller.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ B2bInvoice
constructor
A new instance of B2bInvoice.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ B2bInvoice
Returns a new instance of B2bInvoice.
24243 24244 24245 24246 24247 24248 24249 24250 24251 24252 24253 24254 24255 24256 24257 24258 24259 24260 24261 24262 24263 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24243 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :number, :buyer, :seller, :status, :date, :key, :order, :economic_title_location, :tax, :lines, :documents, :attributes], 'B2bInvoice') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String) @buyer = (x = opts.delete(:buyer); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x)) @seller = (x = opts.delete(:seller); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecordEntity) ? x : ::Io::Flow::V0::Models::MerchantOfRecordEntity.new(x)) @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceStatus) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceStatus.apply(x)) @date = HttpClient::Preconditions.assert_class('date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:date)), DateTime) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceOrderSummary) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceOrderSummary.new(x)) @economic_title_location = (x = opts.delete(:economic_title_location); x.is_a?(::Io::Flow::V0::Models::EconomicTitleLocation) ? x : ::Io::Flow::V0::Models::EconomicTitleLocation.apply(x)) @center = (x = opts.delete(:center); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceCenterReference) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceCenterReference.new(x))) @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x))) @tax = (x = opts.delete(:tax); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)) @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLine) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLine.from_json(x)) } @documents = HttpClient::Preconditions.assert_class('documents', opts.delete(:documents), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceDocument) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceDocument.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 } @estimated_delivery_date = (x = opts.delete(:estimated_delivery_date); x.nil? ? nil : HttpClient::Preconditions.assert_class('estimated_delivery_date', HttpClient::Helper.to_date_time_iso8601(x), DateTime)) @b2b_invoice_type = (x = (x = opts.delete(:b2b_invoice_type); x.nil? ? "self_bill_invoice" : x); x.is_a?(::Io::Flow::V0::Models::B2bInvoiceType) ? x : ::Io::Flow::V0::Models::B2bInvoiceType.apply(x)) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def attributes @attributes end |
#b2b_invoice_type ⇒ Object (readonly)
Returns the value of attribute b2b_invoice_type.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def b2b_invoice_type @b2b_invoice_type end |
#buyer ⇒ Object (readonly)
Returns the value of attribute buyer.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def buyer @buyer end |
#center ⇒ Object (readonly)
Returns the value of attribute center.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def center @center end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def date @date end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def destination @destination end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def documents @documents end |
#economic_title_location ⇒ Object (readonly)
Returns the value of attribute economic_title_location.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def economic_title_location @economic_title_location end |
#estimated_delivery_date ⇒ Object (readonly)
Returns the value of attribute estimated_delivery_date.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def estimated_delivery_date @estimated_delivery_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def key @key end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def lines @lines end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def number @number end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def order @order end |
#seller ⇒ Object (readonly)
Returns the value of attribute seller.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def seller @seller end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def status @status end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
24241 24242 24243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24241 def tax @tax end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
24269 24270 24271 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24269 def copy(incoming={}) B2bInvoice.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
24273 24274 24275 24276 24277 24278 24279 24280 24281 24282 24283 24284 24285 24286 24287 24288 24289 24290 24291 24292 24293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24273 def to_hash { :id => id, :number => number, :buyer => buyer.to_hash, :seller => seller.to_hash, :status => status.value, :date => date, :key => key, :order => order.to_hash, :economic_title_location => economic_title_location.value, :center => center.nil? ? nil : center.to_hash, :destination => destination.nil? ? nil : destination.to_hash, :tax => tax.to_hash, :lines => lines.map { |o| o.to_hash }, :documents => documents.map { |o| o.to_hash }, :attributes => attributes, :estimated_delivery_date => estimated_delivery_date, :b2b_invoice_type => b2b_invoice_type.value } end |
#to_json ⇒ Object
24265 24266 24267 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24265 def to_json JSON.dump(to_hash) end |