From ab0cae9dd32eca9114c93bf18f714e7199e1c078 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 11 Jun 2024 08:55:16 +1000 Subject: [PATCH] ON-41051 # Added ExecuteWorkflowEvent to FormsClient class --- CHANGELOG.md | 1 + OneBlink.SDK.Tests/FormsClientTests.cs | 18 ++++++++++++++++ OneBlink.SDK/FormsClient.cs | 30 ++++++++++++++++++++++++++ docs/forms-client.md | 28 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eb1357..cae35c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - `excludedAttachmentElementIds` to `FormSubmissionEventConfiguration` +- `ExecuteWorkflowEvent` to `FormsClient` class ## [6.0.0] - 2024-06-04 diff --git a/OneBlink.SDK.Tests/FormsClientTests.cs b/OneBlink.SDK.Tests/FormsClientTests.cs index 152a020..ad155f6 100644 --- a/OneBlink.SDK.Tests/FormsClientTests.cs +++ b/OneBlink.SDK.Tests/FormsClientTests.cs @@ -115,6 +115,24 @@ public async void get_draft_data_should_throw_oneblink_exception() Assert.Equal(HttpStatusCode.Unauthorized, oneBlinkAPIException.StatusCode); } + [Fact] + public async void can_execute_form_workflow_event() + { + FormsClient forms = new FormsClient(ACCESS_KEY, SECRET_KEY, TenantName.ONEBLINK_TEST); + FormSubmissionWorkflowEvent formSubmissionWorkflowEvent = await forms.ExecuteWorkflowEvent(this.formId, Guid.Parse(this.submissionId), new FormSubmissionEvent() + { + type = "CALLBACK", + configuration = new FormSubmissionEventConfiguration() + { + url = "https://httpstat.us/200", + secret = "shh" + } + }); + Assert.NotNull(formSubmissionWorkflowEvent); + Assert.Equal(formSubmissionWorkflowEvent.formId, this.formId); + Assert.Equal(formSubmissionWorkflowEvent.submissionId, Guid.Parse(this.submissionId)); + } + [Fact] public async void can_get_submission_data() { diff --git a/OneBlink.SDK/FormsClient.cs b/OneBlink.SDK/FormsClient.cs index a862ecd..05d7338 100644 --- a/OneBlink.SDK/FormsClient.cs +++ b/OneBlink.SDK/FormsClient.cs @@ -310,6 +310,36 @@ public async Task GetFormSubmissionAttachmentMeta(long formI return await this.oneBlinkApiClient.GetRequest(url); } + private class ExecuteWorkflowEventRequest + { + [JsonProperty] + internal Guid submissionId + { + get; set; + } + [JsonProperty] + internal long formId + { + get; set; + } + [JsonProperty] + internal FormSubmissionEvent submissionEvent + { + get; set; + } + } + + public async Task ExecuteWorkflowEvent(long formId, Guid submissionId, FormSubmissionEvent submissionEvent) + { + string url = "/form-submission-meta/replay-submission-event"; + return await this.oneBlinkApiClient.PostRequest(url, new ExecuteWorkflowEventRequest() + { + submissionId = submissionId, + formId = formId, + submissionEvent = submissionEvent + }); + } + internal class AttachmentUploadRequest { [JsonProperty] diff --git a/docs/forms-client.md b/docs/forms-client.md index 0321fa0..e41c822 100644 --- a/docs/forms-client.md +++ b/docs/forms-client.md @@ -670,3 +670,31 @@ EmailAttachmentData emailAttachmentData = await formsClient.UploadEmailAttachmen ### Result A `OneBlink.SDK.Model.EmailAttachmentData` class + +## `ExecuteWorkflowEvent()` + +### Example + +```c# +long formId = 1; +Guid submissionId = Guid.Parse("123"); +FormSubmissionEvent formSubmissionEvent = new FormSubmissionEvent(); +FormSubmissionWorkflowEvent formSubmissionWorkflowEvent = await formsClient.ExecuteWorkflowEvent(formId, submissionId, formSubmissionEvent); +``` + +### Parameters + +| Parameter | Required | Type | Description | +| --------------------- | -------- | ------------------- | ----------------------------------------------------------------------- | +| `formId` | Yes | long | The exact id of the form. | +| `submissionId` | Yes | Guid | The submission identifier generated after a successful form submission. | +| `formSubmissionEvent` | Yes | FormSubmissionEvent | The form workflow event to be executed. | + +### Throws + +- `OneBlinkAPIException` +- `Exception` + +### Result + +A `OneBlink.SDK.Model.FormSubmissionWorkflowEvent` class