lib/carousel/tracking.rb in carousel-ruby-api-0.0.4 vs lib/carousel/tracking.rb in carousel-ruby-api-0.0.5
- old
+ new
@@ -1,19 +1,28 @@
module Carousel
class Tracking
attr_accessor :carrier
- FEDEX = "http://www.fedexuk.net/accounts/QuickTrack.aspx?consignment=:tracking_number"
- CAROUSEL = "https://web.carousel.eu/easyweb/default.asp?action=clienttrack&type=Carousel&acct1=BEC01&reference=:tracking_number"
-
def initialize(carrier, tracking_number)
@carrier = carrier
@tracking_number = tracking_number
end
def carrier_destination
- self.class.const_get(carrier.upcase)
+ carrier_url(carrier.upcase)
+ end
+
+ def carrier_url(carrier)
+ case carrier
+ when 'FEDEX'
+ "http://www.fedexuk.net/accounts/QuickTrack.aspx?" +
+ "consignment=:tracking_number"
+ when 'CAROUSEL'
+ "https://web.carousel.eu/easyweb/default.asp?" +
+ "action=clienttrack&type=Carousel&" +
+ "acct1=#{Carousel.config[:account]}&reference=:tracking_number"
+ end
end
def url
carrier_destination.gsub(':tracking_number', @tracking_number)
end
\ No newline at end of file