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.



61574
61575
61576
61577
61578
61579
61580
61581
61582
61583
61584
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61574

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.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def carrier_tracking_number
  @carrier_tracking_number
end

#itemsObject (readonly)

Returns the value of attribute items.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def order_number
  @order_number
end

#serviceObject (readonly)

Returns the value of attribute service.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



61572
61573
61574
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61572

def shipment_recipient
  @shipment_recipient
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



61590
61591
61592
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61590

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

#subtype_to_hashObject



61594
61595
61596
61597
61598
61599
61600
61601
61602
61603
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61594

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



61586
61587
61588
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61586

def to_json
  JSON.dump(to_hash)
end