Class: Io::Flow::V0::Models::Tracking

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

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Tracking

Returns a new instance of Tracking.



14696
14697
14698
14699
14700
14701
14702
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14696

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :status, :metadata], 'Tracking')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::TrackingStatus) ? x : ::Io::Flow::V0::Models::TrackingStatus.apply(x))
   = HttpClient::Preconditions.assert_class('metadata', HttpClient::Helper.to_object(opts.delete(:metadata)), Hash)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14694
14695
14696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14694

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



14694
14695
14696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14694

def 
  
end

#statusObject (readonly)

Returns the value of attribute status.



14694
14695
14696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14694

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14708
14709
14710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14708

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

#to_hashObject



14712
14713
14714
14715
14716
14717
14718
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14712

def to_hash
  {
    :id => id,
    :status => status.value,
    :metadata => 
  }
end

#to_jsonObject



14704
14705
14706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14704

def to_json
  JSON.dump(to_hash)
end