Class: Io::Flow::V0::Models::TrackingLabel

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TrackingLabel

Returns a new instance of TrackingLabel.



54644
54645
54646
54647
54648
54649
54650
54651
54652
54653
54654
54655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54644

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

#carrierObject (readonly)

Returns the value of attribute carrier.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def carrier
  @carrier
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def carrier_tracking_number
  @carrier_tracking_number
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def description
  @description
end

#eventsObject (readonly)

Returns the value of attribute events.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def events
  @events
end

#idObject (readonly)

Returns the value of attribute id.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



54642
54643
54644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54642

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



54661
54662
54663
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54661

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

#to_hashObject



54665
54666
54667
54668
54669
54670
54671
54672
54673
54674
54675
54676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54665

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_jsonObject



54657
54658
54659
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54657

def to_json
  JSON.dump(to_hash)
end