Skip to content

Commit

Permalink
Add signed evidence file download endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
developer88 committed Nov 22, 2023
1 parent c0d845d commit 92c6d53
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/resources/WorkflowRuns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxiosInstance } from "axios";
import { OnfidoDownload } from "../OnfidoDownload";
import { Method, Resource } from "../Resource";

export type WorkflowRunRequest = {
Expand All @@ -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;
}

Expand Down Expand Up @@ -63,4 +64,8 @@ export class WorkflowRuns extends Resource<WorkflowRunRequest> {

return workflowRuns;
}

public async evidence(id: string): Promise<OnfidoDownload> {
return super.download(`${id}/signed_evidence_file`);
}
}
14 changes: 13 additions & 1 deletion test/resources/WorkflowRuns.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Applicant, WorkflowRun } from "onfido-node";
import { Applicant, WorkflowRun, OnfidoDownload } from "onfido-node";

import { exampleWorkflowRun } from "../testExamples";
import {
Expand Down Expand Up @@ -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);
});

0 comments on commit 92c6d53

Please sign in to comment.