lib/ups.rb in trackerific-0.1.2 vs lib/ups.rb in trackerific-0.2.0

- old
+ new

@@ -1,21 +1,23 @@ module Trackerific require 'httparty' class UPS < Base - TEST_TRACKING_NUMBERS = [ - '1Z12345E0291980793', '1Z12345E6692804405','1Z12345E1392654435', - '1Z12345E6892410845','1Z12345E029198079','1Z12345E1591910450' - ] + include ::HTTParty + format :xml + base_uri defined?(Rails) ? case Rails.env + when 'test','development' then 'https://wwwcie.ups.com/ups.app/xml' + when 'production' then 'https://www.ups.com/ups.app/xml' + end : 'https://www.ups.com/ups.app/xml' def required_options [:key, :user_id, :password] end def track_package(package_id) super - http_response = HTTP.post('/Track', :body => build_xml_request) + http_response = self.class.post('/Track', :body => build_xml_request) http_response.error! unless http_response.code == 200 case http_response['TrackResponse']['Response']['ResponseStatusCode'] when "0" then raise Trackerific::Error, parse_error_response(http_response) when "1" then return parse_success_response(http_response) else raise Trackerific::Error, "Invalid response code returned from server." @@ -63,19 +65,8 @@ r.RequestAction 'Track' end tr.TrackingNumber @package_id end return xml - end - - private - - class HTTP - include ::HTTParty - format :xml - base_uri case Rails.env - when 'test','development' then 'https://wwwcie.ups.com/ups.app/xml' - when 'production' then 'https://www.ups.com/ups.app/xml' - end end end end