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.



14601
14602
14603
14604
14605
14606
14607
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14601

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.



14599
14600
14601
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14599

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



14599
14600
14601
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14599

def 
  
end

#statusObject (readonly)

Returns the value of attribute status.



14599
14600
14601
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14599

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14613
14614
14615
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14613

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

#to_hashObject



14617
14618
14619
14620
14621
14622
14623
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14617

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

#to_jsonObject



14609
14610
14611
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14609

def to_json
  JSON.dump(to_hash)
end