Class: Io::Flow::V0::Models::TrackingLabel
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::TrackingLabel
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a specific label being tracked as part of the tracking bucket
Instance Attribute Summary collapse
-
#carrier ⇒ Object
readonly
Returns the value of attribute carrier.
-
#carrier_tracking_number ⇒ Object
readonly
Returns the value of attribute carrier_tracking_number.
-
#delivery_estimate ⇒ Object
readonly
Returns the value of attribute delivery_estimate.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ TrackingLabel
constructor
A new instance of TrackingLabel.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ TrackingLabel
Returns a new instance of TrackingLabel.
28878 28879 28880 28881 28882 28883 28884 28885 28886 28887 28888 28889 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28878 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :carrier, :carrier_tracking_number, :events, :status, :timestamp], 'TrackingLabel') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @carrier = HttpClient::Preconditions.assert_class('carrier', opts.delete(:carrier), String) @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String) @events = HttpClient::Preconditions.assert_class('events', opts.delete(:events), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TrackingEvent) ? x : ::Io::Flow::V0::Models::TrackingEvent.new(x)) } @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x)) @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime) @delivery_estimate = (x = opts.delete(:delivery_estimate); x.nil? ? nil : HttpClient::Preconditions.assert_class('delivery_estimate', HttpClient::Helper.to_date_time_iso8601(x), DateTime)) @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String)) end |
Instance Attribute Details
#carrier ⇒ Object (readonly)
Returns the value of attribute carrier.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def carrier @carrier end |
#carrier_tracking_number ⇒ Object (readonly)
Returns the value of attribute carrier_tracking_number.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def carrier_tracking_number @carrier_tracking_number end |
#delivery_estimate ⇒ Object (readonly)
Returns the value of attribute delivery_estimate.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def delivery_estimate @delivery_estimate end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def description @description end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def events @events end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def status @status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
28876 28877 28878 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28876 def @timestamp end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
28895 28896 28897 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28895 def copy(incoming={}) TrackingLabel.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
28899 28900 28901 28902 28903 28904 28905 28906 28907 28908 28909 28910 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28899 def to_hash { :id => id, :carrier => carrier, :carrier_tracking_number => carrier_tracking_number, :events => events.map { |o| o.to_hash }, :status => status.value, :timestamp => , :delivery_estimate => delivery_estimate, :description => description } end |
#to_json ⇒ Object
28891 28892 28893 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28891 def to_json JSON.dump(to_hash) end |