docusignsdk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/docusign.rb ADDED
@@ -0,0 +1,42 @@
1
+ # Copyright (C) DocuSign, Inc. All rights reserved.
2
+ #
3
+ # This source code is intended only as a supplement to DocuSign SDK
4
+ # and/or on-line documentation.
5
+ #
6
+ # This sample is designed to demonstrate DocuSign features and is not intended
7
+ # for production use. Code and policy for a production application must be
8
+ # developed to meet the specific data and security requirements of the
9
+ # application.
10
+ #
11
+ # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12
+ # KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14
+ # PARTICULAR PURPOSE.
15
+
16
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
17
+
18
+ gem 'soap4r'
19
+ require 'active_support'
20
+
21
+ require 'docusign/utilities'
22
+
23
+ require 'docusign/docusign'
24
+ require 'docusign/docusignMappingRegistry'
25
+ require 'docusign/docusignDriver'
26
+ require 'docusign/base'
27
+ require 'docusign/auth_header_handler'
28
+ require 'docusign/integrators_key_auth_header_handler'
29
+ require 'docusign/credential'
30
+ require 'docusign/credentialDriver'
31
+ require 'docusign/credentialMappingRegistry'
32
+
33
+ require 'docusign/document'
34
+ require 'docusign/tab'
35
+ require 'docusign/anchor_tab'
36
+ require 'docusign/request_recipient_token_client_urls'
37
+
38
+ require 'docusign/builder/base'
39
+ require 'docusign/builder/tab_builder'
40
+ require 'docusign/builder/anchor_builder'
41
+
42
+ require 'docusign/extensions'
@@ -0,0 +1,5 @@
1
+ module Docusign
2
+ class AnchorTab
3
+ alias_attribute :string, :anchorTabString
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ # Copyright (C) DocuSign, Inc. All rights reserved.
2
+ #
3
+ # This source code is intended only as a supplement to DocuSign SDK
4
+ # and/or on-line documentation.
5
+ #
6
+ # This sample is designed to demonstrate DocuSign features and is not intended
7
+ # for production use. Code and policy for a production application must be
8
+ # developed to meet the specific data and security requirements of the
9
+ # application.
10
+ #
11
+ # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12
+ # KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14
+ # PARTICULAR PURPOSE.
15
+
16
+ require 'soap/header/simplehandler'
17
+
18
+ module Docusign
19
+ class AuthHeaderHandler < SOAP::Header::SimpleHandler
20
+ NAMESPACE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
21
+
22
+ attr_accessor :attributes
23
+
24
+ def initialize(options={})
25
+ self.attributes = options
26
+
27
+ super(XSD::QName.new(NAMESPACE, 'Security'))
28
+ end
29
+
30
+ def on_simple_outbound
31
+ if attributes[:user_name] && attributes[:password]
32
+ {"UsernameToken" => {"Username" => attributes[:user_name], "Password" => attributes[:password]}}
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright (C) DocuSign, Inc. All rights reserved.
2
+ #
3
+ # This source code is intended only as a supplement to DocuSign SDK
4
+ # and/or on-line documentation.
5
+ #
6
+ # This sample is designed to demonstrate DocuSign features and is not intended
7
+ # for production use. Code and policy for a production application must be
8
+ # developed to meet the specific data and security requirements of the
9
+ # application.
10
+ #
11
+ # THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12
+ # KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14
+ # PARTICULAR PURPOSE.
15
+
16
+ module Docusign
17
+ class Base
18
+
19
+ class << self
20
+ def login(options={})
21
+
22
+ connection = Docusign::APIServiceSoap.new
23
+
24
+ if options[:integrators_key]
25
+ header = IntegratorsKeyAuthHeaderHandler.new(
26
+ :email => options.delete(:email),
27
+ :integrators_key => options.delete(:integrators_key),
28
+ :password => options.delete(:password)
29
+ )
30
+ else
31
+ header = AuthHeaderHandler.new(
32
+ :user_name => options.delete(:user_name),
33
+ :password => options.delete(:password)
34
+ )
35
+ end
36
+
37
+ connection.headerhandler << header
38
+
39
+ options.each do |key, value|
40
+ connection.send("#{key}=", value)
41
+ end
42
+
43
+ connection
44
+ end
45
+
46
+ def credentials(email, password, endpoint_url=nil)
47
+
48
+ connection = Docusign::Credential::CredentialSoap.new
49
+ connection.endpoint_url = endpoint_url if endpoint_url
50
+
51
+ connection.login(:email => email, :password => password).loginResult
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ module Docusign
2
+ module Builder
3
+ class AnchorBuilder < Docusign::Builder::Base
4
+ self.builder_class = Docusign::AnchorTab
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ module Docusign
2
+ module Builder
3
+ class Base
4
+ class << self
5
+ attr_accessor :builder_class
6
+ end
7
+
8
+ attr_accessor :object
9
+
10
+ def initialize(*args, &block); end
11
+
12
+ def build(options = {}, &block)
13
+ returning self.object = builder_class.new do |o|
14
+ options.each do |key, value|
15
+ o.send "#{key}=", value
16
+ end
17
+
18
+ yield o if block_given?
19
+ end
20
+ end
21
+
22
+ def builder_class
23
+ self.class.builder_class
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ require 'docusign'
2
+
3
+ module Docusign
4
+ module Builder
5
+ class TabBuilder < Docusign::Builder::Base
6
+ attr_accessor :document, :recipient
7
+
8
+ self.builder_class = Docusign::Tab
9
+
10
+ def initialize(document = nil, recipient = nil)
11
+ super
12
+ self.document, self.recipient = document, recipient
13
+ end
14
+
15
+ def build(options = {}, &block)
16
+ anchor_options = options.delete(:anchor)
17
+
18
+ returning super(options, &block) do |tab|
19
+ tab.anchor anchor_options if anchor_options && !tab.anchor_tab_item
20
+ tab.document_id ||= document.id if document
21
+ tab.recipient_id ||= recipient.id if recipient
22
+
23
+ # Default tab_label to the tab name if none is explicitly given
24
+ tab.tab_label ||= tab.name
25
+
26
+ # Provide a custom tab type if none has already been provided
27
+ tab.type ||= Docusign::TabTypeCode::Custom
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,196 @@
1
+ require 'xsd/qname'
2
+
3
+ module Docusign; module Credential
4
+
5
+
6
+ # {http://www.docusign.net/API/Credential}ArrayOfAccount
7
+ class ArrayOfAccount < ::Array
8
+
9
+ # {http://www.docusign.net/API/Credential}Account
10
+ # accountID - SOAP::SOAPString
11
+ # accountName - SOAP::SOAPString
12
+ # userID - SOAP::SOAPString
13
+ # userName - SOAP::SOAPString
14
+ # email - SOAP::SOAPString
15
+ class Account
16
+ attr_accessor :accountID
17
+ attr_accessor :accountName
18
+ attr_accessor :userID
19
+ attr_accessor :userName
20
+ attr_accessor :email
21
+
22
+ def initialize(accountID = nil, accountName = nil, userID = nil, userName = nil, email = nil)
23
+ @accountID = accountID
24
+ @accountName = accountName
25
+ @userID = userID
26
+ @userName = userName
27
+ @email = email
28
+ end
29
+ end
30
+ end
31
+
32
+ # {http://www.docusign.net/API/Credential}ErrorCode
33
+ class ErrorCode < ::String
34
+ Account_Lacks_Permissions = ErrorCode.new("Account_Lacks_Permissions")
35
+ Success = ErrorCode.new("Success")
36
+ Unspecified_Error = ErrorCode.new("Unspecified_Error")
37
+ User_Authentication_Failed = ErrorCode.new("User_Authentication_Failed")
38
+ User_Does_Not_Exist_In_System = ErrorCode.new("User_Does_Not_Exist_In_System")
39
+ User_Lacks_Permissions = ErrorCode.new("User_Lacks_Permissions")
40
+ end
41
+
42
+ # {http://www.docusign.net/API/Credential}Ping
43
+ class Ping
44
+ def initialize
45
+ end
46
+ end
47
+
48
+ # {http://www.docusign.net/API/Credential}PingResponse
49
+ # pingResult - SOAP::SOAPBoolean
50
+ class PingResponse
51
+ attr_accessor :pingResult
52
+
53
+ def initialize(pingResult = nil)
54
+ @pingResult = pingResult
55
+ end
56
+ end
57
+
58
+ # {http://www.docusign.net/API/Credential}Login
59
+ # email - SOAP::SOAPString
60
+ # password - SOAP::SOAPString
61
+ class Login
62
+ attr_accessor :email
63
+ attr_accessor :password
64
+
65
+ def initialize(email = nil, password = nil)
66
+ @email = email
67
+ @password = password
68
+ end
69
+ end
70
+
71
+ # {http://www.docusign.net/API/Credential}LoginResponse
72
+ # loginResult - Docusign::Credential::LoginResponse::LoginResult
73
+ class LoginResponse
74
+
75
+ # inner class for member: LoginResult
76
+ # {http://www.docusign.net/API/Credential}LoginResult
77
+ # success - SOAP::SOAPBoolean
78
+ # errorCode - Docusign::Credential::ErrorCode
79
+ # authenticationMessage - SOAP::SOAPString
80
+ # accounts - Docusign::Credential::ArrayOfAccount
81
+ class LoginResult
82
+ attr_accessor :success
83
+ attr_accessor :errorCode
84
+ attr_accessor :authenticationMessage
85
+ attr_accessor :accounts
86
+
87
+ def initialize(success = nil, errorCode = nil, authenticationMessage = nil, accounts = nil)
88
+ @success = success
89
+ @errorCode = errorCode
90
+ @authenticationMessage = authenticationMessage
91
+ @accounts = accounts
92
+ end
93
+ end
94
+
95
+ attr_accessor :loginResult
96
+
97
+ def initialize(loginResult = nil)
98
+ @loginResult = loginResult
99
+ end
100
+ end
101
+
102
+ # {http://www.docusign.net/API/Credential}GetAuthenticationToken
103
+ # email - SOAP::SOAPString
104
+ # password - SOAP::SOAPString
105
+ # accountID - SOAP::SOAPString
106
+ # goToEnvelopeID - SOAP::SOAPString
107
+ class GetAuthenticationToken
108
+ attr_accessor :email
109
+ attr_accessor :password
110
+ attr_accessor :accountID
111
+ attr_accessor :goToEnvelopeID
112
+
113
+ def initialize(email = nil, password = nil, accountID = nil, goToEnvelopeID = nil)
114
+ @email = email
115
+ @password = password
116
+ @accountID = accountID
117
+ @goToEnvelopeID = goToEnvelopeID
118
+ end
119
+ end
120
+
121
+ # {http://www.docusign.net/API/Credential}GetAuthenticationTokenResponse
122
+ # getAuthenticationTokenResult - SOAP::SOAPString
123
+ class GetAuthenticationTokenResponse
124
+ attr_accessor :getAuthenticationTokenResult
125
+
126
+ def initialize(getAuthenticationTokenResult = nil)
127
+ @getAuthenticationTokenResult = getAuthenticationTokenResult
128
+ end
129
+ end
130
+
131
+ # {http://www.docusign.net/API/Credential}RequestSenderToken
132
+ # email - SOAP::SOAPString
133
+ # password - SOAP::SOAPString
134
+ # accountID - SOAP::SOAPString
135
+ # envelopeID - SOAP::SOAPString
136
+ # returnURL - SOAP::SOAPString
137
+ class RequestSenderToken
138
+ attr_accessor :email
139
+ attr_accessor :password
140
+ attr_accessor :accountID
141
+ attr_accessor :envelopeID
142
+ attr_accessor :returnURL
143
+
144
+ def initialize(email = nil, password = nil, accountID = nil, envelopeID = nil, returnURL = nil)
145
+ @email = email
146
+ @password = password
147
+ @accountID = accountID
148
+ @envelopeID = envelopeID
149
+ @returnURL = returnURL
150
+ end
151
+ end
152
+
153
+ # {http://www.docusign.net/API/Credential}RequestSenderTokenResponse
154
+ # requestSenderTokenResult - SOAP::SOAPString
155
+ class RequestSenderTokenResponse
156
+ attr_accessor :requestSenderTokenResult
157
+
158
+ def initialize(requestSenderTokenResult = nil)
159
+ @requestSenderTokenResult = requestSenderTokenResult
160
+ end
161
+ end
162
+
163
+ # {http://www.docusign.net/API/Credential}RequestCorrectToken
164
+ # email - SOAP::SOAPString
165
+ # password - SOAP::SOAPString
166
+ # envelopeID - SOAP::SOAPString
167
+ # suppressNavigation - SOAP::SOAPBoolean
168
+ # returnURL - SOAP::SOAPString
169
+ class RequestCorrectToken
170
+ attr_accessor :email
171
+ attr_accessor :password
172
+ attr_accessor :envelopeID
173
+ attr_accessor :suppressNavigation
174
+ attr_accessor :returnURL
175
+
176
+ def initialize(email = nil, password = nil, envelopeID = nil, suppressNavigation = nil, returnURL = nil)
177
+ @email = email
178
+ @password = password
179
+ @envelopeID = envelopeID
180
+ @suppressNavigation = suppressNavigation
181
+ @returnURL = returnURL
182
+ end
183
+ end
184
+
185
+ # {http://www.docusign.net/API/Credential}RequestCorrectTokenResponse
186
+ # requestCorrectTokenResult - SOAP::SOAPString
187
+ class RequestCorrectTokenResponse
188
+ attr_accessor :requestCorrectTokenResult
189
+
190
+ def initialize(requestCorrectTokenResult = nil)
191
+ @requestCorrectTokenResult = requestCorrectTokenResult
192
+ end
193
+ end
194
+
195
+
196
+ end; end
@@ -0,0 +1,83 @@
1
+ require 'docusign/credential.rb'
2
+ require 'docusign/credentialMappingRegistry.rb'
3
+ require 'soap/rpc/driver'
4
+
5
+ module Docusign::Credential
6
+
7
+ class CredentialSoap < ::SOAP::RPC::Driver
8
+ DefaultEndpointUrl = "https://demo.docusign.net/api/3.0/credential.asmx"
9
+
10
+ Methods = [
11
+ [ "http://www.docusign.net/API/Credential/Ping",
12
+ "ping",
13
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "Ping"]],
14
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "PingResponse"]] ],
15
+ { :request_style => :document, :request_use => :literal,
16
+ :response_style => :document, :response_use => :literal,
17
+ :faults => {} }
18
+ ],
19
+ [ "http://www.docusign.net/API/Credential/Login",
20
+ "login",
21
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "Login"]],
22
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "LoginResponse"]] ],
23
+ { :request_style => :document, :request_use => :literal,
24
+ :response_style => :document, :response_use => :literal,
25
+ :faults => {} }
26
+ ],
27
+ [ "http://www.docusign.net/API/Credential/GetAuthenticationToken",
28
+ "getAuthenticationToken",
29
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "GetAuthenticationToken"]],
30
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "GetAuthenticationTokenResponse"]] ],
31
+ { :request_style => :document, :request_use => :literal,
32
+ :response_style => :document, :response_use => :literal,
33
+ :faults => {} }
34
+ ],
35
+ [ "http://www.docusign.net/API/Credential/RequestSenderToken",
36
+ "requestSenderToken",
37
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "RequestSenderToken"]],
38
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "RequestSenderTokenResponse"]] ],
39
+ { :request_style => :document, :request_use => :literal,
40
+ :response_style => :document, :response_use => :literal,
41
+ :faults => {} }
42
+ ],
43
+ [ "http://www.docusign.net/API/Credential/RequestCorrectToken",
44
+ "requestCorrectToken",
45
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "RequestCorrectToken"]],
46
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "RequestCorrectTokenResponse"]] ],
47
+ { :request_style => :document, :request_use => :literal,
48
+ :response_style => :document, :response_use => :literal,
49
+ :faults => {} }
50
+ ]
51
+ ]
52
+
53
+ def initialize(endpoint_url = nil)
54
+ endpoint_url ||= DefaultEndpointUrl
55
+ super(endpoint_url, nil)
56
+ self.mapping_registry = DefaultMappingRegistry::EncodedRegistry
57
+ self.literal_mapping_registry = DefaultMappingRegistry::LiteralRegistry
58
+ init_methods
59
+ end
60
+
61
+ private
62
+
63
+ def init_methods
64
+ Methods.each do |definitions|
65
+ opt = definitions.last
66
+ if opt[:request_style] == :document
67
+ add_document_operation(*definitions)
68
+ else
69
+ add_rpc_operation(*definitions)
70
+ qname = definitions[0]
71
+ name = definitions[2]
72
+ if qname.name != name and qname.name.capitalize == name.capitalize
73
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
74
+ __send__(name, *arg)
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+
83
+ end