@swishapp/api-client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/client/client.gen.d.ts +12 -0
- package/dist/client/client.gen.js +5 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +3 -0
- package/dist/client/sdk.gen.d.ts +39 -0
- package/dist/client/sdk.gen.js +82 -0
- package/dist/client/types.gen.d.ts +440 -0
- package/dist/client/types.gen.js +2 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +42 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Swish API Client
|
|
2
|
+
|
|
3
|
+
A JavaScript client for the Swish API with TypeScript support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @swish/api-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { SwishClient } from "@swish/api-client";
|
|
15
|
+
|
|
16
|
+
const client = new SwishClient({
|
|
17
|
+
apiKey: "your-api-key",
|
|
18
|
+
shop: "your-shopify-shop-name.myshopify.com",
|
|
19
|
+
key: "gid://shopify/Customer/123456789",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { data } = await client.items.list();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
For more information on the Swish API, see the [Swish API documentation](https://docs.swish.app).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClientOptions } from './types.gen';
|
|
2
|
+
import { type Config, type ClientOptions as DefaultClientOptions } from '@hey-api/client-fetch';
|
|
3
|
+
/**
|
|
4
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
+
* and the returned object will become the client's initial configuration.
|
|
6
|
+
*
|
|
7
|
+
* You may want to initialize your client this way instead of calling
|
|
8
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
+
* to ensure your client always has the correct values.
|
|
10
|
+
*/
|
|
11
|
+
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
|
|
12
|
+
export declare const client: import("@hey-api/client-fetch").Client;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
+
import type { ListControllerFindAllData, ListControllerCreateOneData, ListControllerDeleteOneData, ListControllerFindOneData, ListControllerUpdateOneData, ItemControllerDeleteManyData, ItemControllerFindAllData, ItemControllerCreateManyData, ItemControllerDeleteOneData, ItemControllerUpdateOneData } from './types.gen';
|
|
3
|
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
|
+
/**
|
|
5
|
+
* You can provide a client instance returned by `createClient()` instead of
|
|
6
|
+
* individual options. This might be also useful if you want to implement a
|
|
7
|
+
* custom client.
|
|
8
|
+
*/
|
|
9
|
+
client?: Client;
|
|
10
|
+
/**
|
|
11
|
+
* You can pass arbitrary values through the `meta` object. This can be
|
|
12
|
+
* used to access values that aren't defined as part of the SDK function.
|
|
13
|
+
*/
|
|
14
|
+
meta?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
export declare const listControllerFindAll: <ThrowOnError extends boolean = false>(options: Options<ListControllerFindAllData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").PaginatedResponseDto & {
|
|
17
|
+
data?: Array<import("./types.gen").List>;
|
|
18
|
+
}, unknown, ThrowOnError>;
|
|
19
|
+
export declare const listControllerCreateOne: <ThrowOnError extends boolean = false>(options: Options<ListControllerCreateOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ResponseDto & {
|
|
20
|
+
data?: import("./types.gen").List;
|
|
21
|
+
}, unknown, ThrowOnError>;
|
|
22
|
+
export declare const listControllerDeleteOne: <ThrowOnError extends boolean = false>(options: Options<ListControllerDeleteOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, unknown, ThrowOnError>;
|
|
23
|
+
export declare const listControllerFindOne: <ThrowOnError extends boolean = false>(options: Options<ListControllerFindOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ResponseDto & {
|
|
24
|
+
data?: import("./types.gen").List;
|
|
25
|
+
}, unknown, ThrowOnError>;
|
|
26
|
+
export declare const listControllerUpdateOne: <ThrowOnError extends boolean = false>(options: Options<ListControllerUpdateOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ResponseDto & {
|
|
27
|
+
data?: import("./types.gen").List;
|
|
28
|
+
}, unknown, ThrowOnError>;
|
|
29
|
+
export declare const itemControllerDeleteMany: <ThrowOnError extends boolean = false>(options: Options<ItemControllerDeleteManyData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, unknown, ThrowOnError>;
|
|
30
|
+
export declare const itemControllerFindAll: <ThrowOnError extends boolean = false>(options: Options<ItemControllerFindAllData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").PaginatedResponseDto & {
|
|
31
|
+
data?: Array<import("./types.gen").Item>;
|
|
32
|
+
}, unknown, ThrowOnError>;
|
|
33
|
+
export declare const itemControllerCreateMany: <ThrowOnError extends boolean = false>(options: Options<ItemControllerCreateManyData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ResponseDto & {
|
|
34
|
+
data?: Array<import("./types.gen").Item>;
|
|
35
|
+
}, unknown, ThrowOnError>;
|
|
36
|
+
export declare const itemControllerDeleteOne: <ThrowOnError extends boolean = false>(options: Options<ItemControllerDeleteOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, unknown, ThrowOnError>;
|
|
37
|
+
export declare const itemControllerUpdateOne: <ThrowOnError extends boolean = false>(options: Options<ItemControllerUpdateOneData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").ResponseDto & {
|
|
38
|
+
data?: import("./types.gen").Item;
|
|
39
|
+
}, unknown, ThrowOnError>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { client as _heyApiClient } from './client.gen';
|
|
3
|
+
export const listControllerFindAll = (options) => {
|
|
4
|
+
return (options.client ?? _heyApiClient).get({
|
|
5
|
+
url: '/lists',
|
|
6
|
+
...options
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export const listControllerCreateOne = (options) => {
|
|
10
|
+
return (options.client ?? _heyApiClient).post({
|
|
11
|
+
url: '/lists',
|
|
12
|
+
...options,
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
...options?.headers
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const listControllerDeleteOne = (options) => {
|
|
20
|
+
return (options.client ?? _heyApiClient).delete({
|
|
21
|
+
url: '/lists/{listId}',
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const listControllerFindOne = (options) => {
|
|
26
|
+
return (options.client ?? _heyApiClient).get({
|
|
27
|
+
url: '/lists/{listId}',
|
|
28
|
+
...options
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export const listControllerUpdateOne = (options) => {
|
|
32
|
+
return (options.client ?? _heyApiClient).patch({
|
|
33
|
+
url: '/lists/{listId}',
|
|
34
|
+
...options,
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
...options?.headers
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export const itemControllerDeleteMany = (options) => {
|
|
42
|
+
return (options.client ?? _heyApiClient).delete({
|
|
43
|
+
url: '/items',
|
|
44
|
+
...options,
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
...options?.headers
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const itemControllerFindAll = (options) => {
|
|
52
|
+
return (options.client ?? _heyApiClient).get({
|
|
53
|
+
url: '/items',
|
|
54
|
+
...options
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export const itemControllerCreateMany = (options) => {
|
|
58
|
+
return (options.client ?? _heyApiClient).post({
|
|
59
|
+
url: '/items',
|
|
60
|
+
...options,
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
...options?.headers
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export const itemControllerDeleteOne = (options) => {
|
|
68
|
+
return (options.client ?? _heyApiClient).delete({
|
|
69
|
+
url: '/items/{itemId}',
|
|
70
|
+
...options
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
export const itemControllerUpdateOne = (options) => {
|
|
74
|
+
return (options.client ?? _heyApiClient).patch({
|
|
75
|
+
url: '/items/{itemId}',
|
|
76
|
+
...options,
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
...options?.headers
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
export type List = {
|
|
2
|
+
/**
|
|
3
|
+
* The ID of the list
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* The name of the list
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the list is readonly
|
|
12
|
+
*/
|
|
13
|
+
readonly: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The date and time the list was created
|
|
16
|
+
*/
|
|
17
|
+
createdAt: string;
|
|
18
|
+
/**
|
|
19
|
+
* The date and time the list was updated
|
|
20
|
+
*/
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
};
|
|
23
|
+
export type PageInfoDto = {
|
|
24
|
+
/**
|
|
25
|
+
* The cursor for the next page
|
|
26
|
+
*/
|
|
27
|
+
next: {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* The cursor for the previous page
|
|
32
|
+
*/
|
|
33
|
+
previous: {
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
} | null;
|
|
36
|
+
};
|
|
37
|
+
export type PaginatedResponseDto = {
|
|
38
|
+
pageInfo: PageInfoDto;
|
|
39
|
+
};
|
|
40
|
+
export type ResponseDto = {
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
export type CreateListDto = {
|
|
44
|
+
/**
|
|
45
|
+
* The name of the list
|
|
46
|
+
*/
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
export type UpdateListDto = {
|
|
50
|
+
/**
|
|
51
|
+
* The name of the list
|
|
52
|
+
*/
|
|
53
|
+
name: string;
|
|
54
|
+
};
|
|
55
|
+
export type Item = {
|
|
56
|
+
/**
|
|
57
|
+
* The ID of the item
|
|
58
|
+
*/
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* The Shopify ID of the product
|
|
62
|
+
*/
|
|
63
|
+
productId: number;
|
|
64
|
+
/**
|
|
65
|
+
* The Shopify ID of the variant
|
|
66
|
+
*/
|
|
67
|
+
variantId: {
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The quantity of the item in the list
|
|
72
|
+
*/
|
|
73
|
+
quantity: number;
|
|
74
|
+
/**
|
|
75
|
+
* The date and time the item was created
|
|
76
|
+
*/
|
|
77
|
+
createdAt: string;
|
|
78
|
+
/**
|
|
79
|
+
* The date and time the item was updated
|
|
80
|
+
*/
|
|
81
|
+
updatedAt: string;
|
|
82
|
+
};
|
|
83
|
+
export type NewItemDto = {
|
|
84
|
+
/**
|
|
85
|
+
* The Shopify ID of the product
|
|
86
|
+
*/
|
|
87
|
+
productId: number;
|
|
88
|
+
/**
|
|
89
|
+
* The Shopify ID of the variant
|
|
90
|
+
*/
|
|
91
|
+
variantId: number;
|
|
92
|
+
/**
|
|
93
|
+
* The quantity of the item
|
|
94
|
+
*/
|
|
95
|
+
quantity: number;
|
|
96
|
+
};
|
|
97
|
+
export type CreateItemsDto = {
|
|
98
|
+
items: Array<NewItemDto>;
|
|
99
|
+
};
|
|
100
|
+
export type ItemDto = {
|
|
101
|
+
/**
|
|
102
|
+
* The ID of the item
|
|
103
|
+
*/
|
|
104
|
+
id: string;
|
|
105
|
+
};
|
|
106
|
+
export type DeleteItemsDto = {
|
|
107
|
+
items: Array<ItemDto>;
|
|
108
|
+
};
|
|
109
|
+
export type UpdateItemDto = {
|
|
110
|
+
/**
|
|
111
|
+
* The Shopify ID of the product
|
|
112
|
+
*/
|
|
113
|
+
productId: number;
|
|
114
|
+
/**
|
|
115
|
+
* The Shopify ID of the variant
|
|
116
|
+
*/
|
|
117
|
+
variantId: number;
|
|
118
|
+
};
|
|
119
|
+
export type ListControllerFindAllData = {
|
|
120
|
+
body?: never;
|
|
121
|
+
headers: {
|
|
122
|
+
/**
|
|
123
|
+
* Your Swish API key
|
|
124
|
+
*/
|
|
125
|
+
Authorization: string;
|
|
126
|
+
/**
|
|
127
|
+
* The shop domain
|
|
128
|
+
*/
|
|
129
|
+
Shop: string;
|
|
130
|
+
/**
|
|
131
|
+
* The profile key
|
|
132
|
+
*/
|
|
133
|
+
Key: string;
|
|
134
|
+
};
|
|
135
|
+
path?: never;
|
|
136
|
+
query?: {
|
|
137
|
+
/**
|
|
138
|
+
* The pagination cursor
|
|
139
|
+
*/
|
|
140
|
+
cursor?: string;
|
|
141
|
+
};
|
|
142
|
+
url: '/lists';
|
|
143
|
+
};
|
|
144
|
+
export type ListControllerFindAllResponses = {
|
|
145
|
+
/**
|
|
146
|
+
* Returns all lists as paginated response
|
|
147
|
+
*/
|
|
148
|
+
200: PaginatedResponseDto & {
|
|
149
|
+
data?: Array<List>;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type ListControllerFindAllResponse = ListControllerFindAllResponses[keyof ListControllerFindAllResponses];
|
|
153
|
+
export type ListControllerCreateOneData = {
|
|
154
|
+
body: CreateListDto;
|
|
155
|
+
headers: {
|
|
156
|
+
/**
|
|
157
|
+
* Your Swish API key
|
|
158
|
+
*/
|
|
159
|
+
Authorization: string;
|
|
160
|
+
/**
|
|
161
|
+
* The shop domain
|
|
162
|
+
*/
|
|
163
|
+
Shop: string;
|
|
164
|
+
/**
|
|
165
|
+
* The profile key
|
|
166
|
+
*/
|
|
167
|
+
Key: string;
|
|
168
|
+
};
|
|
169
|
+
path?: never;
|
|
170
|
+
query?: never;
|
|
171
|
+
url: '/lists';
|
|
172
|
+
};
|
|
173
|
+
export type ListControllerCreateOneResponses = {
|
|
174
|
+
/**
|
|
175
|
+
* The list has been successfully created.
|
|
176
|
+
*/
|
|
177
|
+
201: ResponseDto & {
|
|
178
|
+
data?: List;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export type ListControllerCreateOneResponse = ListControllerCreateOneResponses[keyof ListControllerCreateOneResponses];
|
|
182
|
+
export type ListControllerDeleteOneData = {
|
|
183
|
+
body?: never;
|
|
184
|
+
headers: {
|
|
185
|
+
/**
|
|
186
|
+
* Your Swish API key
|
|
187
|
+
*/
|
|
188
|
+
Authorization: string;
|
|
189
|
+
/**
|
|
190
|
+
* The shop domain
|
|
191
|
+
*/
|
|
192
|
+
Shop: string;
|
|
193
|
+
/**
|
|
194
|
+
* The profile key
|
|
195
|
+
*/
|
|
196
|
+
Key: string;
|
|
197
|
+
};
|
|
198
|
+
path: {
|
|
199
|
+
/**
|
|
200
|
+
* The ID of the list
|
|
201
|
+
*/
|
|
202
|
+
listId: string;
|
|
203
|
+
};
|
|
204
|
+
query?: never;
|
|
205
|
+
url: '/lists/{listId}';
|
|
206
|
+
};
|
|
207
|
+
export type ListControllerDeleteOneResponses = {
|
|
208
|
+
/**
|
|
209
|
+
* The list has been successfully deleted.
|
|
210
|
+
*/
|
|
211
|
+
204: void;
|
|
212
|
+
};
|
|
213
|
+
export type ListControllerDeleteOneResponse = ListControllerDeleteOneResponses[keyof ListControllerDeleteOneResponses];
|
|
214
|
+
export type ListControllerFindOneData = {
|
|
215
|
+
body?: never;
|
|
216
|
+
headers: {
|
|
217
|
+
/**
|
|
218
|
+
* Your Swish API key
|
|
219
|
+
*/
|
|
220
|
+
Authorization: string;
|
|
221
|
+
/**
|
|
222
|
+
* The shop domain
|
|
223
|
+
*/
|
|
224
|
+
Shop: string;
|
|
225
|
+
/**
|
|
226
|
+
* The profile key
|
|
227
|
+
*/
|
|
228
|
+
Key: string;
|
|
229
|
+
};
|
|
230
|
+
path: {
|
|
231
|
+
/**
|
|
232
|
+
* The ID of the list
|
|
233
|
+
*/
|
|
234
|
+
listId: string;
|
|
235
|
+
};
|
|
236
|
+
query?: never;
|
|
237
|
+
url: '/lists/{listId}';
|
|
238
|
+
};
|
|
239
|
+
export type ListControllerFindOneResponses = {
|
|
240
|
+
/**
|
|
241
|
+
* The list has been successfully retrieved.
|
|
242
|
+
*/
|
|
243
|
+
200: ResponseDto & {
|
|
244
|
+
data?: List;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
export type ListControllerFindOneResponse = ListControllerFindOneResponses[keyof ListControllerFindOneResponses];
|
|
248
|
+
export type ListControllerUpdateOneData = {
|
|
249
|
+
body: UpdateListDto;
|
|
250
|
+
headers: {
|
|
251
|
+
/**
|
|
252
|
+
* Your Swish API key
|
|
253
|
+
*/
|
|
254
|
+
Authorization: string;
|
|
255
|
+
/**
|
|
256
|
+
* The shop domain
|
|
257
|
+
*/
|
|
258
|
+
Shop: string;
|
|
259
|
+
/**
|
|
260
|
+
* The profile key
|
|
261
|
+
*/
|
|
262
|
+
Key: string;
|
|
263
|
+
};
|
|
264
|
+
path: {
|
|
265
|
+
/**
|
|
266
|
+
* The ID of the list
|
|
267
|
+
*/
|
|
268
|
+
listId: string;
|
|
269
|
+
};
|
|
270
|
+
query?: never;
|
|
271
|
+
url: '/lists/{listId}';
|
|
272
|
+
};
|
|
273
|
+
export type ListControllerUpdateOneResponses = {
|
|
274
|
+
/**
|
|
275
|
+
* The list has been successfully updated.
|
|
276
|
+
*/
|
|
277
|
+
200: ResponseDto & {
|
|
278
|
+
data?: List;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
export type ListControllerUpdateOneResponse = ListControllerUpdateOneResponses[keyof ListControllerUpdateOneResponses];
|
|
282
|
+
export type ItemControllerDeleteManyData = {
|
|
283
|
+
body: DeleteItemsDto;
|
|
284
|
+
headers: {
|
|
285
|
+
/**
|
|
286
|
+
* Your Swish API key
|
|
287
|
+
*/
|
|
288
|
+
Authorization: string;
|
|
289
|
+
/**
|
|
290
|
+
* The shop domain
|
|
291
|
+
*/
|
|
292
|
+
Shop: string;
|
|
293
|
+
/**
|
|
294
|
+
* The profile key
|
|
295
|
+
*/
|
|
296
|
+
Key: string;
|
|
297
|
+
};
|
|
298
|
+
path?: never;
|
|
299
|
+
query?: never;
|
|
300
|
+
url: '/items';
|
|
301
|
+
};
|
|
302
|
+
export type ItemControllerDeleteManyResponses = {
|
|
303
|
+
/**
|
|
304
|
+
* The items have been successfully deleted.
|
|
305
|
+
*/
|
|
306
|
+
204: void;
|
|
307
|
+
};
|
|
308
|
+
export type ItemControllerDeleteManyResponse = ItemControllerDeleteManyResponses[keyof ItemControllerDeleteManyResponses];
|
|
309
|
+
export type ItemControllerFindAllData = {
|
|
310
|
+
body?: never;
|
|
311
|
+
headers: {
|
|
312
|
+
/**
|
|
313
|
+
* Your Swish API key
|
|
314
|
+
*/
|
|
315
|
+
Authorization: string;
|
|
316
|
+
/**
|
|
317
|
+
* The shop domain
|
|
318
|
+
*/
|
|
319
|
+
Shop: string;
|
|
320
|
+
/**
|
|
321
|
+
* The profile key
|
|
322
|
+
*/
|
|
323
|
+
Key: string;
|
|
324
|
+
};
|
|
325
|
+
path?: never;
|
|
326
|
+
query?: {
|
|
327
|
+
/**
|
|
328
|
+
* The pagination cursor
|
|
329
|
+
*/
|
|
330
|
+
cursor?: string;
|
|
331
|
+
};
|
|
332
|
+
url: '/items';
|
|
333
|
+
};
|
|
334
|
+
export type ItemControllerFindAllResponses = {
|
|
335
|
+
/**
|
|
336
|
+
* Returns all items as paginated response
|
|
337
|
+
*/
|
|
338
|
+
200: PaginatedResponseDto & {
|
|
339
|
+
data?: Array<Item>;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
export type ItemControllerFindAllResponse = ItemControllerFindAllResponses[keyof ItemControllerFindAllResponses];
|
|
343
|
+
export type ItemControllerCreateManyData = {
|
|
344
|
+
body: CreateItemsDto;
|
|
345
|
+
headers: {
|
|
346
|
+
/**
|
|
347
|
+
* Your Swish API key
|
|
348
|
+
*/
|
|
349
|
+
Authorization: string;
|
|
350
|
+
/**
|
|
351
|
+
* The shop domain
|
|
352
|
+
*/
|
|
353
|
+
Shop: string;
|
|
354
|
+
/**
|
|
355
|
+
* The profile key
|
|
356
|
+
*/
|
|
357
|
+
Key: string;
|
|
358
|
+
};
|
|
359
|
+
path?: never;
|
|
360
|
+
query?: never;
|
|
361
|
+
url: '/items';
|
|
362
|
+
};
|
|
363
|
+
export type ItemControllerCreateManyResponses = {
|
|
364
|
+
/**
|
|
365
|
+
* The items have been successfully created.
|
|
366
|
+
*/
|
|
367
|
+
201: ResponseDto & {
|
|
368
|
+
data?: Array<Item>;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
export type ItemControllerCreateManyResponse = ItemControllerCreateManyResponses[keyof ItemControllerCreateManyResponses];
|
|
372
|
+
export type ItemControllerDeleteOneData = {
|
|
373
|
+
body?: never;
|
|
374
|
+
headers: {
|
|
375
|
+
/**
|
|
376
|
+
* Your Swish API key
|
|
377
|
+
*/
|
|
378
|
+
Authorization: string;
|
|
379
|
+
/**
|
|
380
|
+
* The shop domain
|
|
381
|
+
*/
|
|
382
|
+
Shop: string;
|
|
383
|
+
/**
|
|
384
|
+
* The profile key
|
|
385
|
+
*/
|
|
386
|
+
Key: string;
|
|
387
|
+
};
|
|
388
|
+
path: {
|
|
389
|
+
/**
|
|
390
|
+
* The ID of the item
|
|
391
|
+
*/
|
|
392
|
+
itemId: string;
|
|
393
|
+
};
|
|
394
|
+
query?: never;
|
|
395
|
+
url: '/items/{itemId}';
|
|
396
|
+
};
|
|
397
|
+
export type ItemControllerDeleteOneResponses = {
|
|
398
|
+
/**
|
|
399
|
+
* The item has been successfully deleted.
|
|
400
|
+
*/
|
|
401
|
+
204: void;
|
|
402
|
+
};
|
|
403
|
+
export type ItemControllerDeleteOneResponse = ItemControllerDeleteOneResponses[keyof ItemControllerDeleteOneResponses];
|
|
404
|
+
export type ItemControllerUpdateOneData = {
|
|
405
|
+
body: UpdateItemDto;
|
|
406
|
+
headers: {
|
|
407
|
+
/**
|
|
408
|
+
* Your Swish API key
|
|
409
|
+
*/
|
|
410
|
+
Authorization: string;
|
|
411
|
+
/**
|
|
412
|
+
* The shop domain
|
|
413
|
+
*/
|
|
414
|
+
Shop: string;
|
|
415
|
+
/**
|
|
416
|
+
* The profile key
|
|
417
|
+
*/
|
|
418
|
+
Key: string;
|
|
419
|
+
};
|
|
420
|
+
path: {
|
|
421
|
+
/**
|
|
422
|
+
* The ID of the item
|
|
423
|
+
*/
|
|
424
|
+
itemId: string;
|
|
425
|
+
};
|
|
426
|
+
query?: never;
|
|
427
|
+
url: '/items/{itemId}';
|
|
428
|
+
};
|
|
429
|
+
export type ItemControllerUpdateOneResponses = {
|
|
430
|
+
/**
|
|
431
|
+
* The item has been successfully updated.
|
|
432
|
+
*/
|
|
433
|
+
200: ResponseDto & {
|
|
434
|
+
data?: Item;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
export type ItemControllerUpdateOneResponse = ItemControllerUpdateOneResponses[keyof ItemControllerUpdateOneResponses];
|
|
438
|
+
export type ClientOptions = {
|
|
439
|
+
baseUrl: 'https://swish.app/api/unstable' | (string & {});
|
|
440
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CreateItemsDto, CreateListDto, DeleteItemsDto, UpdateItemDto, UpdateListDto } from "./client/types.gen";
|
|
2
|
+
export interface SwishClientOptions {
|
|
3
|
+
authToken: string;
|
|
4
|
+
shop: string;
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
type CursorQuery = {
|
|
8
|
+
cursor?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class SwishClient {
|
|
11
|
+
private readonly authToken;
|
|
12
|
+
private readonly shop;
|
|
13
|
+
private readonly key;
|
|
14
|
+
constructor(options: SwishClientOptions);
|
|
15
|
+
readonly items: {
|
|
16
|
+
list: (query?: CursorQuery) => Promise<(import("./client").PaginatedResponseDto & {
|
|
17
|
+
data?: Array<import("./client").Item>;
|
|
18
|
+
}) | undefined>;
|
|
19
|
+
create: (items: CreateItemsDto["items"]) => Promise<(import("./client").ResponseDto & {
|
|
20
|
+
data?: Array<import("./client").Item>;
|
|
21
|
+
}) | undefined>;
|
|
22
|
+
delete: (items: DeleteItemsDto["items"]) => Promise<void | undefined>;
|
|
23
|
+
deleteById: (itemId: string) => Promise<void | undefined>;
|
|
24
|
+
updateById: (itemId: string, body: UpdateItemDto) => Promise<(import("./client").ResponseDto & {
|
|
25
|
+
data?: import("./client").Item;
|
|
26
|
+
}) | undefined>;
|
|
27
|
+
};
|
|
28
|
+
readonly lists: {
|
|
29
|
+
list: (query?: CursorQuery) => Promise<(import("./client").PaginatedResponseDto & {
|
|
30
|
+
data?: Array<import("./client").List>;
|
|
31
|
+
}) | undefined>;
|
|
32
|
+
getById: (listId: string) => Promise<(import("./client").ResponseDto & {
|
|
33
|
+
data?: import("./client").List;
|
|
34
|
+
}) | undefined>;
|
|
35
|
+
create: (list: CreateListDto) => Promise<(import("./client").ResponseDto & {
|
|
36
|
+
data?: import("./client").List;
|
|
37
|
+
}) | undefined>;
|
|
38
|
+
deleteById: (listId: string) => Promise<void | undefined>;
|
|
39
|
+
updateById: (listId: string, body: UpdateListDto) => Promise<(import("./client").ResponseDto & {
|
|
40
|
+
data?: import("./client").List;
|
|
41
|
+
}) | undefined>;
|
|
42
|
+
};
|
|
43
|
+
private readonly addHeaders;
|
|
44
|
+
private readonly handleRequest;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { itemControllerFindAll, itemControllerCreateMany, itemControllerDeleteMany, itemControllerDeleteOne, itemControllerUpdateOne, listControllerFindAll, listControllerCreateOne, listControllerDeleteOne, listControllerFindOne, listControllerUpdateOne, } from "./client/sdk.gen";
|
|
2
|
+
export class SwishClient {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.items = {
|
|
5
|
+
list: (query) => this.handleRequest(itemControllerFindAll(this.addHeaders({ query }))),
|
|
6
|
+
create: (items) => this.handleRequest(itemControllerCreateMany(this.addHeaders({ body: { items } }))),
|
|
7
|
+
delete: (items) => this.handleRequest(itemControllerDeleteMany(this.addHeaders({ body: { items } }))),
|
|
8
|
+
deleteById: (itemId) => this.handleRequest(itemControllerDeleteOne(this.addHeaders({ path: { itemId } }))),
|
|
9
|
+
updateById: (itemId, body) => this.handleRequest(itemControllerUpdateOne(this.addHeaders({
|
|
10
|
+
body,
|
|
11
|
+
path: { itemId },
|
|
12
|
+
}))),
|
|
13
|
+
};
|
|
14
|
+
this.lists = {
|
|
15
|
+
list: (query) => this.handleRequest(listControllerFindAll(this.addHeaders({ query }))),
|
|
16
|
+
getById: (listId) => this.handleRequest(listControllerFindOne(this.addHeaders({ path: { listId } }))),
|
|
17
|
+
create: (list) => this.handleRequest(listControllerCreateOne(this.addHeaders({ body: list }))),
|
|
18
|
+
deleteById: (listId) => this.handleRequest(listControllerDeleteOne(this.addHeaders({ path: { listId } }))),
|
|
19
|
+
updateById: (listId, body) => this.handleRequest(listControllerUpdateOne(this.addHeaders({ body, path: { listId } }))),
|
|
20
|
+
};
|
|
21
|
+
this.addHeaders = (options) => ({
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: this.authToken,
|
|
24
|
+
Shop: this.shop,
|
|
25
|
+
Key: this.key,
|
|
26
|
+
},
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
this.handleRequest = async (request) => {
|
|
30
|
+
const { data, error } = await request;
|
|
31
|
+
if (error) {
|
|
32
|
+
// TODO: Add unified error responses
|
|
33
|
+
// TODO: Add { cause: error }
|
|
34
|
+
throw new Error("Failed to execute API request");
|
|
35
|
+
}
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
this.authToken = options.authToken;
|
|
39
|
+
this.shop = options.shop;
|
|
40
|
+
this.key = options.key;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swishapp/api-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "API client for the Swish API",
|
|
5
|
+
"website": "https://swish.app",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"generate": "openapi-ts",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:watch": "jest --watch",
|
|
23
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"lint": "eslint src --ext .ts",
|
|
26
|
+
"clean": "rimraf dist"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@hey-api/client-fetch": "0.8.3",
|
|
33
|
+
"@hey-api/openapi-ts": "0.64.10",
|
|
34
|
+
"@types/jest": "29.5.14",
|
|
35
|
+
"jest": "29.7.0",
|
|
36
|
+
"ts-jest": "29.1.1",
|
|
37
|
+
"rimraf": "5.0.1"
|
|
38
|
+
}
|
|
39
|
+
}
|