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.



69383
69384
69385
69386
69387
69388
69389
69390
69391
69392
69393
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69383

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.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def carrier_tracking_number
  @carrier_tracking_number
end

#itemsObject (readonly)

Returns the value of attribute items.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def order_number
  @order_number
end

#serviceObject (readonly)

Returns the value of attribute service.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



69381
69382
69383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69381

def shipment_recipient
  @shipment_recipient
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



69399
69400
69401
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69399

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

#subtype_to_hashObject



69403
69404
69405
69406
69407
69408
69409
69410
69411
69412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69403

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



69395
69396
69397
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69395

def to_json
  JSON.dump(to_hash)
end