Update user endpoints

This commit is contained in:
Andrew Kingston 2024-12-11 10:03:40 +00:00
parent 4c5bfa5285
commit 28f895f884
No known key found for this signature in database
1 changed files with 21 additions and 12 deletions

View File

@ -5,9 +5,16 @@ import {
BulkUserDeleted, BulkUserDeleted,
BulkUserRequest, BulkUserRequest,
BulkUserResponse, BulkUserResponse,
CheckInviteResponse,
CountUserResponse,
CreateAdminUserRequest, CreateAdminUserRequest,
CreateAdminUserResponse, CreateAdminUserResponse,
DeleteInviteUsersRequest, DeleteInviteUsersRequest,
DeleteInviteUsersResponse,
DeleteUserResponse,
FetchUsersResponse,
FindUserResponse,
GetUserInvitesResponse,
InviteUsersRequest, InviteUsersRequest,
InviteUsersResponse, InviteUsersResponse,
LookupAccountHolderResponse, LookupAccountHolderResponse,
@ -23,8 +30,8 @@ import {
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface UserEndpoints { export interface UserEndpoints {
getUsers: () => Promise<User[]> getUsers: () => Promise<FetchUsersResponse>
getUser: (userId: string) => Promise<User> getUser: (userId: string) => Promise<FindUserResponse>
updateOwnMetadata: ( updateOwnMetadata: (
metadata: UpdateSelfMetadataRequest metadata: UpdateSelfMetadataRequest
) => Promise<UpdateSelfMetadataResponse> ) => Promise<UpdateSelfMetadataResponse>
@ -32,7 +39,7 @@ export interface UserEndpoints {
user: CreateAdminUserRequest user: CreateAdminUserRequest
) => Promise<CreateAdminUserResponse> ) => Promise<CreateAdminUserResponse>
saveUser: (user: User) => Promise<SaveUserResponse> saveUser: (user: User) => Promise<SaveUserResponse>
deleteUser: (userId: string) => Promise<{ message: string }> deleteUser: (userId: string) => Promise<DeleteUserResponse>
deleteUsers: ( deleteUsers: (
users: Array<{ users: Array<{
userId: string userId: string
@ -40,21 +47,16 @@ export interface UserEndpoints {
}> }>
) => Promise<BulkUserDeleted | undefined> ) => Promise<BulkUserDeleted | undefined>
onboardUsers: (data: InviteUsersRequest) => Promise<InviteUsersResponse> onboardUsers: (data: InviteUsersRequest) => Promise<InviteUsersResponse>
getUserInvite: (code: string) => Promise<{ email: string }> getUserInvite: (code: string) => Promise<CheckInviteResponse>
getUserInvites: () => Promise<any[]> getUserInvites: () => Promise<GetUserInvitesResponse>
inviteUsers: (users: InviteUsersRequest) => Promise<InviteUsersResponse> inviteUsers: (users: InviteUsersRequest) => Promise<InviteUsersResponse>
removeUserInvites: ( removeUserInvites: (
data: DeleteInviteUsersRequest data: DeleteInviteUsersRequest
) => Promise<{ message: string }> ) => Promise<DeleteInviteUsersResponse>
acceptInvite: ( acceptInvite: (
data: AcceptUserInviteRequest data: AcceptUserInviteRequest
) => Promise<AcceptUserInviteResponse> ) => Promise<AcceptUserInviteResponse>
getUserCountByApp: (appId: string) => Promise<number> getUserCountByApp: (appId: string) => Promise<number>
addAppBuilder: (userId: string, appId: string) => Promise<{ message: string }>
removeAppBuilder: (
userId: string,
appId: string
) => Promise<{ message: string }>
getAccountHolder: () => Promise<LookupAccountHolderResponse> getAccountHolder: () => Promise<LookupAccountHolderResponse>
searchUsers: (data: SearchUsersRequest) => Promise<SearchUsersResponse> searchUsers: (data: SearchUsersRequest) => Promise<SearchUsersResponse>
createUsers: ( createUsers: (
@ -65,6 +67,13 @@ export interface UserEndpoints {
code: string, code: string,
data: UpdateInviteRequest data: UpdateInviteRequest
) => Promise<UpdateInviteResponse> ) => Promise<UpdateInviteResponse>
// Missing request or response types
addAppBuilder: (userId: string, appId: string) => Promise<{ message: string }>
removeAppBuilder: (
userId: string,
appId: string
) => Promise<{ message: string }>
} }
export const buildUserEndpoints = (API: BaseAPIClient): UserEndpoints => ({ export const buildUserEndpoints = (API: BaseAPIClient): UserEndpoints => ({
@ -248,7 +257,7 @@ export const buildUserEndpoints = (API: BaseAPIClient): UserEndpoints => ({
* Counts the number of users in an app * Counts the number of users in an app
*/ */
getUserCountByApp: async appId => { getUserCountByApp: async appId => {
const res = await API.get<{ userCount: number }>({ const res = await API.get<CountUserResponse>({
url: `/api/global/users/count/${appId}`, url: `/api/global/users/count/${appId}`,
}) })
return res.userCount return res.userCount