Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions src/api/identities/address-document-verifications.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { determineError } from '../../services/errors.js';
import { buildQueryParams } from '../../services/utils.js';
import { get, post } from '../../services/http.js';

// Path segments appended to the API base (config.identityVerificationUrl).
const ADDRESS_DOCUMENT_VERIFICATIONS_PATH = 'address-document-verifications';
const ANONYMIZE_PATH = 'anonymize';
const ASSETS_PATH = 'assets';
const ATTEMPTS_PATH = 'attempts';
const PDF_REPORT_PATH = 'pdf-report';

Expand Down Expand Up @@ -71,11 +73,17 @@ export default class AddressDocumentVerifications {
* Get the details of all attempts for a specific address document verification.
* @method listAttempts
* @param {string} address_document_verification_id - The address document verification's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of attempts to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of attempts to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get address document verification attempts response
*/
async listAttempts(address_document_verification_id) {
async listAttempts(address_document_verification_id, params) {
try {
const url = `${this.config.identityVerificationUrl}/${ADDRESS_DOCUMENT_VERIFICATIONS_PATH}/${address_document_verification_id}/${ATTEMPTS_PATH}`;
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${ADDRESS_DOCUMENT_VERIFICATIONS_PATH}/${address_document_verification_id}/${ATTEMPTS_PATH}`,
params
);
const response = await get(
this.config.httpClient,
url,
Expand Down Expand Up @@ -182,4 +190,36 @@ export default class AddressDocumentVerifications {
throw await determineError(error);
}
}

/**
* Get address document verification attempt assets
* [BETA]
* Get the assets (the document image) uploaded for an address document verification attempt.
* Results are paginated.
* @method getAttemptAssets
* @param {string} address_document_verification_id - The address document verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get address document verification attempt assets response
*/
async getAttemptAssets(address_document_verification_id, attempt_id, params) {
try {
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${ADDRESS_DOCUMENT_VERIFICATIONS_PATH}/${address_document_verification_id}/${ATTEMPTS_PATH}/${attempt_id}/${ASSETS_PATH}`,
params
);

const response = await get(
this.config.httpClient,
url,
this.config,
this.config.sk
);
return await response.json;
} catch (error) {
throw await determineError(error);
}
}
}
14 changes: 11 additions & 3 deletions src/api/identities/face-authentications.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ export default class FaceAuthentications {
* Get the details of all attempts for a specific face authentication.
* @method listAttempts
* @param {string} face_authentication_id - The face authentication's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of attempts to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of attempts to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get face authentication attempts response
*/
async listAttempts(face_authentication_id) {
async listAttempts(face_authentication_id, params) {
try {
const url = `${this.config.identityVerificationUrl}/${FACE_AUTHENTICATIONS_PATH}/${face_authentication_id}/${ATTEMPTS_PATH}`;
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${FACE_AUTHENTICATIONS_PATH}/${face_authentication_id}/${ATTEMPTS_PATH}`,
params
);
const response = await get(
this.config.httpClient,
url,
Expand Down Expand Up @@ -120,7 +126,9 @@ export default class FaceAuthentications {
* @method getAttemptAssets
* @param {string} face_authentication_id - The face authentication's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters (skip and limit)
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get face authentication attempt assets response
*/
async getAttemptAssets(face_authentication_id, attempt_id, params) {
Expand Down
44 changes: 42 additions & 2 deletions src/api/identities/id-document-verifications.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { determineError } from '../../services/errors.js';
import { buildQueryParams } from '../../services/utils.js';
import { get, post } from '../../services/http.js';

// Path segments appended to the API base (config.identityVerificationUrl).
const ANONYMIZE_PATH = 'anonymize';
const ASSETS_PATH = 'assets';
const ATTEMPTS_PATH = 'attempts';
const ID_DOCUMENT_VERIFICATIONS_PATH = 'id-document-verifications';
const PDF_REPORT_PATH = 'pdf-report';
Expand Down Expand Up @@ -71,11 +73,17 @@ export default class IDDocumentVerifications {
* Get the details of all attempts for a specific ID document verification.
* @method listAttempts
* @param {string} id_document_verification_id - The ID document verification's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of attempts to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of attempts to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get ID document verification attempts response
*/
async listAttempts(id_document_verification_id) {
async listAttempts(id_document_verification_id, params) {
try {
const url = `${this.config.identityVerificationUrl}/${ID_DOCUMENT_VERIFICATIONS_PATH}/${id_document_verification_id}/${ATTEMPTS_PATH}`;
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${ID_DOCUMENT_VERIFICATIONS_PATH}/${id_document_verification_id}/${ATTEMPTS_PATH}`,
params
);
const response = await get(
this.config.httpClient,
url,
Expand Down Expand Up @@ -184,4 +192,36 @@ export default class IDDocumentVerifications {
throw await determineError(error);
}
}

/**
* Get ID document verification attempt assets
* [BETA]
* Get the assets (the front and back images of the document) uploaded for an ID document verification attempt.
* Results are paginated.
* @method getAttemptAssets
* @param {string} id_document_verification_id - The ID document verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get ID document verification attempt assets response
*/
async getAttemptAssets(id_document_verification_id, attempt_id, params) {
try {
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${ID_DOCUMENT_VERIFICATIONS_PATH}/${id_document_verification_id}/${ATTEMPTS_PATH}/${attempt_id}/${ASSETS_PATH}`,
params
);

const response = await get(
this.config.httpClient,
url,
this.config,
this.config.sk
);
return await response.json;
} catch (error) {
throw await determineError(error);
}
}
}
68 changes: 60 additions & 8 deletions src/api/identities/identities.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,24 @@ export default class Identities {
return this.faceAuthentications.getFaceAuthentication(face_authentication_id);
}

async listFaceAuthenticationAttempts(face_authentication_id) {
return this.faceAuthentications.listAttempts(face_authentication_id);
async listFaceAuthenticationAttempts(face_authentication_id, params) {
return this.faceAuthentications.listAttempts(face_authentication_id, params);
}

async getFaceAuthenticationAttempt(face_authentication_id, attempt_id) {
return this.faceAuthentications.getAttempt(face_authentication_id, attempt_id);
}

/**
* Get the assets (the face image or video) uploaded for a face authentication attempt.
* Delegates to `faceAuthentications.getAttemptAssets`. Results are paginated.
* @param {string} face_authentication_id - The face authentication's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get face authentication attempt assets response
*/
async getFaceAuthenticationAttemptAssets(face_authentication_id, attempt_id, params) {
return this.faceAuthentications.getAttemptAssets(face_authentication_id, attempt_id, params);
}
Expand All @@ -88,8 +98,22 @@ export default class Identities {
return this.idDocumentVerifications.getIDDocumentVerification(id_document_verification_id);
}

async listIDDocumentVerificationAttempts(id_document_verification_id) {
return this.idDocumentVerifications.listAttempts(id_document_verification_id);
async listIDDocumentVerificationAttempts(id_document_verification_id, params) {
return this.idDocumentVerifications.listAttempts(id_document_verification_id, params);
}

/**
* Get the assets (the front and back images of the document) uploaded for an ID document verification attempt.
* Delegates to `idDocumentVerifications.getAttemptAssets`. Results are paginated.
* @param {string} id_document_verification_id - The ID document verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get ID document verification attempt assets response
*/
async getIDDocumentVerificationAttemptAssets(id_document_verification_id, attempt_id, params) {
return this.idDocumentVerifications.getAttemptAssets(id_document_verification_id, attempt_id, params);
}

async getIDDocumentVerificationAttempt(id_document_verification_id, attempt_id) {
Expand Down Expand Up @@ -117,8 +141,26 @@ export default class Identities {
return this.addressDocumentVerifications.getAddressDocumentVerification(address_document_verification_id);
}

async listAddressDocumentVerificationAttempts(address_document_verification_id) {
return this.addressDocumentVerifications.listAttempts(address_document_verification_id);
async listAddressDocumentVerificationAttempts(address_document_verification_id, params) {
return this.addressDocumentVerifications.listAttempts(address_document_verification_id, params);
}

/**
* Get the assets (the document image) uploaded for a address document verification attempt.
* Delegates to `addressDocumentVerifications.getAttemptAssets`. Results are paginated.
* @param {string} address_document_verification_id - The address document verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get address document verification attempt assets response
*/
async getAddressDocumentVerificationAttemptAssets(address_document_verification_id, attempt_id, params) {
return this.addressDocumentVerifications.getAttemptAssets(
address_document_verification_id,
attempt_id,
params
);
}

async getAddressDocumentVerificationAttempt(address_document_verification_id, attempt_id) {
Expand Down Expand Up @@ -158,14 +200,24 @@ export default class Identities {
return this.identityVerifications.createAttempt(identity_verification_id, body);
}

async listIdentityVerificationAttempts(identity_verification_id) {
return this.identityVerifications.listAttempts(identity_verification_id);
async listIdentityVerificationAttempts(identity_verification_id, params) {
return this.identityVerifications.listAttempts(identity_verification_id, params);
}

async getIdentityVerificationAttempt(identity_verification_id, attempt_id) {
return this.identityVerifications.getAttempt(identity_verification_id, attempt_id);
}

/**
* Get the assets (the captured images and videos) uploaded for a identity verification attempt.
* Delegates to `identityVerifications.getAttemptAssets`. Results are paginated.
* @param {string} identity_verification_id - The identity verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get identity verification attempt assets response
*/
async getIdentityVerificationAttemptAssets(identity_verification_id, attempt_id, params) {
return this.identityVerifications.getAttemptAssets(identity_verification_id, attempt_id, params);
}
Expand Down
21 changes: 15 additions & 6 deletions src/api/identities/identity-verifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ export default class IdentityVerifications {
* Get all the attempts for a specific identity verification.
* @method listAttempts
* @param {string} identity_verification_id - The identity verification's unique identifier
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of attempts to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of attempts to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get identity verification attempts response
*/
async listAttempts(identity_verification_id) {
async listAttempts(identity_verification_id, params) {
try {
const url = `${this.config.identityVerificationUrl}/${IDENTITY_VERIFICATIONS_PATH}/${identity_verification_id}/${ATTEMPTS_PATH}`;
const url = buildQueryParams(
`${this.config.identityVerificationUrl}/${IDENTITY_VERIFICATIONS_PATH}/${identity_verification_id}/${ATTEMPTS_PATH}`,
params
);
const response = await get(
this.config.httpClient,
url,
Expand Down Expand Up @@ -195,7 +201,9 @@ export default class IdentityVerifications {
* @method getAttemptAssets
* @param {string} identity_verification_id - The identity verification's unique identifier
* @param {string} attempt_id - The attempt's unique identifier
* @param {Object} [params] - Optional pagination query parameters (skip and limit)
* @param {Object} [params] - Optional pagination query parameters
* @param {number} [params.skip] - The number of assets to skip. Defaults to 0
* @param {number} [params.limit] - The maximum number of assets to return. Defaults to 10
* @returns {Promise<Object>} A promise to the Get identity verification attempt assets response
*/
async getAttemptAssets(identity_verification_id, attempt_id, params) {
Expand Down Expand Up @@ -224,18 +232,19 @@ export default class IdentityVerifications {
* The report is only available when the verification status is approved or declined.
* @method getPDFReport
* @param {string} identity_verification_id - The identity verification's unique identifier
* @returns {Promise<Buffer>} A promise to the PDF report as a Buffer
* @returns {Promise<Object>} A promise to the Get identity verification report response,
* carrying `pdf_report`, the pre-signed URL to the PDF
*/
async getPDFReport(identity_verification_id) {
try {
const url = `${this.config.identityVerificationUrl}/${IDENTITY_VERIFICATIONS_PATH}/${identity_verification_id}/${PDF_REPORT_PATH}`;
const response = await get(
this.config.httpClient,
url,
{ ...this.config, csv: true },
this.config,
this.config.sk
);
return await response.csv;
return await response.json;
} catch (error) {
throw await determineError(error);
}
Expand Down
Loading
Loading