docusign 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
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/credential'
29
+ require 'docusign/credentialDriver'
30
+ require 'docusign/credentialMappingRegistry'
31
+
32
+ require 'docusign/document'
33
+ require 'docusign/tab'
34
+ require 'docusign/anchor_tab'
35
+
36
+ require 'docusign/builder/base'
37
+ require 'docusign/builder/tab_builder'
38
+ require 'docusign/builder/anchor_builder'
39
+
40
+ 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,46 @@
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
+ header = AuthHeaderHandler.new(
24
+ :user_name => options.delete(:user_name),
25
+ :password => options.delete(:password)
26
+ )
27
+
28
+ connection.headerhandler << header
29
+
30
+ options.each do |key, value|
31
+ connection.send("#{key}=", value)
32
+ end
33
+
34
+ connection
35
+ end
36
+
37
+ def credentials(email, password, endpoint_url=nil)
38
+
39
+ connection = Docusign::Credential::CredentialSoap.new
40
+ connection.endpoint_url = endpoint_url if endpoint_url
41
+
42
+ connection.login(:email => email, :password => password).loginResult
43
+ end
44
+ end
45
+ end
46
+ 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,26 @@
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
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,136 @@
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
+
94
+ def success?
95
+ @success
96
+ end
97
+ end
98
+
99
+ attr_accessor :loginResult
100
+
101
+ def initialize(loginResult = nil)
102
+ @loginResult = loginResult
103
+ end
104
+ end
105
+
106
+ # {http://www.docusign.net/API/Credential}GetAuthenticationToken
107
+ # email - SOAP::SOAPString
108
+ # password - SOAP::SOAPString
109
+ # accountID - SOAP::SOAPString
110
+ # goToEnvelopeID - SOAP::SOAPString
111
+ class GetAuthenticationToken
112
+ attr_accessor :email
113
+ attr_accessor :password
114
+ attr_accessor :accountID
115
+ attr_accessor :goToEnvelopeID
116
+
117
+ def initialize(email = nil, password = nil, accountID = nil, goToEnvelopeID = nil)
118
+ @email = email
119
+ @password = password
120
+ @accountID = accountID
121
+ @goToEnvelopeID = goToEnvelopeID
122
+ end
123
+ end
124
+
125
+ # {http://www.docusign.net/API/Credential}GetAuthenticationTokenResponse
126
+ # getAuthenticationTokenResult - SOAP::SOAPString
127
+ class GetAuthenticationTokenResponse
128
+ attr_accessor :getAuthenticationTokenResult
129
+
130
+ def initialize(getAuthenticationTokenResult = nil)
131
+ @getAuthenticationTokenResult = getAuthenticationTokenResult
132
+ end
133
+ end
134
+
135
+
136
+ end; end
@@ -0,0 +1,65 @@
1
+ require 'soap/rpc/driver'
2
+
3
+ module Docusign::Credential
4
+
5
+ class CredentialSoap < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "https://demo.docusign.net/api/3.0/Credential.asmx"
7
+
8
+ Methods = [
9
+ [ "http://www.docusign.net/API/Credential/Ping",
10
+ "ping",
11
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "Ping"]],
12
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "PingResponse"]] ],
13
+ { :request_style => :document, :request_use => :literal,
14
+ :response_style => :document, :response_use => :literal,
15
+ :faults => {} }
16
+ ],
17
+ [ "http://www.docusign.net/API/Credential/Login",
18
+ "login",
19
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "Login"]],
20
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "LoginResponse"]] ],
21
+ { :request_style => :document, :request_use => :literal,
22
+ :response_style => :document, :response_use => :literal,
23
+ :faults => {} }
24
+ ],
25
+ [ "http://www.docusign.net/API/Credential/GetAuthenticationToken",
26
+ "getAuthenticationToken",
27
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "GetAuthenticationToken"]],
28
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://www.docusign.net/API/Credential", "GetAuthenticationTokenResponse"]] ],
29
+ { :request_style => :document, :request_use => :literal,
30
+ :response_style => :document, :response_use => :literal,
31
+ :faults => {} }
32
+ ]
33
+ ]
34
+
35
+ def initialize(endpoint_url = nil)
36
+ endpoint_url ||= DefaultEndpointUrl
37
+ super(endpoint_url, nil)
38
+ self.mapping_registry = DefaultMappingRegistry::EncodedRegistry
39
+ self.literal_mapping_registry = DefaultMappingRegistry::LiteralRegistry
40
+ init_methods
41
+ end
42
+
43
+ private
44
+
45
+ def init_methods
46
+ Methods.each do |definitions|
47
+ opt = definitions.last
48
+ if opt[:request_style] == :document
49
+ add_document_operation(*definitions)
50
+ else
51
+ add_rpc_operation(*definitions)
52
+ qname = definitions[0]
53
+ name = definitions[2]
54
+ if qname.name != name and qname.name.capitalize == name.capitalize
55
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
56
+ __send__(name, *arg)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,128 @@
1
+ require 'soap/mapping'
2
+
3
+ module Docusign; module Credential
4
+
5
+ module DefaultMappingRegistry
6
+ EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new
7
+ LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new
8
+ NsCredential = "http://www.docusign.net/API/Credential"
9
+
10
+ EncodedRegistry.register(
11
+ :class => Docusign::Credential::ArrayOfAccount,
12
+ :schema_type => XSD::QName.new(NsCredential, "ArrayOfAccount"),
13
+ :schema_element => [
14
+ ["account", ["Docusign::Credential::ArrayOfAccount::Account[]", XSD::QName.new(NsCredential, "Account")], [0, nil]]
15
+ ]
16
+ )
17
+
18
+ EncodedRegistry.register(
19
+ :class => Docusign::Credential::ArrayOfAccount::Account,
20
+ :schema_name => XSD::QName.new(NsCredential, "Account"),
21
+ :is_anonymous => true,
22
+ :schema_qualified => true,
23
+ :schema_element => [
24
+ ["accountID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AccountID")], [0, 1]],
25
+ ["accountName", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AccountName")], [0, 1]],
26
+ ["userID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "UserID")], [0, 1]],
27
+ ["userName", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "UserName")], [0, 1]],
28
+ ["email", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Email")], [0, 1]]
29
+ ]
30
+ )
31
+
32
+ EncodedRegistry.register(
33
+ :class => Docusign::Credential::ErrorCode,
34
+ :schema_type => XSD::QName.new(NsCredential, "ErrorCode")
35
+ )
36
+
37
+ LiteralRegistry.register(
38
+ :class => Docusign::Credential::ArrayOfAccount,
39
+ :schema_type => XSD::QName.new(NsCredential, "ArrayOfAccount"),
40
+ :schema_element => [
41
+ ["account", ["Docusign::Credential::ArrayOfAccount::Account[]", XSD::QName.new(NsCredential, "Account")], [0, nil]]
42
+ ]
43
+ )
44
+
45
+ LiteralRegistry.register(
46
+ :class => Docusign::Credential::ArrayOfAccount::Account,
47
+ :schema_name => XSD::QName.new(NsCredential, "Account"),
48
+ :is_anonymous => true,
49
+ :schema_qualified => true,
50
+ :schema_element => [
51
+ ["accountID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AccountID")], [0, 1]],
52
+ ["accountName", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AccountName")], [0, 1]],
53
+ ["userID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "UserID")], [0, 1]],
54
+ ["userName", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "UserName")], [0, 1]],
55
+ ["email", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Email")], [0, 1]]
56
+ ]
57
+ )
58
+
59
+ LiteralRegistry.register(
60
+ :class => Docusign::Credential::ErrorCode,
61
+ :schema_type => XSD::QName.new(NsCredential, "ErrorCode")
62
+ )
63
+
64
+ LiteralRegistry.register(
65
+ :class => Docusign::Credential::Ping,
66
+ :schema_name => XSD::QName.new(NsCredential, "Ping"),
67
+ :schema_element => []
68
+ )
69
+
70
+ LiteralRegistry.register(
71
+ :class => Docusign::Credential::PingResponse,
72
+ :schema_name => XSD::QName.new(NsCredential, "PingResponse"),
73
+ :schema_element => [
74
+ ["pingResult", ["SOAP::SOAPBoolean", XSD::QName.new(NsCredential, "PingResult")]]
75
+ ]
76
+ )
77
+
78
+ LiteralRegistry.register(
79
+ :class => Docusign::Credential::Login,
80
+ :schema_name => XSD::QName.new(NsCredential, "Login"),
81
+ :schema_element => [
82
+ ["email", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Email")], [0, 1]],
83
+ ["password", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Password")], [0, 1]]
84
+ ]
85
+ )
86
+
87
+ LiteralRegistry.register(
88
+ :class => Docusign::Credential::LoginResponse,
89
+ :schema_name => XSD::QName.new(NsCredential, "LoginResponse"),
90
+ :schema_element => [
91
+ ["loginResult", ["Docusign::Credential::LoginResponse::LoginResult", XSD::QName.new(NsCredential, "LoginResult")], [0, 1]]
92
+ ]
93
+ )
94
+
95
+ LiteralRegistry.register(
96
+ :class => Docusign::Credential::LoginResponse::LoginResult,
97
+ :schema_name => XSD::QName.new(NsCredential, "LoginResult"),
98
+ :is_anonymous => true,
99
+ :schema_qualified => true,
100
+ :schema_element => [
101
+ ["success", ["SOAP::SOAPBoolean", XSD::QName.new(NsCredential, "Success")]],
102
+ ["errorCode", ["Docusign::Credential::ErrorCode", XSD::QName.new(NsCredential, "ErrorCode")], [0, 1]],
103
+ ["authenticationMessage", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AuthenticationMessage")], [0, 1]],
104
+ ["accounts", ["Docusign::Credential::ArrayOfAccount", XSD::QName.new(NsCredential, "Accounts")], [0, 1]]
105
+ ]
106
+ )
107
+
108
+ LiteralRegistry.register(
109
+ :class => Docusign::Credential::GetAuthenticationToken,
110
+ :schema_name => XSD::QName.new(NsCredential, "GetAuthenticationToken"),
111
+ :schema_element => [
112
+ ["email", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Email")], [0, 1]],
113
+ ["password", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "Password")], [0, 1]],
114
+ ["accountID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "AccountID")], [0, 1]],
115
+ ["goToEnvelopeID", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "GoToEnvelopeID")], [0, 1]]
116
+ ]
117
+ )
118
+
119
+ LiteralRegistry.register(
120
+ :class => Docusign::Credential::GetAuthenticationTokenResponse,
121
+ :schema_name => XSD::QName.new(NsCredential, "GetAuthenticationTokenResponse"),
122
+ :schema_element => [
123
+ ["getAuthenticationTokenResult", ["SOAP::SOAPString", XSD::QName.new(NsCredential, "GetAuthenticationTokenResult")], [0, 1]]
124
+ ]
125
+ )
126
+ end
127
+
128
+ end; end