Class: Io::Flow::V0::Models::Label

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 = {}) ⇒ Label

Returns a new instance of Label.



11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11707

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :tracking, :status, :carrier, :tracking_number, :timestamp], 'Label')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @tracking = (x = opts.delete(:tracking); x.is_a?(::Io::Flow::V0::Models::TrackingSummary) ? x : ::Io::Flow::V0::Models::TrackingSummary.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x))
  @carrier = HttpClient::Preconditions.assert_class('carrier', opts.delete(:carrier), String)
  @tracking_number = HttpClient::Preconditions.assert_class('tracking_number', opts.delete(:tracking_number), String)
  @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.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def carrier
  @carrier
end

#delivery_estimateObject (readonly)

Returns the value of attribute delivery_estimate.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def delivery_estimate
  @delivery_estimate
end

#descriptionObject (readonly)

Returns the value of attribute description.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def timestamp
  @timestamp
end

#trackingObject (readonly)

Returns the value of attribute tracking.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def tracking
  @tracking
end

#tracking_numberObject (readonly)

Returns the value of attribute tracking_number.



11705
11706
11707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11705

def tracking_number
  @tracking_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



11724
11725
11726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11724

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

#to_hashObject



11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11728

def to_hash
  {
    :id => id,
    :tracking => tracking.to_hash,
    :status => status.value,
    :carrier => carrier,
    :tracking_number => tracking_number,
    :timestamp => timestamp,
    :delivery_estimate => delivery_estimate,
    :description => description
  }
end

#to_jsonObject



11720
11721
11722
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11720

def to_json
  JSON.dump(to_hash)
end