Class: Io::Flow::V0::Models::ConsumerInvoiceLine
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ConsumerInvoiceLine
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
ConsumerInvoiceLineDiscount, ConsumerInvoiceLineItem, ConsumerInvoiceLineShipping, ConsumerInvoiceLineUndefinedType
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ ConsumerInvoiceLine
constructor
A new instance of ConsumerInvoiceLine.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ConsumerInvoiceLine
Returns a new instance of ConsumerInvoiceLine.
10357 10358 10359 10360 10361 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10357 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'ConsumerInvoiceLine') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
10355 10356 10357 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10355 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10371 def ConsumerInvoiceLine.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip if discriminator.empty? raise "Union type[consumer_invoice_line] requires a field named 'discriminator'" end case discriminator when Types::CONSUMER_INVOICE_LINE_ITEM; ConsumerInvoiceLineItem.new(hash) when Types::CONSUMER_INVOICE_LINE_DISCOUNT; ConsumerInvoiceLineDiscount.new(hash) when Types::CONSUMER_INVOICE_LINE_SHIPPING; ConsumerInvoiceLineShipping.new(hash) else ConsumerInvoiceLineUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
10363 10364 10365 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10363 def subtype_to_hash raise 'Cannot serialize an instance of consumer_invoice_line directly - must use one of the specific types: consumer_invoice_line_item, consumer_invoice_line_discount, consumer_invoice_line_shipping' end |
#to_hash ⇒ Object
10367 10368 10369 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10367 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |