Class: Io::Flow::V0::Models::ShippingLabelForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Different models for forms to create shipping labels

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#discriminatorObject (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_hashObject



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_hashObject



15507
15508
15509
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15507

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end