Skip to content

Commit

Permalink
feat: add types for carrier options parameters (#165)
Browse files Browse the repository at this point in the history
Path was not typed correctly
add parameter types
  • Loading branch information
Cysword authored Apr 16, 2024
1 parent 5c80d3f commit 33e5624
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/endpoints/private/carrier-options/CarrierOption.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {type CarrierId, type CarrierName} from '@myparcel/constants';
import {type IntBoolean} from '@/types';

export interface MyParcelCarrierOption {
export type MyParcelCarrierOption = {
api_key: string;
carrier: {
id: CarrierId;
Expand All @@ -28,17 +28,25 @@ export interface MyParcelCarrierOption {
username: string;
subscription_id?: number;
label?: string;
}
};

export interface CarrierOptionPostData {
export type CarrierOptionPostData = {
carrier_id: CarrierId;
username?: string;
password?: string;
options?: Record<string, unknown>;
api_key?: string;
}
};

export interface CarrierOptionPutData {
export type CarrierOptionPutData = {
carrier_id: CarrierId;
enabled: IntBoolean;
}
};

export type CarrierOptionsParameters = {
enabled?: IntBoolean;
// You can pass multiple carrier_ids in a string when joined with `;`
carrier_id?: CarrierId | string;
subscription_id?: number;
type: 'main' | 'custom';
};
5 changes: 3 additions & 2 deletions src/endpoints/private/carrier-options/GetCarrierOptions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {type MyParcelCarrierOption, type CarrierOptionsParameters} from './CarrierOption.types';
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: {
path: {
// eslint-disable-next-line @typescript-eslint/naming-convention
account_id: number;
};
parameters: CarrierOptionsParameters;
response: MyParcelCarrierOption[];
}>;

Expand Down

0 comments on commit 33e5624

Please sign in to comment.