-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasisTheoryProxies.ts
40 lines (36 loc) · 1.24 KB
/
BasisTheoryProxies.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
import type { AxiosTransformer } from 'axios';
import {
transformProxyResponseCamelCase,
transformProxyRequestSnakeCase,
} from '@/common/utils';
import { BasisTheoryService } from '@/service';
import type { BasisTheoryServiceOptions } from '@/service';
import { CrudBuilder } from '@/service/CrudBuilder';
import type { CreateProxy, UpdateProxy, Proxy } from '@/types/models';
import type { ListProxyQuery } from '@/types/sdk';
export const BasisTheoryProxies = new CrudBuilder(
class BasisTheoryProxies extends BasisTheoryService {
public constructor(options: BasisTheoryServiceOptions) {
const _options = {
...options,
};
// eslint-disable-next-line unicorn/prefer-spread
_options.transformRequest = ([] as AxiosTransformer[]).concat(
transformProxyRequestSnakeCase,
options.transformRequest || []
);
// eslint-disable-next-line unicorn/prefer-spread
_options.transformResponse = ([] as AxiosTransformer[]).concat(
transformProxyResponseCamelCase,
options.transformResponse || []
);
super(_options);
}
}
)
.create<Proxy, CreateProxy>()
.retrieve<Proxy>()
.update<Proxy, UpdateProxy>()
.delete()
.list<Proxy, ListProxyQuery>()
.build();