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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingNotificationForm

Returns a new instance of ShippingNotificationForm.



21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21759

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:carrier_tracking_number, :destination, :order_number, :origin, :package, :service], 'ShippingNotificationForm')
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', 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))
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_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 = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def carrier_tracking_number
  @carrier_tracking_number
end

#destinationObject (readonly)

Returns the value of attribute destination.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def destination
  @destination
end

#keyObject (readonly)

Returns the value of attribute key.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def package
  @package
end

#serviceObject (readonly)

Returns the value of attribute service.



21757
21758
21759
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21757

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21776
21777
21778
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21776

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

#to_hashObject



21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21780

def to_hash
  {
    :key => key,
    :attributes => attributes.nil? ? nil : attributes,
    :carrier_tracking_number => carrier_tracking_number,
    :destination => destination.to_hash,
    :order_number => order_number,
    :origin => origin.to_hash,
    :package => package.to_hash,
    :service => service
  }
end

#to_jsonObject



21772
21773
21774
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21772

def to_json
  JSON.dump(to_hash)
end