From 7b4357a753dc18b706efdc5d2741626f412963f4 Mon Sep 17 00:00:00 2001 From: Remco Horters Date: Mon, 8 Apr 2024 10:20:40 +0200 Subject: [PATCH 1/3] feat: add types for carrier options parameters --- .../private/carrier-options/CarrierOption.types.ts | 8 ++++++++ .../private/carrier-options/GetCarrierOptions.ts | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/endpoints/private/carrier-options/CarrierOption.types.ts b/src/endpoints/private/carrier-options/CarrierOption.types.ts index 1203004..e189028 100644 --- a/src/endpoints/private/carrier-options/CarrierOption.types.ts +++ b/src/endpoints/private/carrier-options/CarrierOption.types.ts @@ -42,3 +42,11 @@ export interface CarrierOptionPutData { carrier_id: CarrierId; enabled: IntBoolean; } + +export interface 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'; +} diff --git a/src/endpoints/private/carrier-options/GetCarrierOptions.ts b/src/endpoints/private/carrier-options/GetCarrierOptions.ts index 28f3e3c..e2a9826 100644 --- a/src/endpoints/private/carrier-options/GetCarrierOptions.ts +++ b/src/endpoints/private/carrier-options/GetCarrierOptions.ts @@ -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[]; }>; From c2ca4089e17309b28b027b6e48e0bb2ab0d4323b Mon Sep 17 00:00:00 2001 From: Remco Horters Date: Tue, 16 Apr 2024 16:54:46 +0200 Subject: [PATCH 2/3] interface to type --- src/endpoints/private/carrier-options/CarrierOption.types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/endpoints/private/carrier-options/CarrierOption.types.ts b/src/endpoints/private/carrier-options/CarrierOption.types.ts index e189028..47fa45d 100644 --- a/src/endpoints/private/carrier-options/CarrierOption.types.ts +++ b/src/endpoints/private/carrier-options/CarrierOption.types.ts @@ -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; @@ -28,7 +28,7 @@ export interface MyParcelCarrierOption { username: string; subscription_id?: number; label?: string; -} +}; export interface CarrierOptionPostData { carrier_id: CarrierId; From cf3d494226d5b25542f5092fb2dd4b671c5a7554 Mon Sep 17 00:00:00 2001 From: Remco Horters Date: Tue, 16 Apr 2024 17:03:24 +0200 Subject: [PATCH 3/3] all interfaces to types --- .../private/carrier-options/CarrierOption.types.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/endpoints/private/carrier-options/CarrierOption.types.ts b/src/endpoints/private/carrier-options/CarrierOption.types.ts index 47fa45d..5d6a9fe 100644 --- a/src/endpoints/private/carrier-options/CarrierOption.types.ts +++ b/src/endpoints/private/carrier-options/CarrierOption.types.ts @@ -30,23 +30,23 @@ export type MyParcelCarrierOption = { label?: string; }; -export interface CarrierOptionPostData { +export type CarrierOptionPostData = { carrier_id: CarrierId; username?: string; password?: string; options?: Record; api_key?: string; -} +}; -export interface CarrierOptionPutData { +export type CarrierOptionPutData = { carrier_id: CarrierId; enabled: IntBoolean; -} +}; -export interface CarrierOptionsParameters { +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'; -} +};