class DIDWW::Client
Constants
- METHOD_TRANSLATIONS
key is method used by this api wrapper, value is method used by DIDWW's SOAP api
- UNIQUE_HASH_METHODS
Attributes
configuration[R]
methods[R]
Public Class Methods
new()
click to toggle source
# File lib/DIDWW/client.rb, line 42 def initialize @configuration = DIDWW.configuration @savon = savon_client @methods = METHOD_TRANSLATIONS.keys end
Public Instance Methods
method_missing(method_name, *args, &block)
click to toggle source
# File lib/DIDWW/client.rb, line 48 def method_missing(method_name, *args, &block) if methods.include? method_name params = (args.first || {}).merge(auth_string: auth_string) params.merge!(uniq_hash: (Time.now.to_i.to_s + auth_string)) if UNIQUE_HASH_METHODS.include?(method_name) @savon.call METHOD_TRANSLATIONS[method_name], message: params else raise NoMethodError, "#{method_name} is not a valid api endpoint!" end end
Private Instance Methods
auth_string()
click to toggle source
# File lib/DIDWW/client.rb, line 65 def auth_string string = configuration.api_username + configuration.api_key string += 'sandbox' if configuration.sandbox Digest::SHA1.hexdigest(string) end
live_url()
click to toggle source
# File lib/DIDWW/client.rb, line 75 def live_url 'https://api.didww.com/api2/?wsdl' end
sandbox_url()
click to toggle source
# File lib/DIDWW/client.rb, line 71 def sandbox_url 'https://sandbox-api.didww.com/api2/index.php?wsdl' end
savon_client()
click to toggle source
# File lib/DIDWW/client.rb, line 60 def savon_client wsdl = configuration.sandbox ? sandbox_url : live_url Savon::Client.new wsdl: wsdl end