-
Notifications
You must be signed in to change notification settings - Fork 7
/
client.ts
77 lines (73 loc) · 1.94 KB
/
client.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {type ClientConfiguration, createAxiosInstance, type RateLimit} from '@sp-api-sdk/common'
import {Configuration, ShippingApi} from './api-model'
export const clientRateLimits: RateLimit[] = [
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/shipments$'),
rate: 5,
burst: 15,
},
{
method: 'get',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/shipments/[^/]*$'),
rate: 5,
burst: 15,
},
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/shipments/[^/]*/cancel$'),
rate: 5,
burst: 15,
},
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/shipments/[^/]*/purchaseLabels$'),
rate: 5,
burst: 15,
},
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/shipments/[^/]*/label$'),
rate: 5,
burst: 15,
},
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/purchaseShipment$'),
rate: 5,
burst: 15,
},
{
method: 'post',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/rates$'),
rate: 5,
burst: 15,
},
{
method: 'get',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/account$'),
rate: 5,
burst: 15,
},
{
method: 'get',
// eslint-disable-next-line prefer-regex-literals
urlRegex: new RegExp('^/shipping/v1/tracking/[^/]*$'),
rate: 1,
burst: 1,
},
]
export class ShippingApiClient extends ShippingApi {
constructor(configuration: ClientConfiguration) {
const {axios, endpoint} = createAxiosInstance(configuration, clientRateLimits)
super(new Configuration(), endpoint, axios)
}
}