Skip to content

Commit

Permalink
Merge pull request #101 from developer88/add_signed_evidence_download…
Browse files Browse the repository at this point in the history
…_endpoint

Add signed evidence file download endpoint
  • Loading branch information
DavidMealha-Onfido authored Nov 23, 2023
2 parents e21f328 + 9222042 commit 189ae74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.8.0 24 November 2023

- Added `signed_evidence_file` method for WorkflowRuns

## v2.7.2, 14 June 2023

- Added `sandbox` field to Check.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onfido/api",
"version": "2.7.2",
"version": "2.8.0",
"description": "Node.js library for the Onfido API",
"keywords": [
"onfido",
Expand Down Expand Up @@ -61,4 +61,4 @@
"axios": "^1.6.1",
"form-data": "^3.0.0"
}
}
}
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 189ae74

Please sign in to comment.