From 2184bb9be8ac7935d97b3e761bacd708eae88125 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Tue, 12 Mar 2024 13:53:34 +0530 Subject: [PATCH 01/11] [Automated] Update the toml files --- ballerina/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index abed368..397bfaf 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -61,7 +61,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.10.8" +version = "2.10.10" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, From a401ac3c6b7135d3c1f3af4b45d7fe6a799b1b14 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 17:45:57 +0530 Subject: [PATCH 02/11] [Automated] Update the toml files --- ballerina/Ballerina.toml | 4 ++-- ballerina/Dependencies.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 9255954..d75d8b9 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -2,10 +2,10 @@ distribution = "2201.8.4" org = "ballerinax" name = "docusign.dsclick" -version = "1.0.0" +version = "2.0.0" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = ["eSignature", "Cost/Freemium", "Documents", "Collaboration", "Digital Signature"] +keywords = ["eSignature", "Cost/Freemium", "Documents", "Click API", "Collaboration", "Digital Signature"] icon = "icon.png" repository = "https://github.com/ballerina-platform/module-ballerinax-docusign.dsclick" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 397bfaf..667936f 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -61,7 +61,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.10.10" +version = "2.10.11" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -308,7 +308,7 @@ modules = [ [[package]] org = "ballerinax" name = "docusign.dsclick" -version = "1.0.0" +version = "2.0.0" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "io"}, From c4876a033a9ce5104dc36b1afd3818469c17e33a Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:16:42 +0530 Subject: [PATCH 03/11] Update spec to substitute `versionId` and `versionNumber` with `version` --- docs/spec/openapi.json | 278 ++--------------------------------------- 1 file changed, 10 insertions(+), 268 deletions(-) diff --git a/docs/spec/openapi.json b/docs/spec/openapi.json index 9c44fe4..a204a2c 100644 --- a/docs/spec/openapi.json +++ b/docs/spec/openapi.json @@ -742,7 +742,7 @@ }, "parameters": [] }, - "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{versionId}": { + "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{version}": { "get": { "tags": [ "ClickWraps" @@ -767,11 +767,11 @@ "description": "The ID of the clickwrap." }, { - "name": "versionId", + "name": "version", "in": "path", "required": true, "type": "string", - "description": "The ID of the version." + "description": "The version ID or the version number" } ], "responses": { @@ -819,11 +819,11 @@ "description": "The ID of the clickwrap." }, { - "name": "versionId", + "name": "version", "in": "path", "required": true, "type": "string", - "description": "The ID of the version." + "description": "The version ID or the version number" }, { "name": "clickwrapRequest", @@ -880,11 +880,11 @@ "description": "The ID of the clickwrap." }, { - "name": "versionId", + "name": "version", "in": "path", "required": true, "type": "string", - "description": "The ID of the version." + "description": "The version ID or the version number" } ], "responses": { @@ -910,7 +910,7 @@ }, "parameters": [] }, - "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{versionId}/users": { + "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{version}/users": { "get": { "tags": [ "ClickWraps" @@ -935,11 +935,11 @@ "description": "The ID of the clickwrap." }, { - "name": "versionId", + "name": "version", "in": "path", "required": true, "type": "string", - "description": "The ID of the version." + "description": "The version ID of the version number" }, { "name": "client_user_id", @@ -999,264 +999,6 @@ "x-ds-in-sdk": true }, "parameters": [] - }, - "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{versionNumber}": { - "get": { - "tags": [ - "ClickWraps" - ], - "summary": "Gets a clickwrap version by specifying its version number.", - "operationId": "ClickwrapVersions_GetClickwrapVersionByNumber", - "consumes": [], - "produces": [], - "parameters": [ - { - "name": "accountId", - "in": "path", - "required": true, - "type": "string", - "description": "A GUID that identifies your account.\nThis value is automatically generated by\nDocuSign for any account you create. Copy the\nvalue from the **API Account ID** field in\nthe **API and Keys** page in\neSignature Settings.\n" - }, - { - "name": "clickwrapId", - "in": "path", - "required": true, - "type": "string", - "description": "The ID of the clickwrap." - }, - { - "name": "versionNumber", - "in": "path", - "required": true, - "type": "string", - "description": "Version of the clickwrap." - } - ], - "responses": { - "200": { - "description": "A successful response or an error.", - "schema": { - "$ref": "#/definitions/clickwrapVersionResponse" - } - }, - "400": { - "description": "Error encountered.", - "schema": { - "$ref": "#/definitions/errorDetails" - } - } - }, - "deprecated": false, - "x-ds-methodname": "getClickwrapVersionByNumber", - "x-ds-method": "getClickwrapVersionByNumber", - "x-ds-service": "Uncategorized", - "description": "Gets the clickwrap version specified by `versionNumber` from the clickwrap `clickwrapId`.", - "x-ds-in-sdk": true - }, - "put": { - "tags": [ - "ClickWraps" - ], - "summary": "Updates a clickwrap version by specifying its version number.", - "operationId": "ClickwrapVersions_PutClickwrapVersionByNumber", - "consumes": [], - "produces": [], - "parameters": [ - { - "name": "accountId", - "in": "path", - "required": true, - "type": "string", - "description": "A GUID that identifies your account.\nThis value is automatically generated by\nDocuSign for any account you create. Copy the\nvalue from the **API Account ID** field in\nthe **API and Keys** page in\neSignature Settings.\n" - }, - { - "name": "clickwrapId", - "in": "path", - "required": true, - "type": "string", - "description": "The ID of the clickwrap." - }, - { - "name": "versionNumber", - "in": "path", - "required": true, - "type": "string", - "description": "Version of the clickwrap." - }, - { - "name": "clickwrapRequest", - "in": "body", - "required": false, - "schema": { - "$ref": "#/definitions/clickwrapRequest" - }, - "description": "" - } - ], - "responses": { - "200": { - "description": "A successful response or an error.", - "schema": { - "$ref": "#/definitions/clickwrapVersionSummaryResponse" - } - }, - "400": { - "description": "Error encountered.", - "schema": { - "$ref": "#/definitions/errorDetails" - } - } - }, - "deprecated": false, - "x-ds-methodname": "updateClickwrapVersionByNumber", - "x-ds-method": "updateClickwrapVersionByNumber", - "x-ds-service": "Uncategorized", - "description": "Updates the clickwrap version specified by `versionNumber` of the clickwrap `clickwrapId`.\n", - "x-ds-in-sdk": true - }, - "delete": { - "tags": [ - "ClickWraps" - ], - "summary": "Deletes a clickwrap version from a clickwrap by specifying its version number.", - "operationId": "ClickwrapVersions_DeleteClickwrapVersionByNumber", - "consumes": [], - "produces": [], - "parameters": [ - { - "name": "accountId", - "in": "path", - "required": true, - "type": "string", - "description": "A GUID that identifies your account.\nThis value is automatically generated by\nDocuSign for any account you create. Copy the\nvalue from the **API Account ID** field in\nthe **API and Keys** page in\neSignature Settings.\n" - }, - { - "name": "clickwrapId", - "in": "path", - "required": true, - "type": "string", - "description": "The ID of the clickwrap." - }, - { - "name": "versionNumber", - "in": "path", - "required": true, - "type": "string", - "description": "Version of the clickwrap." - } - ], - "responses": { - "200": { - "description": "A successful response or an error.", - "schema": { - "$ref": "#/definitions/clickwrapVersionSummaryResponse" - } - }, - "400": { - "description": "Error encountered.", - "schema": { - "$ref": "#/definitions/errorDetails" - } - } - }, - "deprecated": false, - "x-ds-methodname": "deleteClickwrapVersionByNumber", - "x-ds-method": "deleteClickwrapVersionByNumber", - "x-ds-service": "Uncategorized", - "description": "Deletes the clickwrap version specified by `versionNumber` from the clickwrap `clickwrapId`.\n", - "x-ds-in-sdk": true - }, - "parameters": [] - }, - "/v1/accounts/{accountId}/clickwraps/{clickwrapId}/versions/{versionNumber}/users": { - "get": { - "tags": [ - "ClickWraps" - ], - "summary": "Gets the agreement responses for a clickwrap version", - "operationId": "UserAgreements_GetClickwrapVersionAgreementsByNumber", - "consumes": [], - "produces": [], - "parameters": [ - { - "name": "accountId", - "in": "path", - "required": true, - "type": "string", - "description": "A GUID that identifies your account.\nThis value is automatically generated by\nDocuSign for any account you create. Copy the\nvalue from the **API Account ID** field in\nthe **API and Keys** page in\neSignature Settings.\n" - }, - { - "name": "clickwrapId", - "in": "path", - "required": true, - "type": "string", - "description": "The ID of the clickwrap." - }, - { - "name": "versionNumber", - "in": "path", - "required": true, - "type": "string", - "description": "Version of the clickwrap." - }, - { - "name": "client_user_id", - "in": "query", - "required": false, - "type": "string", - "description": "The client user ID." - }, - { - "name": "from_date", - "in": "query", - "required": false, - "type": "string", - "description": "Optional. The earliest date to return agreements from." - }, - { - "name": "page_number", - "in": "query", - "required": false, - "type": "string", - "description": "Optional. The page number to return.\n" - }, - { - "name": "status", - "in": "query", - "required": false, - "type": "string", - "description": "Clickwrap status. Possible values:\n\n- `active`\n- `inactive`\n- `deleted`" - }, - { - "name": "to_date", - "in": "query", - "required": false, - "type": "string", - "description": "Optional. The latest date to return agreements from." - } - ], - "responses": { - "200": { - "description": "A successful response or an error.", - "schema": { - "$ref": "#/definitions/clickwrapAgreementsResponse" - } - }, - "400": { - "description": "Error encountered.", - "schema": { - "$ref": "#/definitions/errorDetails" - } - } - }, - "deprecated": false, - "x-ds-methodname": "getClickwrapVersionAgreementsByNumber", - "x-ds-method": "getClickwrapVersionAgreementsByNumber", - "x-ds-service": "Uncategorized", - "description": "Gets the agreement responses for a clickwrap version", - "x-ds-in-sdk": true - }, - "parameters": [] } }, "definitions": { From 239e47eb468febb3807ada75056e0528cd8c6d4f Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:17:32 +0530 Subject: [PATCH 04/11] Update resource methods to use `version` in the path parameters instead of `versionId` and `versionNumber` --- ballerina/client.bal | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ballerina/client.bal b/ballerina/client.bal index fd28021..b778916 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -301,10 +301,10 @@ public isolated client class Client { # the **API and Keys** page in # eSignature Settings. # + clickwrapId - The ID of the clickwrap. - # + versionId - The ID of the version. + # + version - The version ID or the version number # + return - A successful response or an error. - resource isolated function get v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string versionId]() returns ClickwrapVersionResponse|error { - string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(versionId)}`; + resource isolated function get v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string version]() returns ClickwrapVersionResponse|error { + string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(version)}`; ClickwrapVersionResponse response = check self.clientEp->get(resourcePath); return response; } @@ -318,10 +318,10 @@ public isolated client class Client { # the **API and Keys** page in # eSignature Settings. # + clickwrapId - The ID of the clickwrap. - # + versionId - The ID of the version. + # + version - The version ID or the version number # + return - A successful response or an error. - resource isolated function put v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string versionId](ClickwrapRequest payload) returns ClickwrapVersionSummaryResponse|error { - string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(versionId)}`; + resource isolated function put v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string version](ClickwrapRequest payload) returns ClickwrapVersionSummaryResponse|error { + string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(version)}`; http:Request request = new; json jsonBody = payload.toJson(); request.setPayload(jsonBody, "application/json"); @@ -338,10 +338,10 @@ public isolated client class Client { # the **API and Keys** page in # eSignature Settings. # + clickwrapId - The ID of the clickwrap. - # + versionId - The ID of the version. + # + version - The version ID or the version number # + return - A successful response or an error. - resource isolated function delete v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string versionId]() returns ClickwrapVersionDeleteResponse|error { - string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(versionId)}`; + resource isolated function delete v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string version]() returns ClickwrapVersionDeleteResponse|error { + string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(version)}`; ClickwrapVersionDeleteResponse response = check self.clientEp->delete(resourcePath); return response; } @@ -355,7 +355,7 @@ public isolated client class Client { # the **API and Keys** page in # eSignature Settings. # + clickwrapId - The ID of the clickwrap. - # + versionId - The ID of the version. + # + version - The version ID of the version number # + from_date - Optional. The earliest date to return agreements from. # + page_number - Optional. The page number to return. # + status - Clickwrap status. Possible values: @@ -364,8 +364,8 @@ public isolated client class Client { # - `deleted` # + to_date - Optional. The latest date to return agreements from. # + return - A successful response or an error. - resource isolated function get v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string versionId]/users(string? client_user_id = (), string? from_date = (), string? page_number = (), string? status = (), string? to_date = ()) returns ClickwrapAgreementsResponse|error { - string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(versionId)}/users`; + resource isolated function get v1/accounts/[string accountId]/clickwraps/[string clickwrapId]/versions/[string version]/users(string? client_user_id = (), string? from_date = (), string? page_number = (), string? status = (), string? to_date = ()) returns ClickwrapAgreementsResponse|error { + string resourcePath = string `/v1/accounts/${getEncodedUri(accountId)}/clickwraps/${getEncodedUri(clickwrapId)}/versions/${getEncodedUri(version)}/users`; map queryParam = {"client_user_id": client_user_id, "from_date": from_date, "page_number": page_number, "status": status, "to_date": to_date}; resourcePath = resourcePath + check getPathForQueryParam(queryParam); ClickwrapAgreementsResponse response = check self.clientEp->get(resourcePath); From 2180a9971d591a133371eaaee08c1ba6e49bc2ec Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:20:19 +0530 Subject: [PATCH 05/11] Use configurable parameter for `serviceUrl` --- ballerina/client.bal | 2 +- ballerina/tests/click-test.bal | 10 ++++------ examples/return-policy-agreement/main.bal | 5 +++-- examples/terms-and-conditions-agreement/main.bal | 5 +++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ballerina/client.bal b/ballerina/client.bal index b778916..1a8ac6e 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -24,7 +24,7 @@ public isolated client class Client { # + config - The configurations to be used when initializing the `connector` # + serviceUrl - URL of the target service # + return - An error if connector initialization failed - public isolated function init(ConnectionConfig config = {}, string serviceUrl = "https://demo.docusign.net/clickapi") returns error? { + public isolated function init(string serviceUrl, ConnectionConfig config = {}) returns error? { http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation}; do { if config.auth is http:ClientAuthConfig { diff --git a/ballerina/tests/click-test.bal b/ballerina/tests/click-test.bal index ecd0d73..3b55bd4 100644 --- a/ballerina/tests/click-test.bal +++ b/ballerina/tests/click-test.bal @@ -33,7 +33,7 @@ configurable string userId = ?; @test:BeforeSuite function initializeClientsForDocuSignServer() returns error? { if isTestOnLiveServer { - docuSignClient = check new( + docuSignClient = check new("https://demo.docusign.net/clickapi/", { timeout: 10000, auth: { @@ -42,11 +42,10 @@ function initializeClientsForDocuSignServer() returns error? { refreshToken: os:getEnv("REFRESH_TOKEN"), refreshUrl: os:getEnv("REFRESH_URL") } - }, - serviceUrl = "https://demo.docusign.net/clickapi/" + } ); } else { - docuSignClient = check new( + docuSignClient = check new("http://localhost:9092/clickapi", { timeout: 10000, auth: { @@ -55,8 +54,7 @@ function initializeClientsForDocuSignServer() returns error? { refreshToken, refreshUrl } - }, - serviceUrl = "http://localhost:9092/clickapi" + } ); } } diff --git a/examples/return-policy-agreement/main.bal b/examples/return-policy-agreement/main.bal index 30b8de2..2ce35c3 100644 --- a/examples/return-policy-agreement/main.bal +++ b/examples/return-policy-agreement/main.bal @@ -25,9 +25,11 @@ configurable string refreshToken = os:getEnv("REFRESH_TOKEN"); configurable string refreshUrl = os:getEnv("REFRESH_URL"); configurable string accountId = os:getEnv("ACCOUNT_ID"); configurable string userId = os:getEnv("USER_ID"); +configurable string serviceUrl = os:getEnv("SERVICE_URL"); public function main() returns error? { dsclick:Client docuSignClient = check new( + serviceUrl, { auth: { clientId, @@ -35,8 +37,7 @@ public function main() returns error? { refreshToken, refreshUrl } - }, - serviceUrl = "https://demo.docusign.net/clickapi/" + } ); dsclick:ClickwrapRequest returnPolicyPayload = { diff --git a/examples/terms-and-conditions-agreement/main.bal b/examples/terms-and-conditions-agreement/main.bal index c065bb5..d433916 100644 --- a/examples/terms-and-conditions-agreement/main.bal +++ b/examples/terms-and-conditions-agreement/main.bal @@ -25,9 +25,11 @@ configurable string refreshToken = os:getEnv("REFRESH_TOKEN"); configurable string refreshUrl = os:getEnv("REFRESH_URL"); configurable string accountId = os:getEnv("ACCOUNT_ID"); configurable string userId = os:getEnv("USER_ID"); +configurable string serviceUrl = os:getEnv("SERVICE_URL"); public function main() returns error? { dsclick:Client docuSignClient = check new( + serviceUrl, { auth: { clientId, @@ -35,8 +37,7 @@ public function main() returns error? { refreshToken, refreshUrl } - }, - serviceUrl = "https://demo.docusign.net/clickapi/" + } ); io:println(docuSignClient); From 8b4237a7ded7dd953a156e12e6b8789ada9adbfd Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:21:20 +0530 Subject: [PATCH 06/11] Bump package version to 2.0.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6df62fb..c8337d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.lib -version=1.0.0-SNAPSHOT +version=2.0.0-SNAPSHOT checkstylePluginVersion=10.12.0 spotbugsPluginVersion=5.0.14 From b5334c72b67a35be2f26cede1a934bd48f01f2cf Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:21:41 +0530 Subject: [PATCH 07/11] Update overview section in docs --- README.md | 10 ++-------- ballerina/Module.md | 4 ++-- ballerina/Package.md | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ad2ca62..9b3c3c6 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,9 @@ [![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/docusign.dsclick.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fdocusign.dsclick) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -The DocuSign Click connector can be used for simple agreements like terms & conditions and privacy policies, etc. It enables users to capture consent with just one click which simplifies the agreement process and enhances the user experience with this functionality. For more information about configuration and operations, refer to the module. +DocuSign is a digital transaction management platform that enables users to securely sign, send, and manage documents electronically. -- [docusign.dsclick](ballerina/Module.md) - Perform DocuSign Click related operations - -## Overview - -The Ballerina Docusign Click Connector provides the capability to capture user consent with one click for simple agreements such as terms & conditions and privacy policies - -The Ballerina Docusign Click module supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). +The Ballerina DocuSign Click connector integrates with the DocuSign platform, provides APIs to capture user consent with one click for simple agreements such as terms & conditions and privacy policies within Ballerina applications. It supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). ## Setup guide diff --git a/ballerina/Module.md b/ballerina/Module.md index c633212..46a59e6 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -1,8 +1,8 @@ ## Overview -The Ballerina Docusign Click Connector provides the capability to capture user consent with one click for simple agreements such as terms & conditions and privacy policies +DocuSign is a digital transaction management platform that enables users to securely sign, send, and manage documents electronically. -The Ballerina Docusign Click module supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). +The Ballerina DocuSign Click connector integrates with the DocuSign platform, provides APIs to capture user consent with one click for simple agreements such as terms & conditions and privacy policies within Ballerina applications. It supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). ## Setup guide diff --git a/ballerina/Package.md b/ballerina/Package.md index 592fe79..e96f172 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -1,8 +1,8 @@ ## Package overview -The Ballerina Docusign Click Connector provides the capability to capture user consent with one click for simple agreements such as terms & conditions and privacy policies +DocuSign is a digital transaction management platform that enables users to securely sign, send, and manage documents electronically. -The Ballerina Docusign Click module supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). +The Ballerina DocuSign Click connector integrates with the DocuSign platform, provides APIs to capture user consent with one click for simple agreements such as terms & conditions and privacy policies within Ballerina applications. It supports [DocuSign Click API V2](https://github.com/docusign/OpenAPI-Specifications/blob/master/click.rest.swagger-v2.json). ## Setup guide From e705d566f880e20cc87b04542679877451c48bd9 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:21:58 +0530 Subject: [PATCH 08/11] Add sanitations file into the spec directory --- docs/spec/sanitations.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/spec/sanitations.md diff --git a/docs/spec/sanitations.md b/docs/spec/sanitations.md new file mode 100644 index 0000000..42d7968 --- /dev/null +++ b/docs/spec/sanitations.md @@ -0,0 +1,23 @@ +# Sanitations for OpenAPI specification + +_Authors_: @Nuvindu \ +_Reviewers_: @shafreenAnfar @ThisaruGuruge \ +_Created_: 2024/03/12 \ +_Updated_: 2024/02/12 \ +_Edition_: Swan Lake + +## Introduction + +The Ballerina DocuSign Click connector facilitates integration with the [DocuSign Click API](https://developers.docusign.com/docs/click-api/reference) through the generation of client code using the [OpenAPI specification](https://github.com/ballerina-platform/module-ballerinax-docusign.dsclick/blob/main/docs/spec/openapi.json). To enhance usability, the following modifications have been applied to the original specification. + +1. Response descriptions +Previously, all responses for resource functions were labeled with a generic "Successful Response". This has been revised to "A successful response or an error". + +2. Parameter redefinition +Similar resource methods with path parameters `versionId` and `versionNumber` have been identified as the same resource path. To resolve this, a single API now utilizes the path parameter `version`. As both instances previously had the same functionality with the only difference being the path parameter for `version`, the new API can be used for both occurrences. + +## OpenAPI cli command + +```bash +bal openapi -i docs/spec/openapi.json --mode client -o ballerina +``` From fbe52d337d4b43e040947c697545d4bfe4ad1a4f Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:22:59 +0530 Subject: [PATCH 09/11] Add a keyword specific to the package --- build-config/resources/Ballerina.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index a9a8da9..75bbc14 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -5,7 +5,7 @@ name = "docusign.dsclick" version = "@toml.version@" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = ["eSignature", "Cost/Freemium", "Documents", "Collaboration", "Digital Signature"] +keywords = ["eSignature", "Cost/Freemium", "Documents", "Click API", "Collaboration", "Digital Signature"] icon = "icon.png" repository = "https://github.com/ballerina-platform/module-ballerinax-docusign.dsclick" From f83554a78cbe7ced09f0ada83eb8f8a1eebe9862 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Wed, 13 Mar 2024 19:23:13 +0530 Subject: [PATCH 10/11] Update docs in examples --- .../clickwraps-for-return-policy-agreement.md | 113 +++-------------- .../clickwraps-for-terms-and-conditions.md | 117 +++--------------- 2 files changed, 28 insertions(+), 202 deletions(-) diff --git a/examples/return-policy-agreement/clickwraps-for-return-policy-agreement.md b/examples/return-policy-agreement/clickwraps-for-return-policy-agreement.md index 6ed7f60..57ad639 100644 --- a/examples/return-policy-agreement/clickwraps-for-return-policy-agreement.md +++ b/examples/return-policy-agreement/clickwraps-for-return-policy-agreement.md @@ -2,112 +2,27 @@ This guide demonstrates the integration of the DocuSign Click API in a Ballerina application for managing clickwraps. The example covers creating, updating, retrieving versions, fetching user agreements, and deleting clickwraps. -## Step 1: Import DocuSign connector +## Prerequisites -Import the `ballerinax/docusign.dsclick` module into your Ballerina project. +Follow the guidelines in the [Setup guide](https://github.com/ballerina-platform/module-ballerinax-docusign.dsclick?tab=readme-ov-file#setup-guide) to get access to DocuSign APIs. -```ballerina -import ballerinax/docusign.dsclick; -``` - -## Step 2: Instantiate a new DocuSign client - -Define configurable parameters such as `clientId`, `clientSecret`, `refreshToken`, `refreshUrl`, `accountId` and `userId` to set up the DocuSign connection. Initialize the DocuSign client with the specified service URL and connection configuration. Define the clickwrap payload, including document details and display settings. - -```ballerina -configurable string clientId = ?; -configurable string clientSecret = ?; -configurable string refreshToken = ?; -configurable string refreshUrl = ?; -configurable string accountId = ?; -configurable string userId = ?; - -public function main() returns error? { - dsclick:Client docuSignClient = check new( - { - auth: { - clientId, - clientSecret, - refreshToken, - refreshUrl - } - }, - serviceUrl = "https://demo.docusign.net/clickapi/" - ); -} -``` - -## Step 3: Create new DocuSign clickwrap - -Create a new clickwrap by posting the clickwrap payload. - -```ballerina -dsclick:ClickwrapRequest returnPolicyPayload = { - clickwrapName: "ReturnPolicy", - documents: [ - { - documentName: "Test Doc", - documentBase64: array:toBase64(check io:fileReadBytes("./resources/README.pdf")), - fileExtension: "pdf" - } - ], - displaySettings: { - displayName: "Return Policy", - consentButtonText: "I Agree", - downloadable: true, - format: "modal", - requireAccept: true, - documentDisplay: "document", - sendToEmail: true - } -}; - -dsclick:ClickwrapVersionSummaryResponse newClickWrap = check docuSignClient->/v1/accounts/[accountId]/clickwraps.post(returnPolicyPayload); -``` +### Configuration -## Step 4: Retrieve clickwrap version +Configure DocuSign API credentials in Config.toml in the example directory. -Retrieve information about a specific clickwrap version. - -```ballerina -string? clickwrapId = newClickWrap.clickwrapId; -if clickwrapId is () { - return error("Clickwrap ID is empty"); -} -string? versionId = newClickWrap.versionId; -if versionId is () { - return error("Version ID is empty"); -} - -dsclick:ClickwrapVersionSummaryResponse versionResponse = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]; -io:println(versionResponse); -``` - -## Step 5: Update the clickwrap - -Update the existing clickwrap with new information. - -```ballerina -returnPolicyPayload.displaySettings.displayName = "Return Policy Updated"; - -dsclick:ClickwrapVersionSummaryResponse updateClickWrap = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]/versions/[versionId].put(returnPolicyPayload); -io:println(updateClickWrap); -``` - -## Step 6: Get user agreements - -Retrieve user agreements for a specific clickwrap version. - -```ballerina -dsclick:ClickwrapAgreementsResponse response = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]/versions/[versionId]/users(); -io:println(response); +```toml +accountId = "" +userId = "" +clientId = "" +clientSecret = "" +refreshToken = "" +refreshUrl = "" ``` -## Step 7: Delete the clickwrap +## Run the example -Delete the clickwrap. +Execute the following command to run the example. ```ballerina -dsclick:ClickwrapVersionsDeleteResponse deleteResponse = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId].delete(); -io:println(deleteResponse); +bal run ``` diff --git a/examples/terms-and-conditions-agreement/clickwraps-for-terms-and-conditions.md b/examples/terms-and-conditions-agreement/clickwraps-for-terms-and-conditions.md index 197de59..441cb59 100644 --- a/examples/terms-and-conditions-agreement/clickwraps-for-terms-and-conditions.md +++ b/examples/terms-and-conditions-agreement/clickwraps-for-terms-and-conditions.md @@ -2,116 +2,27 @@ This guide demonstrates how to integrate the DocuSign Click API into a Ballerina application to manage clickwraps for terms and conditions. The example covers creating, updating, retrieving versions, fetching user agreements, and deleting clickwraps. -## Step 1: Import DocuSign connector +## Prerequisites -Import the `ballerinax/docusign.dsclick` module into your Ballerina project. +Follow the guidelines in the [Setup guide](https://github.com/ballerina-platform/module-ballerinax-docusign.dsclick?tab=readme-ov-file#setup-guide) to get access to DocuSign APIs. -```ballerina -import ballerinax/docusign.dsclick; -``` - -## Step 2: Instantiate a new DocuSign client - -Define configurable parameters such as `clientId`, `clientSecret`, `refreshToken`, `refreshUrl`, `accountId` and `userId` to set up the DocuSign connection. Initialize the DocuSign client with the specified service URL and connection configuration. Define the clickwrap payload, including document details and display settings. - -```ballerina -configurable string clientId = ?; -configurable string clientSecret = ?; -configurable string refreshToken = ?; -configurable string refreshUrl = ?; -configurable string accountId = ?; -configurable string userId = ?; - -public function main() returns error? { - dsclick:Client docuSignClient = check new( - { - auth: { - clientId, - clientSecret, - refreshToken, - refreshUrl - } - }, - serviceUrl = "https://demo.docusign.net/clickapi/" - ); -} -``` - -## Step 3: Create new DocuSign clickwrap for terms and conditions - -Create a new clickwrap for terms and conditions. - -```ballerina -dsclick:Client docuSignClient = check new(serviceUrl = "https://demo.docusign.net/clickapi", config = { auth: { - token: accessToken -}}); - -dsclick:ClickwrapRequest termsPayload = { - clickwrapName: "TermsAndConditions", - documents: [ - { - documentName: "Terms Document", - documentBase64: array:toBase64(check io:fileReadBytes("./resources/Terms.pdf")), - fileExtension: "pdf" - } - ], - displaySettings: { - displayName: "Terms and Conditions", - consentButtonText: "I Agree", - downloadable: true, - format: "modal", - requireAccept: true, - documentDisplay: "document", - sendToEmail: true - } -}; - -dsclick:ClickwrapVersionSummaryResponse newClickWrap = check docuSignClient->/v1/accounts/[accountId]/clickwraps.post(termsPayload); -io:println(newClickWrap); -``` - -## Step 4: Retrieve clickwrap version - -Retrieve information about a specific clickwrap version. - -```ballerina -string? clickwrapId = newClickWrap.clickwrapId; -if clickwrapId is () { - return error("Clickwrap ID is empty"); -} -string? versionId = newClickWrap.versionId; -if versionId is () { - return error("Version ID is empty"); -} - -dsclick:ClickwrapVersionSummaryResponse versionResponse = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]; -io:println(versionResponse); -``` +### Configuration -## Step 6: Update the clickwrap +Configure DocuSign API credentials in Config.toml in the example directory. -Update the existing clickwrap with new information. - -```ballerina -termsPayload.displaySettings.displayName = "Updated Terms and Conditions"; -dsclick:ClickwrapVersionSummaryResponse updateClickWrap = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]/versions/[versionId].put(termsPayload); -io:println(updateClickWrap); -``` - -## Step 7: Get user agreements - -Retrieve user agreements for a specific clickwrap version. - -```ballerina -dsclick:ClickwrapAgreementsResponse response = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId]/versions/[versionId]/users(); -io:println(response); +```toml +accountId = "" +userId = "" +clientId = "" +clientSecret = "" +refreshToken = "" +refreshUrl = "" ``` -## Step 8: Delete the clickwrap +## Run the example -Delete the clickwrap for terms and conditions. +Execute the following command to run the example. ```ballerina -dsclick:ClickwrapVersionsDeleteResponse deleteResponse = check docuSignClient->/v1/accounts/[accountId]/clickwraps/[clickwrapId].delete(); -io:println(deleteResponse); +bal run ``` From 3df37ad5f527723536cd979872fe99103f68c64d Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Thu, 14 Mar 2024 11:29:53 +0530 Subject: [PATCH 11/11] Use included record parameter for `ConnectionConfig` --- ballerina/client.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/client.bal b/ballerina/client.bal index 1a8ac6e..350156e 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -24,7 +24,7 @@ public isolated client class Client { # + config - The configurations to be used when initializing the `connector` # + serviceUrl - URL of the target service # + return - An error if connector initialization failed - public isolated function init(string serviceUrl, ConnectionConfig config = {}) returns error? { + public isolated function init(string serviceUrl, *ConnectionConfig config) returns error? { http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation}; do { if config.auth is http:ClientAuthConfig {