Class: Trackerific::Base

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

Overview

Base class for Trackerific tracking services.

Direct Known Subclasses

FedEx, UPS, USPS

Instance Method Summary (collapse)

Constructor Details

- (Base) initialize(options = {})

A new instance of Base



12
13
14
15
16
17
18
19
20
21
# File 'lib/trackerific.rb', line 12

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

Instance Method Details

- (Array) required_options

Override this method if your subclass has required options.

Returns:

  • (Array)

    the required options



25
26
27
# File 'lib/trackerific.rb', line 25

def required_options
  []
end

- (Hash) track_package(package_id)

Override this method in your subclass to implement tracking a package.

Returns:

  • (Hash)

    the tracking details



31
32
33
# File 'lib/trackerific.rb', line 31

def track_package(package_id)
  @package_id = package_id
end