Skip to content

Commit

Permalink
Makeapibranch (#2766)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: vetri-12980 <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent 8b275ae commit df78a27
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
50 changes: 50 additions & 0 deletions certified-connectors/ZohoSign/apiDefinition.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 3 additions & 0 deletions certified-connectors/ZohoSign/apiProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
}
},
"iconBrandColor": "#236EB4",
"scriptOperations": [
"InvokeAPI"
],
"capabilities": [],
"policyTemplateInstances": [
{
Expand Down
4 changes: 4 additions & 0 deletions certified-connectors/ZohoSign/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
40 changes: 40 additions & 0 deletions certified-connectors/ZohoSign/script.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
public class Script : ScriptBase
{
public override async Task<HttpResponseMessage> ExecuteAsync()
{
return await this.HandleForwardOperation().ConfigureAwait(false);
}
private async Task<HttpResponseMessage> HandleForwardOperation()
{
if(this.Context.OperationId == "InvokeAPI"){
return await this.HandleInvokeAPI().ConfigureAwait(false);
}
return null;
}
private async Task<HttpResponseMessage> 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;
}
}

0 comments on commit df78a27

Please sign in to comment.