Class: Io::Flow::V0::Models::Tracking
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Tracking
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Top level tracking information which contains labels. In cases where shipments are re-labeled, you will see multiple labels for each tracking allowing simple access to see where a shipment is - with which carrier and with the local tracking number
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#order_number ⇒ Object
readonly
Returns the value of attribute order_number.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Tracking
constructor
A new instance of Tracking.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Tracking
Returns a new instance of Tracking.
53738 53739 53740 53741 53742 53743 53744 53745 53746 53747 53748 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53738 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :labels, :status, :attributes, :url], 'Tracking') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @labels = HttpClient::Preconditions.assert_class('labels', opts.delete(:labels), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TrackingLabel) ? x : ::Io::Flow::V0::Models::TrackingLabel.new(x)) } @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x)) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h } @url = HttpClient::Preconditions.assert_class('url', opts.delete(:url), String) @window = (x = opts.delete(:window); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x))) @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String)) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def id @id end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def labels @labels end |
#order_number ⇒ Object (readonly)
Returns the value of attribute order_number.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def order_number @order_number end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def url @url end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
53736 53737 53738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53736 def window @window end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
53754 53755 53756 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53754 def copy(incoming={}) Tracking.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
53758 53759 53760 53761 53762 53763 53764 53765 53766 53767 53768 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53758 def to_hash { :id => id, :labels => labels.map { |o| o.to_hash }, :status => status.value, :attributes => attributes, :url => url, :window => window.nil? ? nil : window.to_hash, :order_number => order_number } end |
#to_json ⇒ Object
53750 53751 53752 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53750 def to_json JSON.dump(to_hash) end |