Module: Usps::Api::Endpoints::TrackV2

Included in:
Usps::Api::Endpoints
Defined in:
lib/usps/api/endpoints/track_v2.rb

Instance Method Summary collapse

Instance Method Details

#track_v2(options = {}) ⇒ Object

The Package Tracking “Fields” API is similar to the Package Track API except for the request fields, API name, and the return information. Data returned still contains the detail and summary information, but this information is broken down into fields instead of having only one line of text. Up to 10 tracking IDs may be contained in each API request to the Web Tools server.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • track_field_request (required, Hash)
    • :revision (required, Integer)

    • :client_ip (String)

    • :source_id (required, String)

    • :track_id (required, String)

    • :destination_zip_code (String)

    • :mailing_date (String)



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/usps/api/endpoints/track_v2.rb', line 24

def track_v2(options = {})
	throw ArgumentError.new('Required arguments :track_field_request missing') if options[:track_field_request].nil?
	throw ArgumentError.new('Required arguments :track_field_request, :revision missing') if options[:track_field_request][:revision].nil?
	throw ArgumentError.new('Required arguments :track_field_request, :source_id missing') if options[:track_field_request][:source_id].nil?
	throw ArgumentError.new('Required arguments :track_field_request, :track_id missing') if options[:track_field_request][:track_id].nil?

	request = build_request(:track_v2, options)
	get('https://secure.shippingapis.com/ShippingAPI.dll', {
		API: 'TrackV2',
		XML: request,
	})
end