diff --git a/src/resources/WorkflowRuns.ts b/src/resources/WorkflowRuns.ts index e81d615..2b29fd1 100644 --- a/src/resources/WorkflowRuns.ts +++ b/src/resources/WorkflowRuns.ts @@ -1,4 +1,5 @@ import { AxiosInstance } from "axios"; +import { OnfidoDownload } from "../OnfidoDownload"; import { Method, Resource } from "../Resource"; export type WorkflowRunRequest = { @@ -8,15 +9,15 @@ export type WorkflowRunRequest = { }; type WorkflowRunError = { - type: string; + type: string; message: string; } type WorkflowRunLink = { - url: string; - completed_redirect_url: string; - expired_redirect_url: string; - expires_at: string; + url: string; + completed_redirect_url: string; + expired_redirect_url: string; + expires_at: string; language: string; } @@ -63,4 +64,8 @@ export class WorkflowRuns extends Resource { return workflowRuns; } + + public async evidence(id: string): Promise { + return super.download(`${id}/signed_evidence_file`); + } } diff --git a/test/resources/WorkflowRuns.test.ts b/test/resources/WorkflowRuns.test.ts index d8b26b1..ba9a5b6 100644 --- a/test/resources/WorkflowRuns.test.ts +++ b/test/resources/WorkflowRuns.test.ts @@ -1,4 +1,4 @@ -import { Applicant, WorkflowRun } from "onfido-node"; +import { Applicant, WorkflowRun, OnfidoDownload } from "onfido-node"; import { exampleWorkflowRun } from "../testExamples"; import { @@ -79,3 +79,15 @@ it("lists workflow runs", async () => { ]) ); }); + +it("downloads a signed evidence file", async () => { + const workflowRun = await createWorkflowRun(applicant, workflow_id); + + createNock() + .get("/workflow_runs/" + workflowRun.id + "/signed_evidence_file") + .reply(200, {}); + + const file = await onfido.workflowRun.evidence(workflowRun.id); + + expect(file).toBeInstanceOf(OnfidoDownload); +});