| 1 | package Document::eSign::Docusign::buildCredentials; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | # Builds the auth credentials. | ||||||||||
| 8 | |||||||||||
| 9 | =head1 NAME | ||||||||||
| 10 | |||||||||||
| 11 | Document::eSign::Docusign::buildCredentials - Builds the credentials object. | ||||||||||
| 12 | |||||||||||
| 13 | =head1 VERSION | ||||||||||
| 14 | |||||||||||
| 15 | Version 0.02 | ||||||||||
| 16 | |||||||||||
| 17 | =head1 functions | ||||||||||
| 18 | |||||||||||
| 19 | =head2 new($parent) | ||||||||||
| 20 | |||||||||||
| 21 | Builds an XML or JSON login string for the Docusign header. Setting "usejsononly" to a non-undef (null) in the constructor determines this behavior. | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 26 | 0 | my $class = shift; | |||||||||
| 27 | 0 | my $main = shift; | |||||||||
| 28 | 0 | my $self = bless {}, $class; | |||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | if (defined $main->authxml) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | return $main->authxml; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | if ( $main->usejsononly ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | my $json = JSON->new(); | |||||||||
| 36 | |||||||||||
| 37 | 0 | $main->authxml($json->encode( | |||||||||
| 38 | { | ||||||||||
| 39 | Username => $main->username, | ||||||||||
| 40 | Password => $main->password, | ||||||||||
| 41 | IntegratorKey => $main->IntegratorKey, | ||||||||||
| 42 | usejsononly => 1 | ||||||||||
| 43 | } | ||||||||||
| 44 | )); | ||||||||||
| 45 | 0 | return $main->authxml; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 0 | my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); | |||||||||
| 50 | 0 | my $base = $doc->createElement('DocuSignCredentials'); | |||||||||
| 51 | 0 | my $username = $doc->createElement('Username'); | |||||||||
| 52 | 0 | $username->appendText($main->username); | |||||||||
| 53 | 0 | my $password = $doc->createElement('Password'); | |||||||||
| 54 | 0 | $password->appendText($main->password); | |||||||||
| 55 | 0 | my $intkey = $doc->createElement('IntegratorKey'); | |||||||||
| 56 | 0 | $intkey->appendText($main->integratorkey); | |||||||||
| 57 | |||||||||||
| 58 | 0 | $base->appendChild($username); | |||||||||
| 59 | 0 | $base->appendChild($password); | |||||||||
| 60 | 0 | $base->appendChild($intkey); | |||||||||
| 61 | |||||||||||
| 62 | 0 | $main->authxml($base->toString()); | |||||||||
| 63 | |||||||||||
| 64 | 0 | return $main->authxml; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||