File Coverage

blib/lib/Document/eSign/Docusign.pm
Criterion Covered Total %
statement 8 39 20.5
branch 0 8 0.0
condition n/a
subroutine 3 5 60.0
pod 1 1 100.0
total 12 53 22.6


line stmt bran cond sub pod time code
1             package Document::eSign::Docusign;
2              
3 1     1   17384 use 5.006;
  1         4  
4 1     1   3 use strict;
  1         1  
  1         22  
5 1     1   3 use warnings FATAL => 'all';
  1         4  
  1         436  
6              
7             =head1 NAME
8              
9             Document::eSign::Docusign - Provides an interface for Perl to the Docusign REST API.
10              
11             =head1 VERSION
12              
13             Version 0.04
14              
15             =cut
16              
17             our $VERSION = '0.05';
18             our @apicalls = qw{
19             login updatePassword
20             getToken getTokenOnBehalfOf
21             revokeToken requestSignatureFromTemplate
22             requestSignatureFromDocument requestSignatureFromComposite
23             changeEnvelopeStatus putDocumentDraftEnvelope
24             createRecipientDraftEnvelope openDocusignConsoleView
25             openDocusignCorrectEnvelopeView openDocusignSenderView
26             openDocusignRecipientView getStatusSinceDate
27             getStatusSinceDateUsingChangeType getStatusRangeDateUsingChangeType
28             getSearchFolders getEnvelope
29             getListOfEnvelopesInFolders
30             getEnvelopeRecipients addEnvelopeRecipients
31             editEnvelopeRecipients deleteEnvelopeRecipient
32             getRecipientTabs createRecipientTabs
33             modifyExistingRecipientTabs getEnvelopeAssets
34             getEnvelopeDocument getCombinedEnvelopeDocuments
35             deleteEnvelopeDocument getListOfTemplates
36             getUserProfile updateUserProfile
37             getUserProfileImage updateUserProfileImage
38             deleteUserProfileImage getSignatures
39             createUpdateSignatureName deleteSignatureName
40             getSignatureImage updateSignatureImage
41             getSignatureInitials updateSignatureInitials
42             deleteSignatureImage deleteInitialsImage
43             getUserSettings updateUserSettings
44             getSocialInformation putSocialInformation
45             deleteSocialInformation getAccountProvisioning
46             createAccount getAccountInfo
47             getBillingPlanForAccount deleteAccount
48             viewFolders getFolderItems
49             moveEnvelopeToFolder getRecipientNames
50             getAccountSettings getAccountCustomFields
51             getAccountTemplates getAccountTemplatesById
52             getAccountPermissionProfile createGroup
53             getAccountGroup getAccountUserList
54             addUsersToAccount deleteUsersFromAccount
55             getUnsupportedFileTypes postBrands
56             getBrands deleteBrands
57             distributorGetBillingPlans distributorGetBillingPlanById
58             getConnectConfiguration getConnectConfigurationById
59             postConnectionConfiguration putConnectConfiguration
60             deleteConnectConfiguration getConnectLog
61             getConnectLogById getConnectFailuresLog
62             getConnectFailureLogById deleteConnectLogs
63             deleteConnectLogById deleteConnectFailureLogById
64             putEnvelopesInRetryQueue putEnvelopeInRetryQueueById
65             buildCredentials sendRequest
66             };
67              
68             =head1 SYNOPSIS
69              
70             This module supplies Perl centric methods for accessing the Docusign API.
71              
72             Example:
73              
74             use Document::eSign::Docusign;
75              
76             my $ds = Document::eSign::Docusign->new(
77             baseUrl => 'https://demo.docusign.net/restapi',
78             username => 'username@domain.com',
79             password => 'yourloginpassword',
80             integratorkey => 'yourintegratorkeyfromdocusign'
81             );
82            
83             # The API has already called the "Login" portion of the API, you're ready to go:
84            
85             my $response = $ds->requestSignatureFromTemplate(
86             accountId => $ds->accountId, # Note that this is actually redundant.
87             emailSubject => 'You have a document to sign from ACME.com.',
88             emailBlurb => 'Here is the XYZ document for you to sign.',
89             customFields => {
90             textCustomFields => [
91             name => 'FIELDNAME',
92             value => 'value to place in field',
93             show => 'true',
94             required => 'true',
95             ]
96             },
97             templateId => 'templateId',
98             templateRoles => [
99             {
100             roleName => 'Signer1', # Description of the signer's role
101             name => 'Jane Smith',
102             email => 'jsmith@somedomain.com'
103             }, # Note that this is a list, so adding more roles creates more signatures.
104             ],
105             status => 'created', # One of sent or created.
106             eventNotification => {}, # Large object, see API docs for details.
107            
108            
109             );
110            
111             if ( defined $response->{error} ) {
112             die "Uh oh, we had an error: " . $response->{error};
113             }
114            
115             ...
116              
117             =head1 SUBROUTINES/METHODS
118              
119             =head2 new
120              
121             Sets up the connection to Docusign and performs the login function. You will need
122             to pass parameters, at a minimum the call should contain the following properties:
123              
124             =head3 username
125              
126             Should be set to your username for Docusign
127              
128             =head3 baseUrl
129              
130             Should be set to https://demo.docusign.net/restapi at a minimum. Ultimately will be
131             overwritten after login. The login call specifies the baseUrl that becomes the
132             default.
133              
134             =head3 password
135              
136             Your API password, same as your login password.
137              
138             =head3 integratorkey
139              
140             Assigned to you through Docusign's demo site.
141              
142             =cut
143              
144             sub new {
145 0     0 1   my $class = shift;
146 0           my $self = bless {}, $class;
147 0           my %vars = @_;
148            
149 0           while ( my ($key, $value) = each %vars ) {
150 0           eval { $self->$key($value) };
  0            
151             }
152            
153 0           $self->defaultUrl($self->baseUrl);
154            
155 0           $self->login(
156             {api_password => 'true',
157             include_account_id_guid => 'true',
158             login_settings => ''}
159             );
160            
161 0           return $self;
162             }
163              
164             =head2 API Calls
165              
166             This module attempts to stay true to the intent of the original API interface and
167             simply supplies an OO interface in perl to abstract the need to construct JSON and
168             web calls. It also uses all of the standard perl modules around these. Below is the
169             list of all of the calls. Simply using "perldoc Document::eSign::Docusign::apiCall"
170             will supply you with the examples for each of the calls. Each call returns a hashref
171             that contains the response JSON from Docusign. Errors are passed back with a single
172             reference $response->{error}. This will contain the status code and error as returned
173             from the webservice. Calls that are not yet implemented are marked with a *.
174              
175             updatePassword
176             getToken
177             getTokenOnBehalfOf
178             revokeToken
179             requestSignatureFromTemplate
180             requestSignatureFromDocument
181             requestSignatureFromComposite*
182             changeEnvelopeStatus
183             putDocumentDraftEnvelope*
184             createRecipientDraftEnvelope*
185             openDocusignConsoleView*
186             openDocusignCorrectEnvelopeView*
187             openDocusignSenderView*
188             openDocusignRecipientView*
189             getStatusSinceDate*
190             getStatusSinceDateUsingChangeType*
191             getStatusRangeDateUsingChangeType*
192             getSearchFolders*
193             getListOfEnvelopesInFolders
194             getEnvelope*
195             getEnvelopeRecipients
196             addEnvelopeRecipients*
197             editEnvelopeRecipients*
198             deleteEnvelopeRecipient*
199             getRecipientTabs
200             createRecipientTabs*
201             modifyExistingRecipientTabs*
202             getEnvelopeAssets*
203             getEnvelopeDocument*
204             getCombinedEnvelopeDocuments*
205             deleteEnvelopeDocument*
206             getListOfTemplates*
207             getUserProfile*
208             updateUserProfile*
209             getUserProfileImage*
210             updateUserProfileImage*
211             deleteUserProfileImage*
212             getSignatures*
213             createUpdateSignatureName*
214             deleteSignatureName*
215             getSignatureImage*
216             updateSignatureImage*
217             getSignatureInitials*
218             updateSignatureInitials*
219             deleteSignatureImage*
220             deleteInitialsImage*
221             getUserSettings*
222             updateUserSettings*
223             getSocialInformation*
224             putSocialInformation*
225             deleteSocialInformation*
226             getAccountProvisioning*
227             createAccount*
228             getAccountInfo*
229             getBillingPlanForAccount*
230             deleteAccount*
231             viewFolders*
232             getFolderItems*
233             moveEnvelopeToFolder*
234             getRecipientNames*
235             getAccountSettings*
236             getAccountCustomFields*
237             getAccountTemplates*
238             getAccountTemplatesById*
239             getAccountPermissionProfile*
240             createGroup*
241             getAccountGroup*
242             getAccountUserList*
243             addUsersToAccount*
244             deleteUsersFromAccount*
245             getUnsupportedFileTypes*
246             postBrands*
247             getBrands*
248             deleteBrands*
249             distributorGetBillingPlans*
250             distributorGetBillingPlanById*
251             getConnectConfiguration*
252             getConnectConfigurationById*
253             postConnectionConfiguration*
254             putConnectConfiguration*
255             deleteConnectConfiguration*
256             getConnectLog*
257             getConnectLogById*
258             getConnectFailuresLog*
259             getConnectFailureLogById*
260             deleteConnectLogs*
261             deleteConnectLogById*
262             deleteConnectFailureLogById*
263             putEnvelopesInRetryQueue*
264             putEnvelopeInRetryQueueById*
265              
266             =cut
267              
268             sub AUTOLOAD {
269 0     0     my $self = shift;
270            
271 0           our $AUTOLOAD;
272            
273 0           (my $method = $AUTOLOAD ) =~ s/.*:://;
274            
275             # Is the method part of an API call?
276            
277 0 0         if ( grep $_ eq $method, @apicalls ) {
278 0           my $module = __PACKAGE__ . "::" . $method;
279 0           my $direct = $module;
280 0           $direct =~ s/::/\//g;
281 0           for ( @INC ) {
282 0 0         if ( -f $_ . '/' . $direct . ".pm") {
283 0           $direct = $_ . '/' . $direct . '.pm';
284 0           last;
285             }
286            
287             }
288            
289 0 0         unless ( $direct =~ /.pm/ ) {
290 0           return "Unimplemented. :(";
291             }
292            
293            
294 0           eval {
295 0           require $direct;
296 0           $module->import();
297             };
298            
299 0           return $module->new($self, @_);
300             }
301            
302             # Nope, must be a getter/setter.
303            
304 0           my $value = shift;
305            
306 0           $method = lc $method;
307            
308 0 0         if ( defined $value ) {
309 0           $self->{args}->{$method} = $value;
310             }
311            
312            
313 0           return $self->{args}->{$method};
314            
315             }
316              
317             =head1 AUTHOR
318              
319             Tyler Hardison,
320             Gavin Henry, , Suretec Systems Ltd. T/A SureVoIP.
321              
322             =head1 BUGS
323              
324             Please report any bugs or feature requests to C, or through
325             the web interface at L. I will be notified, and then you'll
326             automatically be notified of progress on your bug as I make changes.
327              
328              
329              
330              
331             =head1 SUPPORT
332              
333             You can find documentation for this module with the perldoc command.
334              
335             perldoc Document::eSign::Docusign
336              
337              
338             You can also look for information at:
339              
340             =over 4
341              
342             =item * RT: CPAN's request tracker (report bugs here)
343              
344             L
345              
346             =item * AnnoCPAN: Annotated CPAN documentation
347              
348             L
349              
350             =item * CPAN Ratings
351              
352             L
353              
354             =item * Search CPAN
355              
356             L
357              
358             =back
359              
360              
361             =head1 ACKNOWLEDGEMENTS
362              
363              
364             =head1 LICENSE AND COPYRIGHT
365              
366             Copyright 2013 Tyler Hardison.
367             Copyright 2017 Gavin Henry, Suretec Systems Ltd. T/A SureVoIP.
368              
369             This program is free software; you can redistribute it and/or modify it
370             under the terms of the the Artistic License (2.0). You may obtain a
371             copy of the full license at:
372              
373             L
374              
375             Any use, modification, and distribution of the Standard or Modified
376             Versions is governed by this Artistic License. By using, modifying or
377             distributing the Package, you accept this license. Do not use, modify,
378             or distribute the Package, if you do not accept this license.
379              
380             If your Modified Version has been derived from a Modified Version made
381             by someone other than you, you are nevertheless required to ensure that
382             your Modified Version complies with the requirements of this license.
383              
384             This license does not grant you the right to use any trademark, service
385             mark, tradename, or logo of the Copyright Holder.
386              
387             This license includes the non-exclusive, worldwide, free-of-charge
388             patent license to make, have made, use, offer to sell, sell, import and
389             otherwise transfer the Package with respect to any patent claims
390             licensable by the Copyright Holder that are necessarily infringed by the
391             Package. If you institute patent litigation (including a cross-claim or
392             counterclaim) against any party alleging that the Package constitutes
393             direct or contributory patent infringement, then this Artistic License
394             to you shall terminate on the date that such litigation is filed.
395              
396             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
397             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
398             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
399             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
400             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
401             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
402             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
403             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
404              
405              
406             =cut
407              
408             1; # End of Document::eSign::Docusign