class Io::Flow::V0::Models::TrackingLabel

Represents a specific label being tracked as part of the tracking bucket

Attributes

carrier[R]
carrier_tracking_number[R]
delivery_estimate[R]
description[R]
events[R]
id[R]
status[R]
timestamp[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 71474
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

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 71491
def copy(incoming={})
  TrackingLabel.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 71495
def to_hash
  {
    :id => id,
    :carrier => carrier,
    :carrier_tracking_number => carrier_tracking_number,
    :events => events.map { |o| o.to_hash },
    :status => status.value,
    :timestamp => timestamp,
    :delivery_estimate => delivery_estimate,
    :description => description
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 71487
def to_json
  JSON.dump(to_hash)
end