Class: DocuSign::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/docu_sign/client.rb

Constant Summary collapse

CACERT =

A CA file used to verify certificates when connecting to Adyen.

File.expand_path('../cacert.pem', __FILE__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



60
61
62
# File 'lib/docu_sign/client.rb', line 60

def initialize(options={})
  self.client = self.class.(options)
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

#clientObject

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.(:email => email, :password => password).
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 (options={})

  client  = Savon::Client.new do |wsdl, http|
    wsdl.document = File.expand_path("../../../wsdl/dsapi.wsdl", __FILE__)
    wsdl.endpoint = options[:endpoint_url] if options[: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 options[:integrator_key]
    client.wsse.credentials "[#{options[:integrator_key]}]#{options[:username]}", options[:password]
    client.http.headers["X-DocuSign-Authentication"] = "<DocuSignCredentials><Username>#{options[:username]}</Username><Password>#{options[:password]}</Password><IntegratorKey>#{options[: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