@vulog/aima-user
Version:
29 lines (24 loc) • 918 B
text/typescript
import { Client } from '@vulog/aima-client';
import { z } from 'zod';
import { PersonalInformationUser, PersonalInformationUserType, personalInformationUserTypeSchema } from './types';
const argsSchema = z.object({
id: z.string().trim().min(1).uuid(),
types: z.array(personalInformationUserTypeSchema).min(1),
});
export const getUserPersonalInfoById = async (
client: Client,
id: string,
types: PersonalInformationUserType[]
): Promise<PersonalInformationUser> => {
const result = argsSchema.safeParse({ id, types });
if (!result.success) {
throw new TypeError('Invalid args', {
cause: result.error.issues,
});
}
return client
.get<PersonalInformationUser>(
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${result.data.id}/pi?types=${result.data.types.join(',')}`
)
.then(({ data }) => data);
};