diff --git a/src/__snapshots__/index.spec.ts.snap b/src/__snapshots__/index.spec.ts.snap index d5f407c..3086ae0 100644 --- a/src/__snapshots__/index.spec.ts.snap +++ b/src/__snapshots__/index.spec.ts.snap @@ -31,6 +31,8 @@ exports[`module exports > exposes the correct data from index.ts 1`] = ` "GetSystemCountryCodes": [Function], "GetSystemMessages": [Function], "GetTrackAndTrace": [Function], + "GetUser": [Function], + "GetUsers": [Function], "GetWebhookSubscriptions": [Function], "PatchSubscriptions": [Function], "PostApiKeys": [Function], diff --git a/src/endpoints/private/accounts/Account.types.ts b/src/endpoints/private/accounts/Account.types.ts index 528bfb9..04340f9 100644 --- a/src/endpoints/private/accounts/Account.types.ts +++ b/src/endpoints/private/accounts/Account.types.ts @@ -3,6 +3,7 @@ import {type PlatformId} from '@myparcel/constants'; import {type Address} from '@/types/common.types'; import {type PaginationParameters, type IntBoolean, type Price} from '@/types'; import {type MyParcelShop} from '@/endpoints/private/shops/Shop.types'; +import {type User} from '@/endpoints/private/users/User.types'; export interface AccountAdditionalInfo { ecommerce_platform: string; @@ -52,7 +53,7 @@ export interface MyParcelAccount { status: AccountStatus; terms_agreed: boolean; username: string; - users: Record; + users: User[]; } export type GetAccountsParams = PaginationParameters & { diff --git a/src/endpoints/private/index.ts b/src/endpoints/private/index.ts index b050322..ead6104 100644 --- a/src/endpoints/private/index.ts +++ b/src/endpoints/private/index.ts @@ -10,4 +10,5 @@ export * from './subscriptions'; export * from './system-country-codes'; export * from './system-messages'; export * from './track-traces'; +export * from './users'; export * from './webhook-subscriptions'; diff --git a/src/endpoints/private/users/GetUser.ts b/src/endpoints/private/users/GetUser.ts new file mode 100644 index 0000000..6adacf9 --- /dev/null +++ b/src/endpoints/private/users/GetUser.ts @@ -0,0 +1,17 @@ +import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; +import type {CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; +import type {User} from './User.types'; + +type GetUserDefinition = CreateDefinition<{ + name: typeof GetUser.name; + response: User[]; +}>; + +/** + * Retrieve single user by id. The endpoint can be called with multiple ids, separated by semicolon. + */ +export class GetUser extends AbstractPrivateEndpoint { + public readonly name = 'getUser'; + public readonly path = 'users/:id'; + public readonly property = 'users'; +} diff --git a/src/endpoints/private/users/GetUsers.ts b/src/endpoints/private/users/GetUsers.ts new file mode 100644 index 0000000..8e7b671 --- /dev/null +++ b/src/endpoints/private/users/GetUsers.ts @@ -0,0 +1,20 @@ +import {type CreateDefinition, PaginatedResponse} from '@/model/endpoint/AbstractEndpoint.types'; +import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; +import type {PaginationParameters} from '@/types'; +import type {User} from './User.types'; + + type GetUserDefinition = CreateDefinition<{ + name: typeof GetUsers.name; + parameters: PaginationParameters; + response: PaginatedResponse; + }>; + + /** + * Retrieve users. Accepts pagination parameters. + */ + export class GetUsers extends AbstractPrivateEndpoint { + public readonly name = 'getUsers'; + public readonly path = 'users'; + public readonly property = 'users'; + } + \ No newline at end of file diff --git a/src/endpoints/private/users/User.types.ts b/src/endpoints/private/users/User.types.ts new file mode 100644 index 0000000..cc04df6 --- /dev/null +++ b/src/endpoints/private/users/User.types.ts @@ -0,0 +1,38 @@ +export interface User { + id: number; + account_id: number; + username: string; + created: string; + remember_token: string | null; + all_shop_access: boolean; + sortPayload: number[]; + contact: Contact; + roles: Role[]; +} + +interface Contact { + id: number; + gender: string; + first_name: string; + last_name: string; + email: string; + phone: string | null; + company: string | null; + street: string; + number: string; + number_suffix: string; + box_number: string; + postal_code: string; + city: string; + cc: string | null; + street_additional_info: string; + region: string; +} + +interface Role { + id: number; + description: string; + name: string; + role_type: string; +} + \ No newline at end of file diff --git a/src/endpoints/private/users/index.ts b/src/endpoints/private/users/index.ts new file mode 100644 index 0000000..0da11eb --- /dev/null +++ b/src/endpoints/private/users/index.ts @@ -0,0 +1,2 @@ +export * from './GetUser'; +export * from './GetUsers';