-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoints: - account messages - accounts - api-key - carrier-options - locations - shipments - shops - subscriptiopn-capabilities - subscriptions - system-country-codes - track traces - webhook subscriptions
- Loading branch information
Showing
52 changed files
with
961 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {describe, expect, it} from 'vitest'; | ||
import * as Endpoints from '.'; | ||
|
||
describe('Endpoints', () => { | ||
it.each(Object.values(Endpoints))(`%o has required properties`, (Endpoint) => { | ||
const endpoint = new Endpoint(); | ||
expect(endpoint.name).not.toBeUndefined(); | ||
expect(endpoint.path).not.toBeUndefined(); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
src/endpoints/private/account-messages/AccountMessages.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
export interface MyParcelAccountMessage { | ||
id: number; | ||
account_id: number; | ||
code: number; | ||
message: string; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/endpoints/private/account-messages/DeleteAccountMessage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type HttpMethod} from '@/types'; | ||
|
||
type DeleteAccountMessageDefinition = CreateDefinition<{ | ||
name: typeof DeleteAccountMessage.name; | ||
path: { | ||
id: number; | ||
}; | ||
}>; | ||
|
||
/** | ||
* Deletes one system message by ID. | ||
*/ | ||
export class DeleteAccountMessage extends AbstractPrivateEndpoint<DeleteAccountMessageDefinition> { | ||
public readonly method: HttpMethod = 'DELETE'; | ||
public readonly name = 'deleteAccountMessage'; | ||
public readonly path = 'account_messages/:id'; | ||
public readonly property = 'messages'; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/endpoints/private/account-messages/GetAccountMessages.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type MyParcelAccountMessage} from './AccountMessages.types'; | ||
|
||
type GetAccountMessagesDefinition = CreateDefinition<{ | ||
name: typeof GetAccountMessages.name; | ||
parameters: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
account_id: number; | ||
}; | ||
response: MyParcelAccountMessage[]; | ||
}>; | ||
|
||
/** | ||
* Retrieve system messages. | ||
*/ | ||
export class GetAccountMessages extends AbstractPrivateEndpoint<GetAccountMessagesDefinition> { | ||
public readonly name = 'getAccountMessages'; | ||
public readonly path = 'account_messages'; | ||
public readonly property = 'messages'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './AccountMessages.types'; | ||
export * from './DeleteAccountMessage'; | ||
export * from './GetAccountMessages'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import {type Address} from '@/types/common.types'; | ||
import {type MyParcelShop} from '@/endpoints/private/shops/Shop.types'; | ||
import { IntBoolean, Price } from '@/types'; | ||
|
||
export interface AccountAdditionalInfo { | ||
ecommerce_platform: string; | ||
phone: string; | ||
coupon: string; | ||
} | ||
|
||
export interface AccountSettings { | ||
affiliate_bcc: IntBoolean; | ||
affiliate_fee: Price; | ||
is_test: IntBoolean; | ||
order_mode: IntBoolean; | ||
order_feature: boolean; | ||
order_Settings: { | ||
shipment_label: 'apart' | 'nested' | 'none'; | ||
}; | ||
show_cumulio_dashboard: IntBoolean; | ||
has_carrier_contract: IntBoolean; | ||
has_carrier_mail_contract: IntBoolean; | ||
use_mfa: IntBoolean; | ||
} | ||
|
||
export interface MyParcelAccount { | ||
additional_info: AccountAdditionalInfo; | ||
carrier_references: []; | ||
contact_id: number; | ||
contact: Record<string, string>; | ||
created: string; | ||
delivery_address: null | Address; | ||
email: string; | ||
first_name: string; | ||
gender: string; | ||
general_Settings: AccountSettings; | ||
id: number; | ||
last_name: string; | ||
modified: string; | ||
origin_id: number; | ||
phone: string; | ||
platform_id: number; | ||
shipment_estimates: Record<string, unknown>; | ||
shops: MyParcelShop[]; | ||
status: number; | ||
terms_agreed: boolean; | ||
username: string; | ||
users: Record<string, unknown>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type MyParcelAccount} from './Account.types'; | ||
|
||
type GetAccountDefinition = CreateDefinition<{ | ||
name: typeof GetAccount.name; | ||
path: { | ||
id: number; | ||
}; | ||
response: [MyParcelAccount]; | ||
}>; | ||
|
||
/** | ||
* Retrieve a single account object by ID. | ||
*/ | ||
export class GetAccount extends AbstractPrivateEndpoint<GetAccountDefinition> { | ||
public readonly name = 'getAccount'; | ||
public readonly path = 'accounts/:id'; | ||
public readonly property = 'accounts'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type HttpMethod} from '@/types'; | ||
import {type MyParcelAccount} from './Account.types'; | ||
|
||
type PutAccountDefinition = CreateDefinition<{ | ||
name: typeof PutAccount.name; | ||
path: { | ||
id: number; | ||
}; | ||
response: MyParcelAccount[]; | ||
}>; | ||
|
||
export class PutAccount extends AbstractPrivateEndpoint<PutAccountDefinition> { | ||
public readonly method: HttpMethod = 'PUT'; | ||
public readonly name = 'putAccount'; | ||
public readonly path = 'accounts'; | ||
public readonly property = 'accounts'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './Account.types'; | ||
export * from './GetAccount'; | ||
export * from './PutAccount'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
export interface MyParcelApiKey { | ||
id: number; | ||
account_id: number; | ||
shop_id: number; | ||
status: number; | ||
username: string; | ||
key: string; | ||
} | ||
|
||
export interface ApiKeyPostData { | ||
account_id: number; | ||
shop_id: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type MyParcelApiKey} from './ApiKey.types'; | ||
|
||
type GetApiKeysDefinition = CreateDefinition<{ | ||
name: typeof GetApiKeys.name; | ||
response: MyParcelApiKey[]; | ||
}>; | ||
|
||
/** | ||
* Retrieve all API keys. | ||
*/ | ||
export class GetApiKeys extends AbstractPrivateEndpoint<GetApiKeysDefinition> { | ||
public readonly name = 'getApiKeys'; | ||
public readonly path = 'keys'; | ||
public readonly property = 'api_keys'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {type ApiKeyPostData, type MyParcelApiKey} from './ApiKey.types'; | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type HttpMethod} from '@/types'; | ||
|
||
type PostApiKeyDefinition = CreateDefinition<{ | ||
name: typeof PostApiKeys.name; | ||
body: ApiKeyPostData[]; | ||
response: MyParcelApiKey[]; | ||
}>; | ||
|
||
/** | ||
* Submit a single new key. | ||
*/ | ||
export class PostApiKeys extends AbstractPrivateEndpoint<PostApiKeyDefinition> { | ||
public readonly method: HttpMethod = 'POST'; | ||
public readonly name = 'postApiKeys'; | ||
public readonly path = 'keys'; | ||
public readonly property = 'api_keys'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './ApiKey.types'; | ||
export * from './GetApiKeys'; | ||
export * from './PostApiKeys'; |
39 changes: 39 additions & 0 deletions
39
src/endpoints/private/carrier-options/CarrierOption.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import {type CarrierId, type CarrierName} from '@myparcel/constants'; | ||
import {type IntBoolean} from '@/types'; | ||
|
||
export interface MyParcelCarrierOption { | ||
api_key: string; | ||
carrier: { | ||
id: CarrierId; | ||
name: CarrierName; | ||
}; | ||
carrier_id: CarrierId; | ||
enabled: IntBoolean; | ||
id: number; | ||
optional: IntBoolean; | ||
options: { | ||
customerCode: string; | ||
customerNumber: string; | ||
customerCollectionLocation: string; | ||
serviceLevels: number; | ||
barcodeOptions: { | ||
gpType: string; | ||
gpRange: string; | ||
}; | ||
}; | ||
password: string; | ||
primary: IntBoolean; | ||
type: 'main' | 'custom'; | ||
username: string; | ||
subscription_id?: number; | ||
label?: string; | ||
} | ||
|
||
export interface CarrierOptionPostData { | ||
carrier_id: CarrierId; | ||
username?: string; | ||
password?: string; | ||
options?: Record<string, unknown>; | ||
api_key?: string; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/endpoints/private/carrier-options/DeleteCarrierOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CarrierId} from '@myparcel/constants'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type HttpMethod} from '@/types'; | ||
|
||
type DeleteCarrierOptionsDefinition = CreateDefinition<{ | ||
name: typeof DeleteCarrierOptions.name; | ||
path: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
carrier_id: CarrierId; | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
account_id: number; | ||
}; | ||
}>; | ||
|
||
export class DeleteCarrierOptions extends AbstractPrivateEndpoint<DeleteCarrierOptionsDefinition> { | ||
public readonly method: HttpMethod = 'DELETE'; | ||
public readonly name = 'deleteCarrierOption'; | ||
public readonly path = 'accounts/:account_id/carrier_options/:carrier_id'; | ||
public readonly property = 'carrier_options'; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/endpoints/private/carrier-options/GetCarrierOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
import {type MyParcelCarrierOption} from './CarrierOption.types'; | ||
|
||
type GetCarrierOptionsDefinition = CreateDefinition<{ | ||
name: typeof GetCarrierOptions.name; | ||
parameters: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
account_id: number; | ||
}; | ||
response: MyParcelCarrierOption[]; | ||
}>; | ||
|
||
export class GetCarrierOptions extends AbstractPrivateEndpoint<GetCarrierOptionsDefinition> { | ||
public readonly name = 'getCarrierOptions'; | ||
public readonly path = 'carrier_management/accounts/:account_id/carrier_options'; | ||
public readonly property = 'carrier_options'; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/endpoints/private/carrier-options/PostCarrierOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {type HttpMethod} from '@/types'; | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CarrierOptionPostData} from './CarrierOption.types'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
|
||
type PostCarrierOptionsDefinition = CreateDefinition<{ | ||
name: typeof PostCarrierOptions.name; | ||
body: CarrierOptionPostData[]; | ||
response: {id: number}[]; | ||
}>; | ||
|
||
export class PostCarrierOptions extends AbstractPrivateEndpoint<PostCarrierOptionsDefinition> { | ||
public readonly method: HttpMethod = 'POST'; | ||
public readonly name = 'postCarrierOptions'; | ||
public readonly path = 'accounts/:account_id/carrier_options'; | ||
public readonly property = 'carrier_options'; | ||
public readonly responseProperty = 'ids'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './CarrierOption.types'; | ||
export * from './DeleteCarrierOptions'; | ||
export * from './GetCarrierOptions'; | ||
export * from './PostCarrierOptions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
export * from './account-messages'; | ||
export * from './accounts'; | ||
export * from './api-key'; | ||
export * from './carrier-options'; | ||
export * from './locations'; | ||
export * from './shipments'; | ||
export * from './shops'; | ||
export * from './subscriptions'; | ||
export * from './system-country-codes'; | ||
export * from './system-messages'; | ||
export * from './webhook-subscriptions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {type LocationParameters, type MyParcelLocation} from './Location.types'; | ||
import {AbstractPrivateEndpoint} from '@/model/endpoint/AbstractPrivateEndpoint'; | ||
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types'; | ||
|
||
type GetLocationsDefinition = CreateDefinition<{ | ||
name: typeof GetLocations.name; | ||
parameters: LocationParameters; | ||
response: MyParcelLocation[]; | ||
}>; | ||
|
||
export class GetLocations extends AbstractPrivateEndpoint<GetLocationsDefinition> { | ||
public readonly name = 'getLocations'; | ||
public readonly path = 'locations'; | ||
public readonly property = 'locations'; | ||
} |
Oops, something went wrong.