Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. public class DocuSign {
  2.  
  3. public void test(String email, String name){
  4. String accountID = 'ec57264a-5e70-****-8ee1-ed2578cd3bdf';
  5. String userName = 'f14763b1-***-**-8e89-ef7297adb9c0';
  6. String passWord = '22223';
  7. String integratorKey = 'EDRE-****-0f94-4e13-8b24-c7ebacb3464a';
  8. String templateID = '6d3eb7ad-77ee-eeee-a22b-efb4f578fc0b';
  9. String endPoint = 'https://demo.docusign.net/restapi/v2/accounts/'+accountID+'/envelopes';
  10. //Apex HTTP Method Initialization.
  11.  
  12. HttpRequest req = new HttpRequest();
  13. req.setEndpoint(endPoint);
  14. req.setMethod('POST');
  15.  
  16. String authorizationHeader = '<DocuSignCredentials><Username>'+userName+'</Username><Password>'+Password+'</Password><IntegratorKey>'+integratorKey+'</IntegratorKey></DocuSignCredentials>';
  17. req.setHeader('X-DocuSign-Authentication', authorizationHeader);
  18. req.setHeader('Accept','application/json');
  19. req.setHeader('Content-Length','162100');
  20. req.setHeader('Content-Type','application/json');
  21. req.setHeader('Content-Disposition','form-data');
  22.  
  23.  
  24. string b = '{'+
  25. '"emailSubject":"DocuSign Templates Envelope Demo",'+
  26. ' "emailBlurb": "demo is sending you this request for your electronic signature.nnPlease review and electronically sign by following the link below. ",'+
  27. '"status": "sent",' +
  28. '"compositeTemplates": ['+
  29. '{'+
  30. '"serverTemplates": ['+
  31. '{'+
  32. '"sequence": "1",'+
  33. ' "templateId": "'+templateID+'",'+
  34. '}'+
  35. '],'+
  36. '"inlineTemplates": ['+
  37. '{'+
  38. '"sequence": "1",'+
  39. '"recipients": {'+
  40. '"signers": ['+
  41. '{'+
  42. ' "signingGroupId": "3839076",'+
  43. '"name": "First Recipient",'+
  44. '"recipientId": "1",'+
  45. '"roleName": "RoleOne"'+
  46. '}'+
  47. ']'+
  48. '}'+
  49. '}'+
  50. ']'+
  51. '},'+
  52. '{'+
  53. '"serverTemplates": ['+
  54. '{'+
  55. '"sequence": "1",'+
  56. '"templateId": "'+templateID+'",'+
  57. '}'+
  58. '],'+
  59. '"inlineTemplates": ['+
  60. '{'+
  61. '"sequence": "1",'+
  62. '"recipients": {'+
  63. '"signers": ['+
  64. '{'+
  65. '"signingGroupId": "3839076",'+
  66. '"name": "First Recipient",'+
  67. '"recipientId": "1",'+
  68. '"roleName": "RoleOne"'+
  69. '}'+
  70. ']'+
  71. '}'+
  72. '}'+
  73. ']'+
  74. '}'+
  75. ']'+
  76. '}';
  77.  
  78. req.setBody(json);
  79. Http http = new Http();
  80. HTTPResponse res;
  81. try{
  82. //Docusign Request Callout.
  83. res = http.send(req);
  84. system.debug('DocuSign Response'+ res.getBody());
  85. }
  86. catch(Exception e){
  87. SYSTEM.DEBUG('!!!!');
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement