@swishapp/api-client 0.2.0 → 0.4.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/dist/client/sdk.gen.d.ts +19 -16
- package/dist/client/sdk.gen.js +18 -8
- package/dist/client/types.gen.d.ts +382 -360
- package/dist/index.d.ts +19 -18
- package/dist/index.js +13 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateItemInput, CreateListInput, DeleteItemsInput, ItemControllerFindData, ListControllerFindData, UpdateItemInput, UpdateListInput, CreateProfileTokenInput, IdentifyProfileInput } from "./client/types.gen";
|
|
2
2
|
export interface SwishClientOptions {
|
|
3
3
|
authToken: string;
|
|
4
|
-
|
|
5
|
-
key: string;
|
|
4
|
+
profile?: string;
|
|
6
5
|
}
|
|
7
|
-
type CursorQuery = {
|
|
8
|
-
cursor?: string;
|
|
9
|
-
};
|
|
10
6
|
export declare class SwishClient {
|
|
11
|
-
private readonly
|
|
12
|
-
private readonly shop;
|
|
13
|
-
private readonly key;
|
|
7
|
+
private readonly options;
|
|
14
8
|
constructor(options: SwishClientOptions);
|
|
15
9
|
readonly items: {
|
|
16
|
-
list: (query?:
|
|
10
|
+
list: (query?: ItemControllerFindData["query"]) => Promise<(import("./client").PaginatedResponse & {
|
|
17
11
|
data?: Array<import("./client").Item>;
|
|
18
12
|
}) | undefined>;
|
|
19
|
-
create: (items:
|
|
13
|
+
create: (items: CreateItemInput) => Promise<(import("./client").Response & {
|
|
20
14
|
data?: import("./client").Item;
|
|
21
15
|
}) | undefined>;
|
|
22
|
-
delete: (items:
|
|
16
|
+
delete: (items: DeleteItemsInput["items"]) => Promise<void | undefined>;
|
|
23
17
|
deleteById: (itemId: string) => Promise<void | undefined>;
|
|
24
|
-
updateById: (itemId: string, body:
|
|
18
|
+
updateById: (itemId: string, body: UpdateItemInput) => Promise<(import("./client").Response & {
|
|
25
19
|
data?: import("./client").Item;
|
|
26
20
|
}) | undefined>;
|
|
27
21
|
};
|
|
28
22
|
readonly lists: {
|
|
29
|
-
list: (query?:
|
|
23
|
+
list: (query?: ListControllerFindData["query"]) => Promise<(import("./client").PaginatedResponse & {
|
|
30
24
|
data?: Array<import("./client").List>;
|
|
31
25
|
}) | undefined>;
|
|
32
|
-
|
|
26
|
+
findById: (listId: string) => Promise<(import("./client").Response & {
|
|
33
27
|
data?: import("./client").List;
|
|
34
28
|
}) | undefined>;
|
|
35
|
-
create: (list:
|
|
29
|
+
create: (list: CreateListInput) => Promise<(import("./client").Response & {
|
|
36
30
|
data?: import("./client").List;
|
|
37
31
|
}) | undefined>;
|
|
38
32
|
deleteById: (listId: string) => Promise<void | undefined>;
|
|
39
|
-
updateById: (listId: string, body:
|
|
33
|
+
updateById: (listId: string, body: UpdateListInput) => Promise<(import("./client").Response & {
|
|
40
34
|
data?: import("./client").List;
|
|
41
35
|
}) | undefined>;
|
|
42
36
|
};
|
|
37
|
+
readonly profile: {
|
|
38
|
+
createToken: (body: CreateProfileTokenInput) => Promise<(import("./client").Response & {
|
|
39
|
+
data?: import("./client").CreateProfileTokenResponse;
|
|
40
|
+
}) | undefined>;
|
|
41
|
+
identifyProfile: (body: IdentifyProfileInput) => Promise<(import("./client").Response & {
|
|
42
|
+
data?: import("./client").IdentifyProfileResponse;
|
|
43
|
+
}) | undefined>;
|
|
44
|
+
};
|
|
43
45
|
private readonly addHeaders;
|
|
44
46
|
private readonly handleRequest;
|
|
45
47
|
}
|
|
46
|
-
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { itemControllerFind, itemControllerCreate, itemControllerDelete,
|
|
1
|
+
import { itemControllerFind, itemControllerCreate, itemControllerDelete, itemControllerDeleteById, itemControllerUpdateById, listControllerFind, listControllerCreate, listControllerDeleteById, listControllerUpdateById, listControllerFindById, profileControllerCreateToken, profileControllerIdentifyProfile, } from "./client/sdk.gen";
|
|
2
2
|
export class SwishClient {
|
|
3
3
|
constructor(options) {
|
|
4
4
|
this.items = {
|
|
@@ -12,17 +12,20 @@ export class SwishClient {
|
|
|
12
12
|
}))),
|
|
13
13
|
};
|
|
14
14
|
this.lists = {
|
|
15
|
-
list: (query) => this.handleRequest(
|
|
16
|
-
|
|
17
|
-
create: (list) => this.handleRequest(
|
|
18
|
-
deleteById: (listId) => this.handleRequest(
|
|
19
|
-
updateById: (listId, body) => this.handleRequest(
|
|
15
|
+
list: (query) => this.handleRequest(listControllerFind(this.addHeaders({ query }))),
|
|
16
|
+
findById: (listId) => this.handleRequest(listControllerFindById(this.addHeaders({ path: { listId } }))),
|
|
17
|
+
create: (list) => this.handleRequest(listControllerCreate(this.addHeaders({ body: list }))),
|
|
18
|
+
deleteById: (listId) => this.handleRequest(listControllerDeleteById(this.addHeaders({ path: { listId } }))),
|
|
19
|
+
updateById: (listId, body) => this.handleRequest(listControllerUpdateById(this.addHeaders({ body, path: { listId } }))),
|
|
20
|
+
};
|
|
21
|
+
this.profile = {
|
|
22
|
+
createToken: (body) => this.handleRequest(profileControllerCreateToken(this.addHeaders({ body }))),
|
|
23
|
+
identifyProfile: (body) => this.handleRequest(profileControllerIdentifyProfile(this.addHeaders({ body }))),
|
|
20
24
|
};
|
|
21
25
|
this.addHeaders = (options) => ({
|
|
22
26
|
headers: {
|
|
23
|
-
Authorization: this.authToken
|
|
24
|
-
|
|
25
|
-
Key: this.key,
|
|
27
|
+
Authorization: `Bearer ${this.options.authToken}`,
|
|
28
|
+
...(this.options.profile && { Profile: this.options.profile }),
|
|
26
29
|
},
|
|
27
30
|
...options,
|
|
28
31
|
});
|
|
@@ -35,8 +38,6 @@ export class SwishClient {
|
|
|
35
38
|
}
|
|
36
39
|
return data;
|
|
37
40
|
};
|
|
38
|
-
this.
|
|
39
|
-
this.shop = options.shop;
|
|
40
|
-
this.key = options.key;
|
|
41
|
+
this.options = options;
|
|
41
42
|
}
|
|
42
43
|
}
|