Skip to content

Commit

Permalink
feat: add getAccounts endpoint (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cysword committed Dec 21, 2023
1 parent e948c1d commit 4f98d5b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`module exports > exposes the correct data from index.ts 1`] = `
"FetchClient": [Function],
"GetAccount": [Function],
"GetAccountMessages": [Function],
"GetAccounts": [Function],
"GetApiKeys": [Function],
"GetCarrier": [Function],
"GetCarrierOptions": [Function],
Expand Down
15 changes: 13 additions & 2 deletions src/endpoints/private/accounts/Account.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */
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 { IntBoolean, Price } from '@/types';

export interface AccountAdditionalInfo {
ecommerce_platform: string;
Expand All @@ -24,6 +25,8 @@ export interface AccountSettings {
use_mfa: IntBoolean;
}

export type AccountStatus = 1 | 2 | 3 | 4;

export interface MyParcelAccount {
additional_info: AccountAdditionalInfo;
carrier_references: [];
Expand All @@ -43,8 +46,16 @@ export interface MyParcelAccount {
platform_id: number;
shipment_estimates: Record<string, unknown>;
shops: MyParcelShop[];
status: number;
status: AccountStatus;
terms_agreed: boolean;
username: string;
users: Record<string, unknown>;
}

export type GetAccountsParams = PaginationParameters & {
status?: AccountStatus;
from?: string;
to?: string;
q?: string;
platform_id?: PlatformId;
};
14 changes: 14 additions & 0 deletions src/endpoints/private/accounts/GetAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {type GetAccountsParams, type MyParcelAccount} from './Account.types';
import {AbstractPrivateEndpoint, type CreateDefinition, type PaginatedResponse} from '@/model';

type GetAccountsDefinition = CreateDefinition<{
name: typeof GetAccounts.name;
parameters: GetAccountsParams;
response: PaginatedResponse<MyParcelAccount[]>;
}>;

export class GetAccounts extends AbstractPrivateEndpoint<GetAccountsDefinition> {
public readonly name = 'getAccounts';
public readonly path = 'accounts';
public readonly property = 'accounts';
}
1 change: 1 addition & 0 deletions src/endpoints/private/accounts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './Account.types';
export * from './GetAccount';
export * from './GetAccounts';
export * from './PutAccount';

0 comments on commit 4f98d5b

Please sign in to comment.