@@ -28,7 +28,9 @@ var basePath = restApi.BasePath.DEMO;
2828var oAuthBasePath = oAuth . BasePath . DEMO ;
2929
3030var SignTest1File = 'docs/SignTest1.pdf' ;
31+ var LargeTestDocument1 = 'docs/LargeTestDocument1.pdf' ;
3132var brandLogoPath = 'img/docusign-lgo.png' ;
33+ var brandXmlPath = 'docs/brand.xml' ;
3234var accountId = '' ;
3335var envelopeId = '' ;
3436var userId = config . userId ;
@@ -427,14 +429,11 @@ describe('SDK Unit Tests:', function (done) {
427429 if ( envelopeSummary ) {
428430 console . log ( 'EnvelopeSummary: ' + JSON . stringify ( envelopeSummary ) ) ;
429431 envelopeId = envelopeSummary . envelopeId ;
430- console . log ( 'starwars' ) ;
431432 console . log ( bulkRecipients ) ;
432433 csvStringify ( bulkRecipients , { header : true } , function ( err , bulkRecipientsRequest ) {
433434 if ( err ) {
434435 return done ( err ) ;
435436 }
436- console . log ( 'starwars2' ) ;
437-
438437 console . log ( bulkRecipientsRequest ) ;
439438 var byteArray = Buffer . from ( bulkRecipientsRequest ) ;
440439 console . log ( byteArray ) ;
@@ -671,7 +670,7 @@ describe('SDK Unit Tests:', function (done) {
671670 try {
672671 var fs = require ( 'fs' ) ;
673672 // read file from a local directory
674- fileBytes = fs . readFileSync ( path . resolve ( __dirname , SignTest1File ) ) ;
673+ fileBytes = fs . readFileSync ( path . resolve ( __dirname , LargeTestDocument1 ) ) ;
675674 } catch ( ex ) {
676675 // handle error
677676 console . log ( 'Exception: ' + ex ) ;
@@ -823,6 +822,38 @@ describe('SDK Unit Tests:', function (done) {
823822 return done ( error ) ;
824823 } ) ;
825824 } ) ;
825+
826+ // it('listStatusChangesOptions 70 envelopeIds', function (done) {
827+ // console.log('starwars')
828+ //
829+ // var envelopesApi = new docusign.EnvelopesApi(apiClient);
830+ // var THIRTY_DAYS_AGO = new Date(new Date().setDate(new Date().getDate()-30));
831+ //
832+ // var options = {
833+ // count: "70", fromDate: THIRTY_DAYS_AGO
834+ // };
835+ // envelopesApi.listStatusChanges(accountId, options)
836+ // .then(function (data) {
837+ // var envelopIds = data.envelopes.reduce( function( acc, envelope ) {
838+ // if (!acc.length) return envelope.envelopeId;
839+ // return acc + ', ' + envelope.envelopeId;
840+ // }, '');
841+ // console.log(envelopIds);
842+ // envelopesApi.listStatusChanges(accountId, {envelopeIds: envelopIds})
843+ // .then( function(data) {
844+ // assert.notEqual(data.envelopes, undefined);
845+ // assert.notEqual(data.envelopes[0].attachmentsUri, undefined);
846+ // assert.notEqual(data.envelopes[0].statusChangedDateTime, undefined);
847+ // done();
848+ // }).catch(function (error, resp) {
849+ // return done(error);
850+ // });;
851+ // })
852+ // .catch(function (error) {
853+ // return done(error);
854+ // });
855+ // });
856+
826857 it ( 'getDiagnosticLogs' , function ( done ) {
827858 var fileBytes = null ;
828859 try {
@@ -1024,6 +1055,30 @@ describe('SDK Unit Tests:', function (done) {
10241055 } ) ;
10251056 } ) ;
10261057 } ) ;
1058+
1059+ it ( 'it updateBrandResourcesByContentType' , function ( done ) {
1060+ var accountsApi = new docusign . AccountsApi ( apiClient ) ;
1061+ accountsApi . listBrands ( accountId , { includeLogos : true } )
1062+ . then ( function ( brandsData ) {
1063+ var currentBrand = brandsData . brands [ 0 ] ;
1064+ var brandXmlBuffer = fs . readFileSync ( path . resolve ( __dirname , brandXmlPath ) ) ;
1065+ accountsApi . updateBrandResourcesByContentType ( accountId , currentBrand . brandId , 'email' , brandXmlBuffer )
1066+ . then ( function ( data ) {
1067+ assert . notEqual ( data . createdByUserInfo , undefined ) ;
1068+ assert . notEqual ( data . resourcesContentUri , undefined ) ;
1069+ return done ( ) ;
1070+ } )
1071+ . catch ( function ( error ) {
1072+ // console.log(error)
1073+ return done ( error ) ;
1074+ } ) ;
1075+ } )
1076+ . catch ( function ( error ) {
1077+ // console.log(error)
1078+ return done ( error ) ;
1079+ } ) ;
1080+ } ) ;
1081+
10271082 it ( 'create template with date and number tabs' , function ( done ) {
10281083 var fileBytes = null ;
10291084 try {
@@ -1119,4 +1174,92 @@ describe('SDK Unit Tests:', function (done) {
11191174 }
11201175 } ) ;
11211176 } ) ;
1177+
1178+ it ( 'resend envelope with envelope update' , function ( done ) {
1179+ var fileBytes = null ;
1180+ try {
1181+ var fs = require ( 'fs' ) ;
1182+ // read file from a local directory
1183+ fileBytes = fs . readFileSync ( path . resolve ( __dirname , SignTest1File ) ) ;
1184+ } catch ( ex ) {
1185+ // handle error
1186+ console . log ( 'Exception: ' + ex ) ;
1187+ }
1188+
1189+ // create an envelope to be signed
1190+ var envDef = new docusign . EnvelopeDefinition ( ) ;
1191+ envDef . emailSubject = 'Please Sign my Node SDK Envelope' ;
1192+ envDef . emailBlurb = 'Hello, Please sign my Node SDK Envelope.' ;
1193+
1194+ // add a document to the envelope
1195+ var doc = new docusign . Document ( ) ;
1196+ var base64Doc = Buffer . from ( fileBytes ) . toString ( 'base64' ) ;
1197+ doc . documentBase64 = base64Doc ;
1198+ doc . name = 'TestFile.pdf' ;
1199+ doc . documentId = '1' ;
1200+
1201+ var docs = [ ] ;
1202+ docs . push ( doc ) ;
1203+ envDef . documents = docs ;
1204+
1205+ // Add a recipient to sign the document
1206+ var signer = new docusign . Signer ( ) ;
1207+ signer . email = userName ;
1208+ var name = 'Pat Developer' ;
1209+ signer . name = name ;
1210+ signer . recipientId = '1' ;
1211+
1212+ // this value represents the client's unique identifier for the signer
1213+ var clientUserId = '2939' ;
1214+ signer . clientUserId = clientUserId ;
1215+
1216+ // create a signHere tab somewhere on the document for the signer to sign
1217+ // default unit of measurement is pixels, can be mms, cms, inches also
1218+ var signHere = new docusign . SignHere ( ) ;
1219+ signHere . documentId = '1' ;
1220+ signHere . pageNumber = '1' ;
1221+ signHere . recipientId = '1' ;
1222+ signHere . xPosition = '100' ;
1223+ signHere . yPosition = '100' ;
1224+
1225+ // can have multiple tabs, so need to add to envelope as a single element list
1226+ var signHereTabs = [ ] ;
1227+ signHereTabs . push ( signHere ) ;
1228+ var tabs = new docusign . Tabs ( ) ;
1229+ tabs . signHereTabs = signHereTabs ;
1230+ signer . tabs = tabs ;
1231+
1232+ // Above causes issue
1233+ envDef . recipients = new docusign . Recipients ( ) ;
1234+ envDef . recipients . signers = [ ] ;
1235+ envDef . recipients . signers . push ( signer ) ;
1236+
1237+ // send the envelope (otherwise it will be "created" in the Draft folder
1238+ envDef . status = 'sent' ;
1239+
1240+ var envelopesApi = new docusign . EnvelopesApi ( apiClient ) ;
1241+
1242+ envelopesApi . createEnvelope ( accountId , { envelopeDefinition : envDef } )
1243+ . then ( function ( envelopeSummary ) {
1244+ if ( envelopeSummary ) {
1245+ envelopesApi . update ( accountId , envelopeSummary . envelopeId , { resendEnvelope : true } )
1246+ . then ( function ( envelopeUpdateSummary ) {
1247+ if ( envelopeUpdateSummary ) {
1248+ console . log ( 'envelopeUpdateSummary: ' + JSON . stringify ( envelopeUpdateSummary ) ) ;
1249+ done ( ) ;
1250+ }
1251+ } )
1252+ . catch ( function ( error ) {
1253+ if ( error ) {
1254+ return done ( error ) ;
1255+ }
1256+ } ) ;
1257+ }
1258+ } )
1259+ . catch ( function ( error ) {
1260+ if ( error ) {
1261+ return done ( error ) ;
1262+ }
1263+ } ) ;
1264+ } ) ;
11221265} ) ;
0 commit comments