Last active
December 10, 2015 00:18
-
-
Save Ergin008/4350022 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# API WALKTHROUGH #3 in Perl - Get Envelope Recipient Information | |
# | |
use strict; | |
use LWP 6.00; | |
use JSON; | |
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; | |
# Enter your info: | |
my $username = "***"; | |
my $password = "***"; | |
my $integratorKey = "***"; | |
my $envelopeId = "***"; | |
my $authHeader = '<DocuSignCredentials><Username>' . $username . '</Username>' . | |
'<Password>' . $password . '</Password>' . | |
'<IntegratorKey>' . $integratorKey . '</IntegratorKey></DocuSignCredentials>'; | |
###################################################################### | |
# STEP 1 - Login | |
###################################################################### | |
my $url = 'https://demo.docusign.net/restapi/v2/login_information'; | |
my $browser = LWP::UserAgent->new; | |
my @requestHeaders = ( | |
'X-DocuSign-Authentication' => $authHeader, | |
'Content-Type' => 'application/json', | |
'Accept' => 'application/json'); | |
my $response = $browser->get( $url, @requestHeaders ); | |
die "Error encountered during login request -- ", $response->status_line . "\n" | |
unless $response->is_success; | |
my $decoded_json = decode_json( $response->content ); | |
my $baseUrl = $decoded_json->{"loginAccounts"}[0]->{"baseUrl"}; | |
my $accountId = $decoded_json->{"loginAccounts"}[0]->{"accountId"}; | |
#-- display results | |
print "\nLogin successful...\nbaseUrl = " . $baseUrl . "\naccountId = " . $accountId . "\n"; | |
###################################################################### | |
# STEP 2 - Get Envelope Recipient(s) Info | |
###################################################################### | |
#append "/envelopes/" . $envelopeId . "/recipients" to $baseUrl and use in the next request | |
$url = $baseUrl . "/envelopes/" . $envelopeId . "/recipients"; | |
@requestHeaders = ( | |
'X-DocuSign-Authentication' => $authHeader); | |
my $req = HTTP::Request->new(GET => $url); | |
$req->header( @requestHeaders ); | |
$response = $browser->request( $req ); | |
die "Error encountered during login request -- ", $response->status_line | |
unless $response->is_success; | |
$decoded_json = decode_json( $response->content ); | |
my $firstSignerName = $decoded_json->{"signers"}[0]{"name"}; | |
my $firstSignerEmail = $decoded_json->{"signers"}[0]{"email"}; | |
my $firstSignerStatus = $decoded_json->{"signers"}[0]{"status"}; | |
#-- display results | |
print "\nSigner 1 info->\nname = $firstSignerName\nemail = $firstSignerEmail\nstatus = $firstSignerStatus\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment