Class: Trackerific::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/trackerific.rb

Overview

Base class for Trackerific package tracking services.

Direct Known Subclasses

FedEx, UPS, USPS

Instance Method Summary (collapse)

Constructor Details

- (Base) initialize(options = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new instance of Trackerific::Base with required options



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trackerific.rb', line 14

def initialize(options = {})
  required = required_options
  # make sure all the required options exist
  required.each do |k|
    raise ArgumentError.new("Missing required parameter: #{k}") unless options.has_key?(k)
  end
  # make sure no invalid options exist
  options.each do |k, v|
    raise ArgumentError.new("Invalid parameter: #{k}") unless required.include?(k)
  end
  @options = options
end

Instance Method Details

- (Trackerific::Details) track_package(package_id)

Gets the tracking information for the package from the server

Examples:

Override this method in your custom tracking provider to implement tracking

module Trackerific
  class MyTrackingProvider < Base
    def track_package
      Trackerific::Details.new(
        "summary of tracking events",
        [Trackerific::Event.new(Time.now, "summary", "location")]
      )
    end
  end
end

Parameters:

  • package_id (String)

    the package identifier

Returns:



42
43
44
# File 'lib/trackerific.rb', line 42

def track_package(package_id)
  @package_id = package_id
end