-
Notifications
You must be signed in to change notification settings - Fork 2
/
GetDeliveryOptions.ts
63 lines (57 loc) · 1.99 KB
/
GetDeliveryOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {
type CarrierNameOrId,
type DeliveryTypeId,
type PackageTypeName,
type PlatformNameOrId,
} from '@myparcel/constants';
import {type RequestHeaders} from '@/types/request.types';
import {type WithRequired} from '@/types/global.types';
import {AbstractPublicEndpoint} from '@/model/endpoint/AbstractPublicEndpoint';
import {type CreateDefinition} from '@/model/endpoint/AbstractEndpoint.types';
import {type DeliveryOption} from '@/endpoints/public/delivery-options/DeliveryOption.types';
type Parameters = {
/* eslint-disable @typescript-eslint/naming-convention */
carrier: CarrierNameOrId;
cc: string;
platform: PlatformNameOrId;
postal_code: string;
city?: string;
cutoff_time?: string;
delivery_date?: string;
delivery_time?: string;
deliverydays_window?: number;
dropoff_days?: string;
dropoff_delay?: number;
exclude_delivery_type?: DeliveryTypeId;
exclude_parcel_lockers?: boolean;
include?: 'shipment_options' | string;
latitude?: string;
longitude?: string;
monday_delivery?: boolean;
number?: number;
package_type?: PackageTypeName;
saturday_delivery?: boolean;
same_day_delivery?: boolean;
street?: string;
/* eslint-enable @typescript-eslint/naming-convention */
};
/**
* Either number or full street is required.
*/
export type DeliveryOptionsParameters = WithRequired<Parameters, 'number'> | WithRequired<Parameters, 'street'>;
type GetDeliveryOptionsDefinition = CreateDefinition<{
name: typeof GetDeliveryOptions.name;
parameters: DeliveryOptionsParameters;
response: DeliveryOption[];
}>;
/**
* Get available delivery options for given location. Note: This calls version 2 of the endpoint.
*/
export class GetDeliveryOptions extends AbstractPublicEndpoint<GetDeliveryOptionsDefinition> {
public readonly name = 'getDeliveryOptions';
public readonly path = 'delivery_options';
public readonly property = 'deliveries';
public getHeaders(): RequestHeaders {
return {...super.getHeaders(), Accept: 'application/json;version=2.0'};
}
}