Class: Io::Flow::V0::Models::ShippingLabelForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ShippingLabelForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Different models for forms to create shipping labels
Direct Known Subclasses
BridgeShippingLabelForm, DetailedShippingLabelForm, ShippingLabelFormUndefinedType, SummaryShippingLabelForm
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 = {}) ⇒ ShippingLabelForm
constructor
A new instance of ShippingLabelForm.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ShippingLabelForm
Returns a new instance of ShippingLabelForm.
15498 15499 15500 15501 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15498 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'detailed_shipping_label_form', String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
15496 15497 15498 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15496 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15511 def ShippingLabelForm.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[shipping_label_form] requires a field named 'discriminator'" end case discriminator when Types::DETAILED_SHIPPING_LABEL_FORM; DetailedShippingLabelForm.new(hash) when Types::SUMMARY_SHIPPING_LABEL_FORM; SummaryShippingLabelForm.new(hash) when Types::BRIDGE_SHIPPING_LABEL_FORM; BridgeShippingLabelForm.new(hash) else ShippingLabelFormUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
15503 15504 15505 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15503 def subtype_to_hash raise 'Cannot serialize an instance of shipping_label_form directly - must use one of the specific types: detailed_shipping_label_form, summary_shipping_label_form, bridge_shipping_label_form' end |
#to_hash ⇒ Object
15507 15508 15509 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15507 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |