From df78a27f3104431cd3aa5476d9795e1b773c545b Mon Sep 17 00:00:00 2001 From: ZohoSign-integ <83749960+ZohoSign-integ@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:48:40 +0530 Subject: [PATCH] Makeapibranch (#2766) * certified connector files created * api properties changes * invoke api changes * invoke api-generalised response changes * adding invoke api action to readme file --------- Co-authored-by: vetri-con861 Co-authored-by: vetri-12980 --- .../ZohoSign/apiDefinition.swagger.json | 50 +++++++++++++++++++ .../ZohoSign/apiProperties.json | 3 ++ certified-connectors/ZohoSign/readme.md | 4 ++ certified-connectors/ZohoSign/script.csx | 40 +++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 certified-connectors/ZohoSign/script.csx diff --git a/certified-connectors/ZohoSign/apiDefinition.swagger.json b/certified-connectors/ZohoSign/apiDefinition.swagger.json index 337da7c7e0..29342f830b 100644 --- a/certified-connectors/ZohoSign/apiDefinition.swagger.json +++ b/certified-connectors/ZohoSign/apiDefinition.swagger.json @@ -22,6 +22,56 @@ "application/json" ], "paths": { + "/{url}": { + "post": { + "responses": { + "200": { + "description": "default", + "schema": { + "type": "object", + "properties": {} + } + } + }, + "operationId": "InvokeAPI", + "summary": "Invoke API", + "description": "Invoke API", + "parameters": [ + { + "name": "url", + "in": "path", + "required": true, + "type": "string", + "x-ms-url-encoding": "single", + "x-ms-summary": "URL Path", + "description": "Provide url path" + }, + { + "name": "method", + "in": "query", + "required": true, + "type": "string", + "enum": [ + "GET", + "POST", + "PUT" + ], + "description": "Select API Method to be used", + "x-ms-summary": "Method" + }, + { + "name": "body", + "in": "body", + "required": false, + "schema": { + "type": "object", + "title": "input_data", + "properties": {} + } + } + ] + } + }, "/requests/{request_id}/completioncertificate": { "get": { "produces": [ diff --git a/certified-connectors/ZohoSign/apiProperties.json b/certified-connectors/ZohoSign/apiProperties.json index 9460b72964..77365f43ee 100644 --- a/certified-connectors/ZohoSign/apiProperties.json +++ b/certified-connectors/ZohoSign/apiProperties.json @@ -65,6 +65,9 @@ } }, "iconBrandColor": "#236EB4", + "scriptOperations": [ + "InvokeAPI" + ], "capabilities": [], "policyTemplateInstances": [ { diff --git a/certified-connectors/ZohoSign/readme.md b/certified-connectors/ZohoSign/readme.md index a223f0c8a2..aa66db38a8 100644 --- a/certified-connectors/ZohoSign/readme.md +++ b/certified-connectors/ZohoSign/readme.md @@ -60,6 +60,10 @@ Get particular template details List of Templates +### Invoke API + +Invoke an API of Zoho Sign + ## Supported Triggers The connector supports the following triggers: diff --git a/certified-connectors/ZohoSign/script.csx b/certified-connectors/ZohoSign/script.csx new file mode 100644 index 0000000000..ca40abf1ad --- /dev/null +++ b/certified-connectors/ZohoSign/script.csx @@ -0,0 +1,40 @@ +public class Script : ScriptBase +{ + public override async Task ExecuteAsync() + { + return await this.HandleForwardOperation().ConfigureAwait(false); + } + private async Task HandleForwardOperation() + { + if(this.Context.OperationId == "InvokeAPI"){ + return await this.HandleInvokeAPI().ConfigureAwait(false); + } + return null; + } + private async Task HandleInvokeAPI() + { + Uri uri = this.Context.Request.RequestUri; + var query = HttpUtility.ParseQueryString(uri.Query); + var apiMethod = HttpMethod.Get; + switch (query["method"].ToString()) { + case "GET": + apiMethod = HttpMethod.Get; + break; + case "POST": + apiMethod = HttpMethod.Post; + break; + case "PUT": + apiMethod = HttpMethod.Put; + break; + } + var updatedURL = Uri.UnescapeDataString(uri.ToString()); + var apiUrl = updatedURL.Substring(0, updatedURL.IndexOf("?")); + Context.Request.RequestUri = new System.Uri(string.Format(apiUrl)); + Context.Request.Method = apiMethod; + HttpResponseMessage response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false); + var responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(continueOnCapturedContext: false); + var responseJson = JObject.Parse(responseString); + response.Content = CreateJsonContent(responseJson.ToString()); + return response; + } +}