@vulog/aima-user
v1.2.48
Published
User management — profiles, personal information, labels, billing groups, and service registration.
Downloads
1,383
Readme
@vulog/aima-user
User management — profiles, personal information, labels, billing groups, and service registration.
Installation
npm install @vulog/aima-user @vulog/aima-client @vulog/aima-core @vulog/aima-configUsage
import { getUserById, createUser, findUser, getUsers } from '@vulog/aima-user';
import { getClient } from '@vulog/aima-client';
const client = getClient({ ... });
const user = await getUserById(client, 'user-uuid');
const results = await findUser(client, 'email', '[email protected]', ['PERSONAL']);API Reference
acceptTAndC
acceptTAndC(client: Client, userId: string, cityId: string): Promise<void>Accepts terms and conditions for a user in a given city.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| cityId | string | City identifier |
assignBillingGroup
assignBillingGroup(client: Client, entityId: string, billingGroupId: string): Promise<void>Assigns an entity to a billing group.
| Param | Type | Description |
| ---------------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| entityId | string | Entity identifier |
| billingGroupId | string | Billing group identifier |
unassignBillingGroup
unassignBillingGroup(client: Client, entityId: string, billingGroupId: string): Promise<void>Removes an entity from a billing group.
| Param | Type | Description |
| ---------------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| entityId | string | Entity identifier |
| billingGroupId | string | Billing group identifier |
createBusinessProfile
createBusinessProfile(client: Client, userId: string, businessId: string, data: { emailConsent: boolean; email: string; requestId: string; costCenterId?: string }): Promise<UserProfile>@deprecated. Creates a business profile for a user.
| Param | Type | Description |
| ------------ | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| businessId | string | Business identifier |
| data | object | Profile creation data |
createUser
createUser(client: Client, user: CreateUser, option?: CreateUserOptions): Promise<User>Creates a new user account.
| Param | Type | Description |
| -------- | ------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| user | CreateUser | User creation data |
| option | CreateUserOptions | Creation options |
findUser
findUser(client: Client, searchType: 'email' | 'username' | 'phoneNumber', searchQuery: string, types: PersonalInformationUserType[]): Promise<ResponseFind>Searches for users by email, username, or phone number.
| Param | Type | Description |
| ------------- | ---------------------------------------- | ------------------------------ |
| client | Client | Authenticated AIMA client |
| searchType | 'email' \| 'username' \| 'phoneNumber' | Search field |
| searchQuery | string | Value to search for |
| types | PersonalInformationUserType[] | Personal info types to include |
getProfilePersonalInfoById
getProfilePersonalInfoById(client: Client, userId: string, profileId: string, types: PersonalInformationProfileType[]): Promise<PersonalInformationProfile>Returns personal information for a user profile.
| Param | Type | Description |
| ----------- | ---------------------------------- | ------------------------------ |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| profileId | string | Profile identifier |
| types | PersonalInformationProfileType[] | Personal info types to include |
getRegistrationOverview
getRegistrationOverview(client: Client, userId: string): Promise<UserServiceRegistration>Returns the service registration overview for a single user.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
getUserById
getUserById(client: Client, id: string, addAccountStatus?: boolean): Promise<User>Fetches a user by ID. Pass addAccountStatus: true to fetch extra account status data.
| Param | Type | Description |
| ------------------ | --------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | User identifier |
| addAccountStatus | boolean | Include account status |
getUserByEmail
getUserByEmail(client: Client, email: string): Promise<User>Fetches a user by email address.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| email | string | User email address |
getUserPersonalInfoById
getUserPersonalInfoById(client: Client, id: string, types: PersonalInformationUserType[]): Promise<PersonalInformationUser>Returns personal information for a user.
| Param | Type | Description |
| -------- | ------------------------------- | ------------------------------ |
| client | Client | Authenticated AIMA client |
| id | string | User identifier |
| types | PersonalInformationUserType[] | Personal info types to include |
getUsersPIByIds
getUsersPIByIds(client: Client, ids: string[], types: PersonalInformationUserType[]): Promise<PersonalInformationUser[]>Batch-fetches personal information for multiple users.
| Param | Type | Description |
| -------- | ------------------------------- | ------------------------------ |
| client | Client | Authenticated AIMA client |
| ids | string[] | User identifiers |
| types | PersonalInformationUserType[] | Personal info types to include |
getLabelsForUser
getLabelsForUser(client: Client, userId: string): Promise<Label[]>Returns all labels assigned to a user.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
addLabelForUser
addLabelForUser(client: Client, userId: string, labelId: number): Promise<void>Assigns a label to a user.
| Param | Type | Description |
| --------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| labelId | number | Label identifier |
removeLabelForUser
removeLabelForUser(client: Client, userId: string, labelId: number): Promise<void>Removes a label from a user.
| Param | Type | Description |
| --------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| labelId | number | Label identifier |
setServicesStatus
setServicesStatus(client: Client, profileId: string, servicesUpdate: ServicesUpdate): Promise<void>Updates service statuses for a profile.
| Param | Type | Description |
| ---------------- | ---------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| profileId | string | Profile identifier |
| servicesUpdate | ServicesUpdate | Service status changes |
registerUserToService
registerUserToService(client: Client, entityId: string, serviceId: string): Promise<void>Registers an entity to a service. Required for private services; optional for public ones.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| entityId | string | Entity identifier |
| serviceId | string | Service identifier |
updateProfilePersonalInfo
updateProfilePersonalInfo(client: Client, userId: string, profileId: string, actions: PatchAction<ProfilePaths>[]): Promise<void>Updates profile personal information using JSON Patch format.
| Param | Type | Description |
| ----------- | ----------------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| profileId | string | Profile identifier |
| actions | PatchAction<ProfilePaths>[] | JSON Patch operations |
updateUser
updateUser(client: Client, id: string, user: UserUpdateBody): Promise<User>Updates user account fields. Accepted fields: locale, accountStatus, dataPrivacyConsent, marketingConsent, surveyConsent, shareDataConsent, profilingConsent, membershipNumber.
| Param | Type | Description |
| -------- | ---------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| id | string | User identifier |
| user | UserUpdateBody | Fields to update |
updateUserPersonalInfo
updateUserPersonalInfo(client: Client, userId: string, actions: PatchAction<UserPaths>[]): Promise<void>Updates user personal information via JSON Patch on /phoneNumber, /email, or /idNumber.
| Param | Type | Description |
| --------- | ------------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userId | string | User identifier |
| actions | PatchAction<UserPaths>[]| JSON Patch operations |
getEntity
getEntity(client: Client, entityId: string): Promise<Entity>Returns a user entity by ID.
| Param | Type | Description |
| ---------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| entityId | string | Entity identifier |
getFleetBillingGroups
getFleetBillingGroups(client: Client, options?: PaginableOptions): Promise<PaginableResponse<BillingGroup>>Returns paginated billing groups for the fleet.
| Param | Type | Description |
| --------- | ----------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| options | PaginableOptions| Pagination options |
getUsersByIds
getUsersByIds(client: Client, ids: string[]): Promise<User[]>Batch-fetches users by their IDs.
| Param | Type | Description |
| -------- | ---------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| ids | string[] | User identifiers |
getUsers
getUsers(client: Client, options?: PaginableOptions<UserFilters, UserSort>): Promise<PaginableResponse<UserStatus>>Returns a paginated list of users with optional filters and sort.
| Param | Type | Description |
| --------- | ----------------------------------------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| options | PaginableOptions<UserFilters, UserSort> | Pagination, filters, sort |
getServiceRegistrationOverview
getServiceRegistrationOverview(client: Client, userIds: string[]): Promise<UserServiceRegistrationOverview[]>Batch-fetches service registration status for multiple users.
| Param | Type | Description |
| --------- | ---------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| userIds | string[] | User identifiers |
requestServiceRegistration
requestServiceRegistration(client: Client, profileId: string, serviceId: string): Promise<string>Requests service registration for a profile. Returns the registration request ID.
| Param | Type | Description |
| ----------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| profileId | string | Profile identifier |
| serviceId | string | Service identifier |
Types
User
Key fields: fleetId, id, registrationDate, agreements[], profiles[], dataPrivacyConsent, marketingConsent.
BillingGroup
{
id: string;
fleetId: string;
name: string;
discount: number;
overMileageCap: number;
overMileageRate: number;
}ServicesUpdate
{
disableEmailNotification: boolean;
operatorProfileId: string;
actions: {
reasonForChange: string;
serviceId: string;
status: string;
}[];
}Other exported types
UserProfile, Entity, Label, PersonalInformationUser, PersonalInformationProfile, UserServiceRegistration, UserServiceRegistrationOverview, UserFilters, UserSort, UserStatus, ResponseFind, CreateUser, CreateUserOptions, UserUpdateBody.
