Class: Io::Flow::V0::Models::ShippingNotificationForm

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

Overview

Form for information about a client-facilitated shipment where the shipping label and fulfillment was not handled by Flow. For merchant-of-record and tracking purposes, clients doing their own shipping will need to notify Flow of shipped packages.

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingNotificationForm



8962
8963
8964
8965
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8962

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'detailed_shipping_notification_form', String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



8960
8961
8962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8960

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8975

def ShippingNotificationForm.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_notification_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::DETAILED_SHIPPING_NOTIFICATION_FORM; DetailedShippingNotificationForm.new(hash)
    when Types::SINGLE_PACKAGE_SHIPPING_NOTIFICATION_FORM; SinglePackageShippingNotificationForm.new(hash)
    else ShippingNotificationFormUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



8967
8968
8969
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8967

def subtype_to_hash
  raise 'Cannot serialize an instance of shipping_notification_form directly - must use one of the specific types: detailed_shipping_notification_form, single_package_shipping_notification_form'
end

#to_hashObject



8971
8972
8973
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8971

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