Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Yousign - Setup email notificationsDemonstrates how to setup email notifications based on events. An event is triggered when a user (or our API) make an action or when a status has changed. For more information, see https://dev.yousign.com/?version=latest#96b9f5ec-8e41-4d0f-82e5-6fa91adfa4fd
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Json oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_Subject string ls_Message integer j integer li_Count_j string ls_StrVal string ls_User string ls_V_type string ls_Firstname string ls_Lastname string ls_Email string ls_Phone integer li_Position string ls_Comment string ls_OperationLevel string ls_OperationModeSmsConfig string ls_FileId string ls_FileName string ls_FileType string ls_FileContentType string ls_FileDescription string ls_FileCreatedAt string ls_FileUpdatedAt string ls_FileSha256 string ls_FileWorkspace string ls_FileCreator integer li_FileProtected integer li_FilePosition string ls_FileParent integer li_Page string ls_Position_str string ls_FieldName string ls_Mention string ls_Mention2 string ls_Reason integer k integer li_Count_k string ls_ContentType string ls_Sha256 integer li_V_protected string ls_Id string ls_Name string ls_Description string ls_CreatedAt string ls_UpdatedAt string ls_FinishedAt string ls_ExpiresAt string ls_Status string ls_Creator string ls_CreatorFirstName string ls_CreatorLastName string ls_Workspace integer li_Template integer li_Ordered string ls_Parent integer li_RelatedFilesEnable integer li_Archive integer i integer li_Count_i // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl --location --request POST 'https://staging-api.yousign.com/procedures' \ // --header 'Authorization: Bearer YOUR_API_KEY' \ // --header 'Content-Type: application/json' \ // --data-raw '{ // "name": "My first procedure with emails", // "description": "Powerful! Here is the description of my first procedure with emails", // "members": [ // { // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "fileObjects": [ // { // "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "page": 2, // "position": "230,499,464,589", // "mention": "Read and approved", // "mention2": "Signed by John Doe" // } // ] // } // ], // "config": { // "email": { // "member.started": [ // { // "subject": "Hey! You are invited to sign!", // "message": "Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>", // "to": ["@member"] // } // ], // "procedure.started": [ // { // "subject": "John, created a procedure your API have.", // "message": "The content of this email is totally awesome.", // "to": ["@creator", "@members", "billing@yousign.fr"] // } // ] // } // } // }' // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "name": "My first procedure with emails", // "description": "Powerful! Here is the description of my first procedure with emails", // "members": [ // { // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "fileObjects": [ // { // "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "page": 2, // "position": "230,499,464,589", // "mention": "Read and approved", // "mention2": "Signed by John Doe" // } // ] // } // ], // "config": { // "email": { // "member.started": [ // { // "subject": "Hey! You are invited to sign!", // "message": "Hello <tag data-tag-type=", // " data-tag-name=": <tag, // "button": [ // "@member" // ] // } // ], // "procedure.started": [ // { // "subject": "John, created a procedure your API have.", // "message": "The content of this email is totally awesome.", // "to": [ // "@creator", // "@members", // "billing@yousign.fr" // ] // } // ] // } // } // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("name","My first procedure with emails") loo_Json.UpdateString("description","Powerful! Here is the description of my first procedure with emails") loo_Json.UpdateString("members[0].firstname","John") loo_Json.UpdateString("members[0].lastname","Doe") loo_Json.UpdateString("members[0].email","john.doe@yousign.fr") loo_Json.UpdateString("members[0].phone","+33612345678") // Use the actual file ID here... loo_Json.UpdateString("members[0].fileObjects[0].file","/files/23686fbe-3ae1-4de9-9e01-58bbf29b2b18") loo_Json.UpdateInt("members[0].fileObjects[0].page",2) loo_Json.UpdateString("members[0].fileObjects[0].position","230,499,464,589") loo_Json.UpdateString("members[0].fileObjects[0].mention","Read and approved") loo_Json.UpdateString("members[0].fileObjects[0].mention2","Signed by John Doe") loo_Json.UpdateString("config.email.~"member.started~"[0].subject","Hey! You are invited to sign!") loo_Json.UpdateString("config.email.~"member.started~"[0].message","Hello <tag data-tag-type=~"string~" data-tag-name=~"recipient.firstname~"></tag> <tag data-tag-type=~"string~" data-tag-name=~"recipient.lastname~"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=~"button~" data-tag-name=~"url~" data-tag-title=~"Access to documents~">Access to documents</tag>") loo_Json.UpdateString("config.email.~"member.started~"[0].to[0]","@member") loo_Json.UpdateString("config.email.~"procedure.started~"[0].subject","John, created a procedure your API have.") loo_Json.UpdateString("config.email.~"procedure.started~"[0].message","The content of this email is totally awesome.") loo_Json.UpdateString("config.email.~"procedure.started~"[0].to[0]","@creator") loo_Json.UpdateString("config.email.~"procedure.started~"[0].to[1]","@members") loo_Json.UpdateString("config.email.~"procedure.started~"[0].to[2]","billing@yousign.fr") // Adds the "Authorization: Bearer YOUR_API_KEY" header. loo_Http.AuthToken = "YOUR_API_KEY" loo_Http.SetRequestHeader("Content-Type","application/json") loo_Resp = loo_Http.PostJson3("https://staging-api.yousign.com/procedures","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Json return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_Resp // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "id": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "My first procedure with emails", // "description": "Powerful! Here is the description of my first procedure with emails", // "createdAt": "2018-12-05T06:53:34+01:00", // "updatedAt": "2018-12-05T06:53:34+01:00", // "finishedAt": null, // "expiresAt": null, // "status": "active", // "creator": null, // "creatorFirstName": null, // "creatorLastName": null, // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "template": false, // "ordered": false, // "parent": null, // "metadata": [ // ], // "config": { // "email": { // "procedure.started": [ // { // "subject": "John, created a procedure your API have.", // "message": "The content of this email is totally awesome.", // "to": [ // "@creator", // "@members", // "billing@yousign.fr" // ] // } // ], // "member.started": [ // { // "subject": "Hey! You are invited to sign!", // "message": "Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>", // "to": [ // "@member" // ] // } // ] // } // }, // "members": [ // { // "id": "/members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "user": null, // "type": "signer", // "firstname": "John", // "lastname": "Doe", // "email": "john.doe@yousign.fr", // "phone": "+33612345678", // "position": 1, // "createdAt": "2018-12-05T06:53:34+01:00", // "updatedAt": "2018-12-05T06:53:34+01:00", // "finishedAt": null, // "status": "pending", // "fileObjects": [ // { // "id": "/file_objects/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "file": { // "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "The best name for my file.pdf", // "type": "signable", // "contentType": "application/pdf", // "description": null, // "createdAt": "2018-12-05T06:52:54+01:00", // "updatedAt": "2018-12-05T06:53:34+01:00", // "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", // "metadata": [ // ], // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "creator": null, // "protected": false, // "position": 0, // "parent": null // }, // "page": 2, // "position": "230,499,464,589", // "fieldName": null, // "mention": "Read and approved", // "mention2": "Signed by John Doe", // "createdAt": "2018-12-05T06:53:34+01:00", // "updatedAt": "2018-12-05T06:53:34+01:00", // "parent": null, // "reason": "Signed by Yousign" // } // ], // "comment": null, // "notificationsEmail": [ // ], // "operationLevel": "custom", // "operationCustomModes": [ // "sms" // ], // "operationModeSmsConfig": null, // "parent": null // } // ], // "subscribers": [ // ], // "files": [ // { // "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "name": "The best name for my file.pdf", // "type": "signable", // "contentType": "application/pdf", // "description": null, // "createdAt": "2018-12-05T06:52:54+01:00", // "updatedAt": "2018-12-05T06:53:34+01:00", // "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", // "metadata": [ // ], // "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", // "creator": null, // "protected": false, // "position": 0, // "parent": null // } // ], // "relatedFilesEnable": false, // "archive": false, // "archiveMetadata": [ // ], // "fields": [ // ], // "permissions": [ // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_Id = loo_JResp.StringOf("id") ls_Name = loo_JResp.StringOf("name") ls_Description = loo_JResp.StringOf("description") ls_CreatedAt = loo_JResp.StringOf("createdAt") ls_UpdatedAt = loo_JResp.StringOf("updatedAt") ls_FinishedAt = loo_JResp.StringOf("finishedAt") ls_ExpiresAt = loo_JResp.StringOf("expiresAt") ls_Status = loo_JResp.StringOf("status") ls_Creator = loo_JResp.StringOf("creator") ls_CreatorFirstName = loo_JResp.StringOf("creatorFirstName") ls_CreatorLastName = loo_JResp.StringOf("creatorLastName") ls_Workspace = loo_JResp.StringOf("workspace") li_Template = loo_JResp.BoolOf("template") li_Ordered = loo_JResp.BoolOf("ordered") ls_Parent = loo_JResp.StringOf("parent") li_RelatedFilesEnable = loo_JResp.BoolOf("relatedFilesEnable") li_Archive = loo_JResp.BoolOf("archive") i = 0 li_Count_i = loo_JResp.SizeOfArray("metadata") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("config.email.~"procedure.started~"") do while i < li_Count_i loo_JResp.I = i ls_Subject = loo_JResp.StringOf("config.email.~"procedure.started~"[i].subject") ls_Message = loo_JResp.StringOf("config.email.~"procedure.started~"[i].message") j = 0 li_Count_j = loo_JResp.SizeOfArray("config.email.~"procedure.started~"[i].to") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("config.email.~"procedure.started~"[i].to[j]") j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("config.email.~"member.started~"") do while i < li_Count_i loo_JResp.I = i ls_Subject = loo_JResp.StringOf("config.email.~"member.started~"[i].subject") ls_Message = loo_JResp.StringOf("config.email.~"member.started~"[i].message") j = 0 li_Count_j = loo_JResp.SizeOfArray("config.email.~"member.started~"[i].to") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("config.email.~"member.started~"[i].to[j]") j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("members") do while i < li_Count_i loo_JResp.I = i ls_Id = loo_JResp.StringOf("members[i].id") ls_User = loo_JResp.StringOf("members[i].user") ls_V_type = loo_JResp.StringOf("members[i].type") ls_Firstname = loo_JResp.StringOf("members[i].firstname") ls_Lastname = loo_JResp.StringOf("members[i].lastname") ls_Email = loo_JResp.StringOf("members[i].email") ls_Phone = loo_JResp.StringOf("members[i].phone") li_Position = loo_JResp.IntOf("members[i].position") ls_CreatedAt = loo_JResp.StringOf("members[i].createdAt") ls_UpdatedAt = loo_JResp.StringOf("members[i].updatedAt") ls_FinishedAt = loo_JResp.StringOf("members[i].finishedAt") ls_Status = loo_JResp.StringOf("members[i].status") ls_Comment = loo_JResp.StringOf("members[i].comment") ls_OperationLevel = loo_JResp.StringOf("members[i].operationLevel") ls_OperationModeSmsConfig = loo_JResp.StringOf("members[i].operationModeSmsConfig") ls_Parent = loo_JResp.StringOf("members[i].parent") j = 0 li_Count_j = loo_JResp.SizeOfArray("members[i].fileObjects") do while j < li_Count_j loo_JResp.J = j ls_Id = loo_JResp.StringOf("members[i].fileObjects[j].id") ls_FileId = loo_JResp.StringOf("members[i].fileObjects[j].file.id") ls_FileName = loo_JResp.StringOf("members[i].fileObjects[j].file.name") ls_FileType = loo_JResp.StringOf("members[i].fileObjects[j].file.type") ls_FileContentType = loo_JResp.StringOf("members[i].fileObjects[j].file.contentType") ls_FileDescription = loo_JResp.StringOf("members[i].fileObjects[j].file.description") ls_FileCreatedAt = loo_JResp.StringOf("members[i].fileObjects[j].file.createdAt") ls_FileUpdatedAt = loo_JResp.StringOf("members[i].fileObjects[j].file.updatedAt") ls_FileSha256 = loo_JResp.StringOf("members[i].fileObjects[j].file.sha256") ls_FileWorkspace = loo_JResp.StringOf("members[i].fileObjects[j].file.workspace") ls_FileCreator = loo_JResp.StringOf("members[i].fileObjects[j].file.creator") li_FileProtected = loo_JResp.BoolOf("members[i].fileObjects[j].file.protected") li_FilePosition = loo_JResp.IntOf("members[i].fileObjects[j].file.position") ls_FileParent = loo_JResp.StringOf("members[i].fileObjects[j].file.parent") li_Page = loo_JResp.IntOf("members[i].fileObjects[j].page") ls_Position_str = loo_JResp.StringOf("members[i].fileObjects[j].position") ls_FieldName = loo_JResp.StringOf("members[i].fileObjects[j].fieldName") ls_Mention = loo_JResp.StringOf("members[i].fileObjects[j].mention") ls_Mention2 = loo_JResp.StringOf("members[i].fileObjects[j].mention2") ls_CreatedAt = loo_JResp.StringOf("members[i].fileObjects[j].createdAt") ls_UpdatedAt = loo_JResp.StringOf("members[i].fileObjects[j].updatedAt") ls_Parent = loo_JResp.StringOf("members[i].fileObjects[j].parent") ls_Reason = loo_JResp.StringOf("members[i].fileObjects[j].reason") k = 0 li_Count_k = loo_JResp.SizeOfArray("members[i].fileObjects[j].file.metadata") do while k < li_Count_k loo_JResp.K = k k = k + 1 loop j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("members[i].notificationsEmail") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("members[i].operationCustomModes") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("members[i].operationCustomModes[j]") j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("subscribers") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("files") do while i < li_Count_i loo_JResp.I = i ls_Id = loo_JResp.StringOf("files[i].id") ls_Name = loo_JResp.StringOf("files[i].name") ls_V_type = loo_JResp.StringOf("files[i].type") ls_ContentType = loo_JResp.StringOf("files[i].contentType") ls_Description = loo_JResp.StringOf("files[i].description") ls_CreatedAt = loo_JResp.StringOf("files[i].createdAt") ls_UpdatedAt = loo_JResp.StringOf("files[i].updatedAt") ls_Sha256 = loo_JResp.StringOf("files[i].sha256") ls_Workspace = loo_JResp.StringOf("files[i].workspace") ls_Creator = loo_JResp.StringOf("files[i].creator") li_V_protected = loo_JResp.BoolOf("files[i].protected") li_Position = loo_JResp.IntOf("files[i].position") ls_Parent = loo_JResp.StringOf("files[i].parent") j = 0 li_Count_j = loo_JResp.SizeOfArray("files[i].metadata") do while j < li_Count_j loo_JResp.J = j j = j + 1 loop i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("archiveMetadata") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("fields") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop i = 0 li_Count_i = loo_JResp.SizeOfArray("permissions") do while i < li_Count_i loo_JResp.I = i i = i + 1 loop destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.