Class: Io::Flow::V0::Models::ShippingLabel

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

Overview

Represents information about a carrier-generated shipping label used by a shipper to transport a package from a given origin to destination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingLabel

Returns a new instance of ShippingLabel.



59011
59012
59013
59014
59015
59016
59017
59018
59019
59020
59021
59022
59023
59024
59025
59026
59027
59028
59029
59030
59031
59032
59033
59034
59035
59036
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59011

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :carrier_tracking_number, :carrier_tracking_number_url, :destination, :flow_tracking_number, :flow_tracking_number_url, :origin, :service, :window, :shipment_recipient], 'ShippingLabel')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @hop = (x = opts.delete(:hop); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelHopSummary) ? x : ::Io::Flow::V0::Models::ShippingLabelHopSummary.new(x)))
  @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)
  @carrier_tracking_number_url = HttpClient::Preconditions.assert_class('carrier_tracking_number_url', opts.delete(:carrier_tracking_number_url), String)
  @cost = (x = opts.delete(:cost); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)))
  @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)
  @flow_tracking_number_url = HttpClient::Preconditions.assert_class('flow_tracking_number_url', opts.delete(:flow_tracking_number_url), String)
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.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))
  @label = (x = opts.delete(:label); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelDocument) ? x : ::Io::Flow::V0::Models::ShippingLabelDocument.new(x)))
  @invoice = (x = opts.delete(:invoice); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelDocument) ? x : ::Io::Flow::V0::Models::ShippingLabelDocument.new(x)))
  @return_ = (x = opts.delete(:return); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelDocument) ? x : ::Io::Flow::V0::Models::ShippingLabelDocument.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)))
  @package = (x = opts.delete(:package); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelPackage) ? x : ::Io::Flow::V0::Models::ShippingLabelPackage.new(x)))
  @order_identifier = (x = opts.delete(:order_identifier); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_identifier', x, String))
  @fulfillment_key = (x = opts.delete(:fulfillment_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('fulfillment_key', x, String))
  @shipment_recipient = (x = opts.delete(:shipment_recipient); x.is_a?(::Io::Flow::V0::Models::ShipmentRecipient) ? x : ::Io::Flow::V0::Models::ShipmentRecipient.apply(x))
  @created_at = (x = opts.delete(:created_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @updated_at = (x = opts.delete(:updated_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def carrier_tracking_number
  @carrier_tracking_number
end

#carrier_tracking_number_urlObject (readonly)

Returns the value of attribute carrier_tracking_number_url.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def carrier_tracking_number_url
  @carrier_tracking_number_url
end

#costObject (readonly)

Returns the value of attribute cost.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def cost
  @cost
end

#created_atObject (readonly)

Returns the value of attribute created_at.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def created_at
  @created_at
end

#destinationObject (readonly)

Returns the value of attribute destination.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def destination
  @destination
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def flow_tracking_number
  @flow_tracking_number
end

#flow_tracking_number_urlObject (readonly)

Returns the value of attribute flow_tracking_number_url.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def flow_tracking_number_url
  @flow_tracking_number_url
end

#fulfillment_keyObject (readonly)

Returns the value of attribute fulfillment_key.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def fulfillment_key
  @fulfillment_key
end

#hopObject (readonly)

Returns the value of attribute hop.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def hop
  @hop
end

#idObject (readonly)

Returns the value of attribute id.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def id
  @id
end

#invoiceObject (readonly)

Returns the value of attribute invoice.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def invoice
  @invoice
end

#labelObject (readonly)

Returns the value of attribute label.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def label
  @label
end

#orderObject (readonly)

Returns the value of attribute order.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def order
  @order
end

#order_identifierObject (readonly)

Returns the value of attribute order_identifier.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def order_identifier
  @order_identifier
end

#originObject (readonly)

Returns the value of attribute origin.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def package
  @package
end

#return_Object (readonly)

Returns the value of attribute return_.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def return_
  @return_
end

#serviceObject (readonly)

Returns the value of attribute service.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def shipment_recipient
  @shipment_recipient
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def updated_at
  @updated_at
end

#windowObject (readonly)

Returns the value of attribute window.



59009
59010
59011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59009

def window
  @window
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



59042
59043
59044
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59042

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

#to_hashObject



59046
59047
59048
59049
59050
59051
59052
59053
59054
59055
59056
59057
59058
59059
59060
59061
59062
59063
59064
59065
59066
59067
59068
59069
59070
59071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59046

def to_hash
  {
    :id => id,
    :hop => hop.nil? ? nil : hop.to_hash,
    :attributes => attributes,
    :carrier_tracking_number => carrier_tracking_number,
    :carrier_tracking_number_url => carrier_tracking_number_url,
    :cost => cost.nil? ? nil : cost.to_hash,
    :destination => destination.to_hash,
    :flow_tracking_number => flow_tracking_number,
    :flow_tracking_number_url => flow_tracking_number_url,
    :origin => origin.to_hash,
    :service => service.to_hash,
    :window => window.to_hash,
    :label => label.nil? ? nil : label.to_hash,
    :invoice => invoice.nil? ? nil : invoice.to_hash,
    :return => return_.nil? ? nil : return_.to_hash,
    :order => order.nil? ? nil : order.to_hash,
    :package => package.nil? ? nil : package.to_hash,
    :order_identifier => order_identifier,
    :fulfillment_key => fulfillment_key,
    :shipment_recipient => shipment_recipient.value,
    :created_at => created_at,
    :updated_at => updated_at
  }
end

#to_jsonObject



59038
59039
59040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59038

def to_json
  JSON.dump(to_hash)
end