Sha256: 5747173362a437e07a6cd84cd4d58891a1d98400360c9d7ae77b32ca70a80ab3

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module Trackerific
  module Services
     # Provides a mock service for using in test and development
    class MockService < Base
      require 'date'

      self.register :mock_service

      def self.credentials
        {}
      end

      def self.package_id_matchers
        [ /XXXXXXXXXX/, /XXXxxxxxxx/ ]
      end

      def track(id)
        if id == "XXXXXXXXXX"
          Trackerific::Details.new(id, "Your package was delivered.",
            [
              Trackerific::Event.new(
                :date         => Date.today,
                :description  => "Package delivered.",
                :location     => "SANTA MARIA, CA"
              ),
              Trackerific::Event.new(
                :date         => Date.today - 1,
                :description  => "Package scanned.",
                :location     => "SANTA BARBARA, CA"
              ),
              Trackerific::Event.new(
                :date         => Date.today - 2,
                :description  => "Package picked up for delivery.",
                :location     => "LOS ANGELES, CA"
              )
            ]
          )
        else
          raise Trackerific::Error, "Package not found."
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trackerific-0.7.2 lib/trackerific/services/mock_service.rb