#puts "REQUIRING: #{Dir[__FILE__]}" [ "g4s/shipping/default", "g4s/shipping/defaultDriver", "g4s/shipping/defaultMappingRegistry", #"g4s/shipping/IPSShippingClient", "g4s/tracking/default", "g4s/tracking/defaultDriver", #"g4s/tracking/IPSTrackingClient", "g4s/tracking/defaultMappingRegistry", "g4s/utilities/default", "g4s/utilities/defaultDriver", #"g4s/utilities/IPSUtilitiesClient", "g4s/utilities/defaultMappingRegistry", "g4s/g4s", "g4s/g4si_auth_header", "version"].each{|f| require f} module G4sClient CONFIG = YAML.load( ENV['G4S_CONFIG'] || File.read(Rails.root + 'config' + 'g4s.yml') ) class Shipping attr_reader :service def initialize(endpoint=nil) @endpoint = endpoint || ENV['G4S_SHIPPING_ENDPOINT_URL'] @service = ::Shipping::IPSShippingSoap.new(@endpoint) @service.headerhandler << G4SIAuthHeader.new(auth.username, auth.password, auth.accessKey) # Add the Authentication to the handler end end class ShippingTest < G4sClient::Shipping def initialize; super("https://wsuat.g4si.com/IPSutilities.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['test']['username'], CONFIG['test']['password'], CONFIG['test']['access_key']); end #TODO: dry end class ShippingLive < G4sClient::Shipping def initialize; super("https://ws.g4si.com/IPSutilities.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['live']['username'], CONFIG['live']['password'], CONFIG['live']['access_key']); end end class Tracking attr_reader :service def initialize(endpoint=nil) @endpoint = endpoint || ENV['G4S_TRACKING_ENDPOINT_URL'] @service = ::Tracking::IPSTrackingSoap.new(@endpoint) @service.headerhandler << G4SIAuthHeader.new(auth.username, auth.password, auth.accessKey) # Add the Authentication to the handler end end class TrackingTest < G4sClient::Tracking def initialize; super("https://wsuat.g4si.com/IPStracking.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['test']['username'], CONFIG['test']['password'], CONFIG['test']['access_key']); end end class TrackingLive < G4sClient::Tracking def initialize; super("https://ws.g4si.com/IPStracking.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['live']['username'], CONFIG['live']['password'], CONFIG['live']['access_key']); end end class Utilities attr_reader :service def initialize(endpoint=nil) @endpoint = endpoint || ENV['G4S_UTILITIES_ENDPOINT_URL'] @service = ::Utilities::IPSUtilitiesSoap.new(@endpoint) @service.headerhandler << G4SIAuthHeader.new(auth.username, auth.password, auth.accessKey) # Add the Authentication to the handler end end class UtilitiesTest < G4sClient::Utilities def initialize; super("https://wsuat.g4si.com/IPSutilities.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['test']['username'], CONFIG['test']['password'], CONFIG['test']['access_key']); end end class UtilitiesLive < G4sClient::Utilities def initialize; super("https://ws.g4si.com/IPSutilities.asmx"); end def auth; @authentication ||= G4SIAuthentication.new(CONFIG['live']['username'], CONFIG['live']['password'], CONFIG['live']['access_key']); end end end