Class: Io::Flow::V0::Models::ShippingNotification

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

Overview

Represents 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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingNotification

Returns a new instance of ShippingNotification.



30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30764

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :carrier_tracking_number, :destination, :flow_tracking_number, :origin, :package, :service, :window], 'ShippingNotification')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String)
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @flow_tracking_number = HttpClient::Preconditions.assert_class('flow_tracking_number', opts.delete(:flow_tracking_number), String)
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @package = (x = opts.delete(:package); x.is_a?(::Io::Flow::V0::Models::ShippingLabelPackage) ? x : ::Io::Flow::V0::Models::ShippingLabelPackage.new(x))
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x))
  @window = (x = opts.delete(:window); x.is_a?(::Io::Flow::V0::Models::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x))
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LabelOrderSummary) ? x : ::Io::Flow::V0::Models::LabelOrderSummary.new(x)))
  @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

#attributesObject (readonly)

Returns the value of attribute attributes.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def carrier_tracking_number
  @carrier_tracking_number
end

#destinationObject (readonly)

Returns the value of attribute destination.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def destination
  @destination
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def flow_tracking_number
  @flow_tracking_number
end

#idObject (readonly)

Returns the value of attribute id.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def key
  @key
end

#orderObject (readonly)

Returns the value of attribute order.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def package
  @package
end

#serviceObject (readonly)

Returns the value of attribute service.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def shipment_recipient
  @shipment_recipient
end

#windowObject (readonly)

Returns the value of attribute window.



30762
30763
30764
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30762

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30785
30786
30787
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30785

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

#to_hashObject



30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30789

def to_hash
  {
    :id => id,
    :key => key,
    :attributes => attributes,
    :carrier_tracking_number => carrier_tracking_number,
    :destination => destination.to_hash,
    :flow_tracking_number => flow_tracking_number,
    :origin => origin.to_hash,
    :package => package.to_hash,
    :service => service.to_hash,
    :window => window.to_hash,
    :order => order.nil? ? nil : order.to_hash,
    :shipment_recipient => shipment_recipient.nil? ? nil : shipment_recipient.value
  }
end

#to_jsonObject



30781
30782
30783
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30781

def to_json
  JSON.dump(to_hash)
end