Skip to content

Commit 6b8ea81

Browse files
harshitav-docusign94farhansaferoombiz
authored andcommitted
Deprecate V2 trigger. Add V3 with envelope and click events (microsoft#2284)
* Partner Center connector - new fields and deal registration actions (microsoft#2130) * Update apiDefinition.swagger.json * Latest changes * fix format warning * X-Caller_Id should be optional * Update apiDefinition.swagger.json Review changes - ->Added reg status and sub status fields. ->Update the fields descriptions as per api's details available on Microsoft public site. ->Remove submission related fields. ->Mark registration status field as read only. ->Remove offerId from root. ->Use Enum values in Create deal registration model. ->Create a separate model for update deal registration. Create a separate action for update deal registration. * Update apiDefinition.swagger.json * Update apiDefinition.swagger.json Add deprecate text in Update a referral by Id action * Update apiDefinition.swagger.json Connector status keep as Preview and UpdateReferralById deprecated keep as false but deprecated word in description. * Update apiDefinition.swagger.json update deal registration success message. * Update apiDefinition.swagger.json added title for registration object * Bitskout Connector (microsoft#2140) * Bitskout Connector * Requested changes * Add envlope and click events * addressing feedback. Alignement fixed. Comments added on backward compatibility * Remove the duplicate event * Add V3 Triggers * corrected the indentation * corrected the indendation Co-authored-by: Farhan <103836444+94farhan@users.noreply.github.com> Co-authored-by: saferoombiz <32263053+saferoombiz@users.noreply.github.com>
1 parent fd2a5bf commit 6b8ea81

File tree

2 files changed

+313
-1
lines changed

2 files changed

+313
-1
lines changed

certified-connectors/DocuSignDemo/apiDefinition.swagger.json

Lines changed: 266 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"/accounts/{accountId}/connectV2": {
7474
"post": {
75-
"summary": "When an envelope status changes (Connect) (V2)",
75+
"summary": "DEPRECATED: When an envelope status changes (Connect) (V2)",
7676
"description": "Triggers a new flow when an envelope status changes.",
7777
"operationId": "CreateHookEnvelopeV2",
7878
"parameters": [
@@ -121,6 +121,57 @@
121121
}
122122
}
123123
},
124+
"/accounts/{accountId}/connectV3": {
125+
"post": {
126+
"summary": "When an envelope status changes (Connect) (V3)",
127+
"description": "Triggers a new flow when an envelope status changes.",
128+
"operationId": "CreateHookEnvelopeV3",
129+
"parameters": [
130+
{
131+
"name": "accountId",
132+
"in": "path",
133+
"description": "Account id",
134+
"required": true,
135+
"x-ms-summary": "Account",
136+
"x-ms-test-value": "insert account id",
137+
"x-ms-dynamic-values": {
138+
"operationId": "GetLoginAccounts",
139+
"value-collection": "loginAccounts",
140+
"value-path": "accountIdGuid",
141+
"value-title": "name"
142+
},
143+
"type": "string"
144+
},
145+
{
146+
"name": "body",
147+
"in": "body",
148+
"required": true,
149+
"schema": {
150+
"$ref": "#/definitions/WebhookRequestV3"
151+
}
152+
}
153+
],
154+
"responses": {
155+
"201": {
156+
"description": "default",
157+
"schema": {
158+
"type": "object"
159+
}
160+
}
161+
},
162+
"deprecated": false,
163+
"x-ms-trigger": "single",
164+
"x-ms-trigger-hint": "To see it work now, send an envelope.",
165+
"x-ms-visibility": "important",
166+
"x-ms-no-generic-test": true
167+
},
168+
"x-ms-notification-content": {
169+
"description": "Details for Webhook",
170+
"schema": {
171+
"$ref": "#/definitions/WebhookEnvelopeResponseV3"
172+
}
173+
}
174+
},
124175
"/accounts/{accountId}/connect/{connectId}": {
125176
"delete": {
126177
"summary": "Delete hook",
@@ -2445,6 +2496,220 @@
24452496
}
24462497
}
24472498
},
2499+
"WebhookRequestV3": {
2500+
"required": [
2501+
"allUsers",
2502+
"allowEnvelopePublish",
2503+
"includeDocumentFields",
2504+
"requiresAcknowledgement",
2505+
"urlToPublishTo",
2506+
"name",
2507+
"envelopeEvents"
2508+
],
2509+
"type": "object",
2510+
"properties": {
2511+
"allUsers": {
2512+
"default": "true",
2513+
"type": "string",
2514+
"x-ms-summary": "allUsers",
2515+
"x-ms-visibility": "internal"
2516+
},
2517+
"allowEnvelopePublish": {
2518+
"default": "true",
2519+
"type": "string",
2520+
"x-ms-summary": "allowEnvelopePublish",
2521+
"x-ms-visibility": "internal"
2522+
},
2523+
"includeDocumentFields": {
2524+
"default": "true",
2525+
"type": "string",
2526+
"x-ms-summary": "includeDocumentFields",
2527+
"x-ms-visibility": "internal"
2528+
},
2529+
"requiresAcknowledgement": {
2530+
"default": "true",
2531+
"type": "string",
2532+
"x-ms-summary": "requiresAcknowledgement",
2533+
"x-ms-visibility": "internal"
2534+
},
2535+
"urlToPublishTo": {
2536+
"type": "string",
2537+
"x-ms-summary": "urlToPublishTo",
2538+
"x-ms-visibility": "internal",
2539+
"x-ms-notification-url": true
2540+
},
2541+
"name": {
2542+
"type": "string",
2543+
"x-ms-summary": "Connect name",
2544+
"x-ms-visibility": "important"
2545+
},
2546+
"envelopeEvents": {
2547+
"enum": [
2548+
"envelope-sent",
2549+
"envelope-delivered",
2550+
"envelope-completed",
2551+
"envelope-declined",
2552+
"envelope-voided",
2553+
"envelope-resent",
2554+
"envelope-corrected",
2555+
"envelope-purge",
2556+
"envelope-deleted",
2557+
"envelope-discard",
2558+
"click-agreed",
2559+
"click-declined"
2560+
],
2561+
"type": "string",
2562+
"x-ms-summary": "Envelope event",
2563+
"x-ms-visibility": "important"
2564+
}
2565+
}
2566+
},
2567+
"WebhookEnvelopeResponseV3": {
2568+
"type": "object",
2569+
"properties": {
2570+
"data": {
2571+
"type": "object",
2572+
"properties": {
2573+
"envelopeSummary": {
2574+
"type": "object",
2575+
"properties": {
2576+
"customFields": {
2577+
"description": "Key-value pairs representing the custom fields for this envelope (where key is the field name, and value is the field value).",
2578+
"type": "object",
2579+
"additionalProperties": {
2580+
"type": "string"
2581+
},
2582+
"x-ms-visibility": "important",
2583+
"x-ms-summary": "Custom Fields"
2584+
},
2585+
"createdDateTime": {
2586+
"format": "date-time",
2587+
"description": "yyyy-MM-ddTHH:mm:ss.fffZ",
2588+
"type": "string",
2589+
"x-ms-summary": "Envelope Created Date-Time",
2590+
"x-ms-visibility": "advanced"
2591+
},
2592+
"envelopeId": {
2593+
"type": "string",
2594+
"x-ms-summary": "Envelope ID",
2595+
"x-ms-visibility": "important"
2596+
},
2597+
"sentDateTime": {
2598+
"format": "date-time",
2599+
"description": "yyyy-MM-ddTHH:mm:ss.fffZ",
2600+
"type": "string",
2601+
"x-ms-summary": "Envelope Sent Date-Time",
2602+
"x-ms-visibility": "important"
2603+
},
2604+
"status": {
2605+
"type": "string",
2606+
"x-ms-summary": "Envelope Status",
2607+
"x-ms-visibility": "important"
2608+
},
2609+
"emailSubject": {
2610+
"type": "string",
2611+
"x-ms-summary": "Email Subject",
2612+
"x-ms-visibility": "important"
2613+
},
2614+
"sender": {
2615+
"type": "object",
2616+
"properties": {
2617+
"userName": {
2618+
"type": "string",
2619+
"x-ms-summary": "Sender's Name",
2620+
"x-ms-visibility": "important"
2621+
},
2622+
"userId": {
2623+
"type": "string",
2624+
"x-ms-summary": "Sender's User ID",
2625+
"x-ms-visibility": "important"
2626+
},
2627+
"accountId": {
2628+
"type": "string",
2629+
"x-ms-summary": "Sender's Account ID",
2630+
"x-ms-visibility": "important"
2631+
},
2632+
"email": {
2633+
"type": "string",
2634+
"x-ms-summary": "Sender's Email Address",
2635+
"x-ms-visibility": "important"
2636+
}
2637+
}
2638+
},
2639+
"recipients": {
2640+
"type": "object",
2641+
"properties": {
2642+
"signers": {
2643+
"type": "array",
2644+
"items": {
2645+
"type": "object",
2646+
"properties": {
2647+
"tabs": {
2648+
"description": "Key-value pairs representing the tabs for this recipient (where key is the field name, and value is the field value).",
2649+
"type": "object",
2650+
"additionalProperties": {
2651+
"type": "string"
2652+
},
2653+
"x-ms-visibility": "important",
2654+
"x-ms-summary": "Tabs"
2655+
},
2656+
"email": {
2657+
"type": "string",
2658+
"x-ms-summary": "Recipient Email",
2659+
"x-ms-visibility": "important"
2660+
},
2661+
"recipientId": {
2662+
"type": "string",
2663+
"x-ms-summary": "Recipient Id",
2664+
"x-ms-visibility": "advanced"
2665+
},
2666+
"routingOrder": {
2667+
"type": "string",
2668+
"x-ms-summary": "Routing Order",
2669+
"x-ms-visibility": "important"
2670+
},
2671+
"sentDateTime": {
2672+
"format": "date-time",
2673+
"description": "yyyy-MM-ddTHH:mm:ss.fffZ",
2674+
"type": "string",
2675+
"x-ms-summary": "Recipient Sent Date-Time",
2676+
"x-ms-visibility": "advanced"
2677+
},
2678+
"status": {
2679+
"description": "The status of the recipient.",
2680+
"type": "string",
2681+
"x-ms-summary": "Recipient Status",
2682+
"x-ms-visibility": "advanced"
2683+
},
2684+
"recipientType": {
2685+
"description": "The type of recipient.",
2686+
"type": "string",
2687+
"x-ms-summary": "Recipient Type",
2688+
"x-ms-visibility": "advanced"
2689+
},
2690+
"verificationType": {
2691+
"description": "The type of the verification.",
2692+
"type": "string",
2693+
"x-ms-summary": "Verification Type",
2694+
"x-ms-visibility": "important"
2695+
},
2696+
"name": {
2697+
"description": "The name of the recipient.",
2698+
"type": "string",
2699+
"x-ms-summary": "Recipient Name",
2700+
"x-ms-visibility": "important"
2701+
}
2702+
}
2703+
}
2704+
}
2705+
}
2706+
}
2707+
}
2708+
}
2709+
}
2710+
}
2711+
}
2712+
},
24482713
"WebhookRequest": {
24492714
"type": "object",
24502715
"required": [

certified-connectors/DocuSignDemo/script.csx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,48 @@ public class Script : ScriptBase
747747
return body;
748748
}
749749

750+
private JObject CreateHookEnvelopeV3BodyTransformation(JObject original)
751+
{
752+
var body = new JObject();
753+
754+
var uriLogicApps = original["urlToPublishTo"]?.ToString();
755+
var uriLogicAppsBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(uriLogicApps ?? string.Empty));
756+
var notificationProxyUri = this.Context.CreateNotificationUri($"/webhook_response?logicAppsUri={uriLogicAppsBase64}");
757+
758+
body["allUsers"] = "true";
759+
body["allowEnvelopePublish"] = "true";
760+
body["includeDocumentFields"] = "true";
761+
body["requiresAcknowledgement"] = "true";
762+
body["urlToPublishTo"] = notificationProxyUri.AbsoluteUri;
763+
body["name"] = original["name"]?.ToString();
764+
765+
var envelopeEvent = original["envelopeEvents"]?.ToString();
766+
var envelopeEventsArray = new JArray();
767+
envelopeEventsArray.Add(envelopeEvent);
768+
body["events"] = envelopeEventsArray;
769+
body["configurationType"] = "custom";
770+
body["deliveryMode"] = "sim";
771+
772+
string eventData = @"[
773+
'tabs',
774+
'custom_fields',
775+
'recipients'
776+
]";
777+
778+
JArray includeData = JArray.Parse(eventData);
779+
body["eventData"] = new JObject
780+
{
781+
["version"] = "restv2.1",
782+
["format"] = "json",
783+
["includeData"] = includeData
784+
};
785+
786+
var uriBuilder = new UriBuilder(this.Context.Request.RequestUri);
787+
uriBuilder.Path = uriBuilder.Path.Replace("connectV3", "connect");
788+
this.Context.Request.RequestUri = uriBuilder.Uri;
789+
return body;
790+
}
791+
750792
private JObject CreateHookEnvelopeBodyTransformation(JObject original)
751793
{
752794
var body = new JObject();
@@ -1305,6 +1347,11 @@ public class Script : ScriptBase
13051347
{
13061348
await this.TransformRequestJsonBody(this.CreateHookEnvelopeV2BodyTransformation).ConfigureAwait(false);
13071349
}
1350+
1351+
if ("CreateHookEnvelopeV3".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
1352+
{
1353+
await this.TransformRequestJsonBody(this.CreateHookEnvelopeV3BodyTransformation).ConfigureAwait(false);
1354+
}
13081355

13091356
if ("CreateBlankEnvelope".Equals(this.Context.OperationId, StringComparison.OrdinalIgnoreCase))
13101357
{

0 commit comments

Comments
 (0)