Skip to content

Commit

Permalink
ON-41051 # Added ExecuteWorkflowEvent to FormsClient class
Browse files Browse the repository at this point in the history
  • Loading branch information
mymattcarroll committed Jun 10, 2024
1 parent 5f775e7 commit ab0cae9
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- `excludedAttachmentElementIds` to `FormSubmissionEventConfiguration`
- `ExecuteWorkflowEvent` to `FormsClient` class

## [6.0.0] - 2024-06-04

Expand Down
18 changes: 18 additions & 0 deletions OneBlink.SDK.Tests/FormsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
30 changes: 30 additions & 0 deletions OneBlink.SDK/FormsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,36 @@ public async Task<FormAttachmentMeta> GetFormSubmissionAttachmentMeta(long formI
return await this.oneBlinkApiClient.GetRequest<FormAttachmentMeta>(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<FormSubmissionWorkflowEvent> ExecuteWorkflowEvent(long formId, Guid submissionId, FormSubmissionEvent submissionEvent)
{
string url = "/form-submission-meta/replay-submission-event";
return await this.oneBlinkApiClient.PostRequest<ExecuteWorkflowEventRequest, FormSubmissionWorkflowEvent>(url, new ExecuteWorkflowEventRequest()
{
submissionId = submissionId,
formId = formId,
submissionEvent = submissionEvent
});
}

internal class AttachmentUploadRequest
{
[JsonProperty]
Expand Down
28 changes: 28 additions & 0 deletions docs/forms-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ab0cae9

Please sign in to comment.