Class: DocuSign::Client
- Inherits:
-
Object
- Object
- DocuSign::Client
- Defined in:
- lib/docu_sign/client.rb
Constant Summary collapse
- CACERT =
A CA file used to verify certificates when connecting to Adyen.
File.('../cacert.pem', __FILE__)
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(api_method, *args, &block) ⇒ Object
:nodoc:.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
60 61 62 |
# File 'lib/docu_sign/client.rb', line 60 def initialize(={}) self.client = self.class.login() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(api_method, *args, &block) ⇒ Object
:nodoc:
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/docu_sign/client.rb', line 64 def method_missing(api_method, *args, &block) # :nodoc: if self.client.wsdl.soap_actions.include?(api_method) begin response = self.client.request(api_method) do soap.body = (args.first.respond_to?(:to_savon) ? args.first.to_savon : convert_hash_keys(args.first)) if args.first end return DocuSignResponse.new(response) rescue Savon::SOAP::Fault => e raise DocuSign::Error.new(e) end else super end end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/docu_sign/client.rb', line 3 def client @client end |
Class Method Details
.credentials(email, password, endpoint_url = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/docu_sign/client.rb', line 51 def credentials(email, password, endpoint_url=nil) connection = DocuSign::Credential::CredentialSoap.new connection.endpoint_url = endpoint_url if endpoint_url connection.login(:email => email, :password => password).login_result end |
.login(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/docu_sign/client.rb', line 11 def login(={}) client = Savon::Client.new do |wsdl, http| wsdl.document = File.("../../../wsdl/dsapi.wsdl", __FILE__) wsdl.endpoint = [:endpoint_url] if [:endpoint_url] #http.auth.ssl.ca_cert_file = CACERT http.auth.ssl.verify_mode = :none http.open_timeout = 1200 http.read_timeout = 1200 end if [:integrator_key] client.wsse.credentials "[#{[:integrator_key]}]#{[:username]}", [:password] client.http.headers["X-DocuSign-Authentication"] = "<DocuSignCredentials><Username>#{[:username]}</Username><Password>#{[:password]}</Password><IntegratorKey>#{[:integrator_key]}</IntegratorKey></DocuSignCredentials>" end # if options[:integrators_key] # header = IntegratorsKeyAuthHeaderHandler.new( # :email => options.delete(:email), # :integrators_key => options.delete(:integrators_key), # :password => options.delete(:password) # ) # else # header = AuthHeaderHandler.new( # :user_name => options.delete(:user_name), # :password => options.delete(:password) # ) # end # # connection.headerhandler << header # # options.each do |key, value| # connection.send("#{key}=", value) # end client end |