From 9d140a8aad06aa5efc4d9295518c9ea4fe560964 Mon Sep 17 00:00:00 2001 From: Jared Snider Date: Wed, 10 May 2023 15:57:16 -0400 Subject: [PATCH] PM-1049 - Add getDevices call to retrieve all user devices to API service --- libs/common/src/abstractions/api.service.ts | 3 +++ libs/common/src/services/api.service.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/libs/common/src/abstractions/api.service.ts b/libs/common/src/abstractions/api.service.ts index 5670a5dc36..abf4c1fe8d 100644 --- a/libs/common/src/abstractions/api.service.ts +++ b/libs/common/src/abstractions/api.service.ts @@ -70,6 +70,7 @@ import { UpdateTwoFactorYubioOtpRequest } from "../auth/models/request/update-tw import { ApiKeyResponse } from "../auth/models/response/api-key.response"; import { AuthRequestResponse } from "../auth/models/response/auth-request.response"; import { DeviceVerificationResponse } from "../auth/models/response/device-verification.response"; +import { DeviceResponse } from "../auth/models/response/device.response"; import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse, @@ -363,6 +364,8 @@ export abstract class ApiService { ) => Promise; getKnownDevice: (email: string, deviceIdentifier: string) => Promise; + getDevices: () => Promise>; + getEmergencyAccessTrusted: () => Promise>; getEmergencyAccessGranted: () => Promise>; getEmergencyAccess: (id: string) => Promise; diff --git a/libs/common/src/services/api.service.ts b/libs/common/src/services/api.service.ts index e02bfb743f..68d4555562 100644 --- a/libs/common/src/services/api.service.ts +++ b/libs/common/src/services/api.service.ts @@ -77,6 +77,7 @@ import { UpdateTwoFactorYubioOtpRequest } from "../auth/models/request/update-tw import { ApiKeyResponse } from "../auth/models/response/api-key.response"; import { AuthRequestResponse } from "../auth/models/response/auth-request.response"; import { DeviceVerificationResponse } from "../auth/models/response/device-verification.response"; +import { DeviceResponse } from "../auth/models/response/device.response"; import { EmergencyAccessGranteeDetailsResponse, EmergencyAccessGrantorDetailsResponse, @@ -1118,6 +1119,12 @@ export class ApiService implements ApiServiceAbstraction { return r as boolean; } + // TODO: move this method to new devices-api.service once it's merged to master + async getDevices(): Promise> { + const r = await this.send("GET", "/devices", null, true, true, null); + return new ListResponse(r, DeviceResponse); + } + // Emergency Access APIs async getEmergencyAccessTrusted(): Promise> {