class DocuSign::Client

Constants

CACERT

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

@see curl.haxx.se/ca/cacert.pem

Attributes

client[RW]

Public Class Methods

credentials(email, password, endpoint_url=nil) click to toggle source
# 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={}) click to toggle source
# File lib/docu_sign/client.rb, line 11
def login(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
new(options={}) click to toggle source
# File lib/docu_sign/client.rb, line 60
def initialize(options={})
  self.client = self.class.login(options)
end

Private Instance Methods

camelize_key(k) click to toggle source
# File lib/docu_sign/client.rb, line 81
def camelize_key(k)
  k.to_s.gsub(/(^|_)(id)($|_)/){ $2.upcase }.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
end
convert_hash_keys(value) click to toggle source
# File lib/docu_sign/client.rb, line 85
def convert_hash_keys(value)
  case value
  when Array
    value.map { |v| convert_hash_keys(v) }
    # or `value.map(&method(:convert_hash_keys))`
  when Hash
    Hash[value.map { |k, v| [camelize_key(k), convert_hash_keys(v)] }]
  else
    value
  end
end