Skip to content

Commit 3319354

Browse files
axshaniilyamerman
andauthored
Download Document (#306)
* download document * npm run lint-fix * response type and encoding * lint-fix --------- Co-authored-by: ilyamerman <[email protected]>
1 parent 86ff93d commit 3319354

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

resources/application.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application, ApplicationDocument, CreateApplicationRequest, PatchApplicationRequest, UploadDocumentRequest, VerifyDocumentRequest, CancelApplicationRequest } from "../types/application"
1+
import { Application, ApplicationDocument, CreateApplicationRequest, DownloadDocumentRequest, PatchApplicationRequest, UploadDocumentRequest, VerifyDocumentRequest, CancelApplicationRequest } from "../types/application"
22
import { UnitResponse, Include, UnitConfig, BaseListParams, BeneficialOwner } from "../types/common"
33
import { BaseResource } from "./baseResource"
44

@@ -84,6 +84,17 @@ export class Applications extends BaseResource {
8484
public async cancel(request: CancelApplicationRequest): Promise<UnitResponse<Application> & Include<ApplicationDocument[]>> {
8585
return this.httpPost<UnitResponse<Application> & Include<ApplicationDocument[]>>(`/${request.applicationId}/cancel`, { data: request.data })
8686
}
87+
88+
public async download(request: DownloadDocumentRequest): Promise<Buffer> {
89+
let path = `/${request.applicationId}/documents/${request.documentId}/download`
90+
if (request.isBackSide)
91+
path += "/back"
92+
93+
const responseEncoding = request.responseEncoding || "binary"
94+
const responseType = request.responseType || "arraybuffer"
95+
96+
return this.httpGet(path, {responseEncoding, responseType})
97+
}
8798
}
8899

89100
export interface ApplicationListParams extends BaseListParams {

types/application.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {responseEncoding, ResponseType} from "axios"
12
import { Address, BeneficialOwner, BusinessContact, FullName, Officer, Phone, State, Relationship, DeviceFingerprint, Agent, RelationshipsArray, Beneficiary, Grantor, TrustContact, Trustee, UnimplementedRelationships, UnimplementedFields, EvaluationParams, Industry } from "./common"
23

34
/**
@@ -605,6 +606,14 @@ export interface UploadDocumentRequest {
605606
fileType: "jpeg" | "png" | "pdf"
606607
}
607608

609+
export interface DownloadDocumentRequest {
610+
applicationId: string
611+
documentId: string
612+
isBackSide?: boolean
613+
responseEncoding?: responseEncoding
614+
responseType?: ResponseType
615+
}
616+
608617
export interface PatchApplicationRequest {
609618
applicationId: string
610619

0 commit comments

Comments
 (0)