Class: Io::Flow::V0::Models::SummaryShippingNotificationForm

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

Overview

Form for minimal information needed for a client-facilitated shipment where the shipping label and fulfillment was not handled by Flow.

Instance Attribute Summary collapse

Attributes inherited from ShippingNotificationForm

#discriminator

Instance Method Summary collapse

Methods inherited from ShippingNotificationForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ SummaryShippingNotificationForm

Returns a new instance of SummaryShippingNotificationForm.



64315
64316
64317
64318
64319
64320
64321
64322
64323
64324
64325
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64315

def initialize(incoming={})
  super(:discriminator => ShippingNotificationForm::Types::SUMMARY_SHIPPING_NOTIFICATION_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order_number, :items, :service, :carrier_tracking_number], 'SummaryShippingNotificationForm')
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), String)
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
  @service = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
  @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String)
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @shipment_recipient = (x = opts.delete(:shipment_recipient); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShipmentRecipient) ? x : ::Io::Flow::V0::Models::ShipmentRecipient.apply(x)))
end

Instance Attribute Details

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def carrier_tracking_number
  @carrier_tracking_number
end

#itemsObject (readonly)

Returns the value of attribute items.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def order_number
  @order_number
end

#serviceObject (readonly)

Returns the value of attribute service.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



64313
64314
64315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64313

def shipment_recipient
  @shipment_recipient
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



64331
64332
64333
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64331

def copy(incoming={})
  SummaryShippingNotificationForm.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



64335
64336
64337
64338
64339
64340
64341
64342
64343
64344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64335

def subtype_to_hash
  {
    :order_number => order_number,
    :items => items.map { |o| o.to_hash },
    :service => service,
    :carrier_tracking_number => carrier_tracking_number,
    :key => key,
    :shipment_recipient => shipment_recipient.nil? ? nil : shipment_recipient.value
  }
end

#to_jsonObject



64327
64328
64329
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 64327

def to_json
  JSON.dump(to_hash)
end