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
(Tcl) 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
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # 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" # ] # } # ] # } # } # } set json [new_CkJsonObject] CkJsonObject_UpdateString $json "name" "My first procedure with emails" CkJsonObject_UpdateString $json "description" "Powerful! Here is the description of my first procedure with emails" CkJsonObject_UpdateString $json "members[0].firstname" "John" CkJsonObject_UpdateString $json "members[0].lastname" "Doe" CkJsonObject_UpdateString $json "members[0].email" "john.doe@yousign.fr" CkJsonObject_UpdateString $json "members[0].phone" "+33612345678" # Use the actual file ID here... CkJsonObject_UpdateString $json "members[0].fileObjects[0].file" "/files/23686fbe-3ae1-4de9-9e01-58bbf29b2b18" CkJsonObject_UpdateInt $json "members[0].fileObjects[0].page" 2 CkJsonObject_UpdateString $json "members[0].fileObjects[0].position" "230,499,464,589" CkJsonObject_UpdateString $json "members[0].fileObjects[0].mention" "Read and approved" CkJsonObject_UpdateString $json "members[0].fileObjects[0].mention2" "Signed by John Doe" CkJsonObject_UpdateString $json "config.email.\"member.started\"[0].subject" "Hey! You are invited to sign!" CkJsonObject_UpdateString $json "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>" CkJsonObject_UpdateString $json "config.email.\"member.started\"[0].to[0]" "@member" CkJsonObject_UpdateString $json "config.email.\"procedure.started\"[0].subject" "John, created a procedure your API have." CkJsonObject_UpdateString $json "config.email.\"procedure.started\"[0].message" "The content of this email is totally awesome." CkJsonObject_UpdateString $json "config.email.\"procedure.started\"[0].to[0]" "@creator" CkJsonObject_UpdateString $json "config.email.\"procedure.started\"[0].to[1]" "@members" CkJsonObject_UpdateString $json "config.email.\"procedure.started\"[0].to[2]" "billing@yousign.fr" # Adds the "Authorization: Bearer YOUR_API_KEY" header. CkHttp_put_AuthToken $http "YOUR_API_KEY" CkHttp_SetRequestHeader $http "Content-Type" "application/json" # resp is a CkHttpResponse set resp [CkHttp_PostJson3 $http "https://staging-api.yousign.com/procedures" "application/json" $json] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkJsonObject $json exit } set sbResponseBody [new_CkStringBuilder] CkHttpResponse_GetBodySb $resp $sbResponseBody set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] set respStatusCode [CkHttpResponse_get_StatusCode $resp] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttpResponse_header $resp] puts "Failed." delete_CkHttpResponse $resp delete_CkHttp $http delete_CkJsonObject $json delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp exit } delete_CkHttpResponse $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 set id [CkJsonObject_stringOf $jResp "id"] set name [CkJsonObject_stringOf $jResp "name"] set description [CkJsonObject_stringOf $jResp "description"] set createdAt [CkJsonObject_stringOf $jResp "createdAt"] set updatedAt [CkJsonObject_stringOf $jResp "updatedAt"] set finishedAt [CkJsonObject_stringOf $jResp "finishedAt"] set expiresAt [CkJsonObject_stringOf $jResp "expiresAt"] set status [CkJsonObject_stringOf $jResp "status"] set creator [CkJsonObject_stringOf $jResp "creator"] set creatorFirstName [CkJsonObject_stringOf $jResp "creatorFirstName"] set creatorLastName [CkJsonObject_stringOf $jResp "creatorLastName"] set workspace [CkJsonObject_stringOf $jResp "workspace"] set template [CkJsonObject_BoolOf $jResp "template"] set ordered [CkJsonObject_BoolOf $jResp "ordered"] set parent [CkJsonObject_stringOf $jResp "parent"] set relatedFilesEnable [CkJsonObject_BoolOf $jResp "relatedFilesEnable"] set archive [CkJsonObject_BoolOf $jResp "archive"] set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "metadata"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "config.email.\"procedure.started\""] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set subject [CkJsonObject_stringOf $jResp "config.email.\"procedure.started\"[i].subject"] set message [CkJsonObject_stringOf $jResp "config.email.\"procedure.started\"[i].message"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "config.email.\"procedure.started\"[i].to"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "config.email.\"procedure.started\"[i].to[j]"] set j [expr $j + 1] } set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "config.email.\"member.started\""] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set subject [CkJsonObject_stringOf $jResp "config.email.\"member.started\"[i].subject"] set message [CkJsonObject_stringOf $jResp "config.email.\"member.started\"[i].message"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "config.email.\"member.started\"[i].to"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "config.email.\"member.started\"[i].to[j]"] set j [expr $j + 1] } set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "members"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set id [CkJsonObject_stringOf $jResp "members[i].id"] set user [CkJsonObject_stringOf $jResp "members[i].user"] set v_type [CkJsonObject_stringOf $jResp "members[i].type"] set firstname [CkJsonObject_stringOf $jResp "members[i].firstname"] set lastname [CkJsonObject_stringOf $jResp "members[i].lastname"] set email [CkJsonObject_stringOf $jResp "members[i].email"] set phone [CkJsonObject_stringOf $jResp "members[i].phone"] set position [CkJsonObject_IntOf $jResp "members[i].position"] set createdAt [CkJsonObject_stringOf $jResp "members[i].createdAt"] set updatedAt [CkJsonObject_stringOf $jResp "members[i].updatedAt"] set finishedAt [CkJsonObject_stringOf $jResp "members[i].finishedAt"] set status [CkJsonObject_stringOf $jResp "members[i].status"] set comment [CkJsonObject_stringOf $jResp "members[i].comment"] set operationLevel [CkJsonObject_stringOf $jResp "members[i].operationLevel"] set operationModeSmsConfig [CkJsonObject_stringOf $jResp "members[i].operationModeSmsConfig"] set parent [CkJsonObject_stringOf $jResp "members[i].parent"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "members[i].fileObjects"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set id [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].id"] set fileId [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.id"] set fileName [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.name"] set fileType [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.type"] set fileContentType [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.contentType"] set fileDescription [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.description"] set fileCreatedAt [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.createdAt"] set fileUpdatedAt [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.updatedAt"] set fileSha256 [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.sha256"] set fileWorkspace [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.workspace"] set fileCreator [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.creator"] set fileProtected [CkJsonObject_BoolOf $jResp "members[i].fileObjects[j].file.protected"] set filePosition [CkJsonObject_IntOf $jResp "members[i].fileObjects[j].file.position"] set fileParent [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].file.parent"] set page [CkJsonObject_IntOf $jResp "members[i].fileObjects[j].page"] set position_str [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].position"] set fieldName [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].fieldName"] set mention [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].mention"] set mention2 [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].mention2"] set createdAt [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].createdAt"] set updatedAt [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].updatedAt"] set parent [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].parent"] set reason [CkJsonObject_stringOf $jResp "members[i].fileObjects[j].reason"] set k 0 set count_k [CkJsonObject_SizeOfArray $jResp "members[i].fileObjects[j].file.metadata"] while {$k < $count_k} { CkJsonObject_put_K $jResp $k set k [expr $k + 1] } set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "members[i].notificationsEmail"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "members[i].operationCustomModes"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "members[i].operationCustomModes[j]"] set j [expr $j + 1] } set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "subscribers"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "files"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set id [CkJsonObject_stringOf $jResp "files[i].id"] set name [CkJsonObject_stringOf $jResp "files[i].name"] set v_type [CkJsonObject_stringOf $jResp "files[i].type"] set contentType [CkJsonObject_stringOf $jResp "files[i].contentType"] set description [CkJsonObject_stringOf $jResp "files[i].description"] set createdAt [CkJsonObject_stringOf $jResp "files[i].createdAt"] set updatedAt [CkJsonObject_stringOf $jResp "files[i].updatedAt"] set sha256 [CkJsonObject_stringOf $jResp "files[i].sha256"] set workspace [CkJsonObject_stringOf $jResp "files[i].workspace"] set creator [CkJsonObject_stringOf $jResp "files[i].creator"] set v_protected [CkJsonObject_BoolOf $jResp "files[i].protected"] set position [CkJsonObject_IntOf $jResp "files[i].position"] set parent [CkJsonObject_stringOf $jResp "files[i].parent"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "files[i].metadata"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set j [expr $j + 1] } set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "archiveMetadata"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "fields"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "permissions"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $json delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.