@great-detail/support-sdk 0.0.9 → 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/dist/chunk-F7GYYFWQ.js +1 -0
- package/dist/chunk-POO5QTDO.js +1 -0
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-DtLhj7uf.d.cts → index-EaleABGN.d.cts} +261 -86
- package/dist/{index-DtLhj7uf.d.ts → index-EaleABGN.d.ts} +261 -86
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Action/ListActions.ts +4 -4
- package/src/Authentication/PublicAuthentication.ts +4 -0
- package/src/Channel/ListChannels.ts +4 -4
- package/src/Client/index.ts +74 -82
- package/src/Contact/GetContact.ts +4 -4
- package/src/Contact/ListContacts.ts +4 -4
- package/src/Contact/UpdateContact.ts +65 -0
- package/src/Conversation/GetConversation.ts +4 -4
- package/src/Conversation/ListConversations.ts +4 -4
- package/src/Conversation/ListLabelConversations.ts +56 -0
- package/src/Conversation/UpdateConversation.ts +4 -4
- package/src/Label/CreateLabel.ts +5 -5
- package/src/Label/DeleteLabel.ts +42 -0
- package/src/Label/GetLabel.ts +4 -4
- package/src/Label/ListLabels.ts +4 -4
- package/src/Label/UpdateLabel.ts +63 -0
- package/src/Message/ListConversationMessages.ts +4 -4
- package/src/Message/ListMessages.ts +4 -4
- package/src/Model/Correction/CreateCorrectionModel.ts +4 -4
- package/src/Model/GetModel.ts +4 -4
- package/src/Model/ListModels.ts +4 -4
- package/src/Model/Response/CreateResponseModel.ts +4 -4
- package/src/Source/GetSource.ts +4 -4
- package/src/Source/ListSources.ts +4 -4
- package/src/Transport/index.ts +59 -0
- package/src/cli/labels.ts +17 -0
- package/dist/chunk-5SRPGK6C.js +0 -1
- package/dist/chunk-XBTUUC2M.js +0 -1
package/package.json
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListActionsRequest {
|
|
17
|
-
constructor(protected
|
|
17
|
+
constructor(protected _transport: Client) {}
|
|
18
18
|
|
|
19
19
|
public async send({ request = {}, ...options }: Options = {}) {
|
|
20
|
-
return this.
|
|
20
|
+
return this._transport
|
|
21
21
|
.send(
|
|
22
|
-
"
|
|
22
|
+
"v1/actions",
|
|
23
23
|
{
|
|
24
24
|
...request,
|
|
25
25
|
method: "GET",
|
|
@@ -11,6 +11,10 @@ import Authentication from "./index.js";
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Public Authentication Configuration.
|
|
14
|
+
* This type of authentication doesn't define any authentication for outgoing
|
|
15
|
+
* HTTP requests. This functionality may work well when using a proxying method
|
|
16
|
+
* to add credentials to a request after-the-fact.
|
|
17
|
+
*
|
|
14
18
|
* Note: Not all APIs and endpoints will work with this authentication type.
|
|
15
19
|
*
|
|
16
20
|
* @since 1.0.l0
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListChannelsRequest {
|
|
17
|
-
constructor(protected
|
|
17
|
+
constructor(protected _transport: Client) {}
|
|
18
18
|
|
|
19
19
|
public async send({ request = {}, ...options }: Options = {}) {
|
|
20
|
-
return this.
|
|
20
|
+
return this._transport
|
|
21
21
|
.send(
|
|
22
|
-
"
|
|
22
|
+
"v1/channels",
|
|
23
23
|
{
|
|
24
24
|
...request,
|
|
25
25
|
method: "GET",
|
package/src/Client/index.ts
CHANGED
|
@@ -13,126 +13,118 @@ import ListChannelsRequest from "../Channel/ListChannels.js";
|
|
|
13
13
|
import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
|
|
14
14
|
import GetContactRequest from "../Contact/GetContact.js";
|
|
15
15
|
import ListContactsRequest from "../Contact/ListContacts.js";
|
|
16
|
+
import UpdateContactRequest from "../Contact/UpdateContact.js";
|
|
16
17
|
import GetConversationRequest from "../Conversation/GetConversation.js";
|
|
17
18
|
import ListConversationsRequest from "../Conversation/ListConversations.js";
|
|
19
|
+
import ListLabelConversations from "../Conversation/ListLabelConversations.js";
|
|
18
20
|
import UpdateConversationRequest from "../Conversation/UpdateConversation.js";
|
|
19
21
|
import CreateLabelRequest from "../Label/CreateLabel.js";
|
|
22
|
+
import DeleteLabelRequest from "../Label/DeleteLabel.js";
|
|
20
23
|
import GetLabelRequest from "../Label/GetLabel.js";
|
|
21
24
|
import ListLabelsRequest from "../Label/ListLabels.js";
|
|
25
|
+
import UpdateLabelRequest from "../Label/UpdateLabel.js";
|
|
22
26
|
import ListConversationMessages from "../Message/ListConversationMessages.js";
|
|
23
27
|
import ListMessagesRequest from "../Message/ListMessages.js";
|
|
24
28
|
import CreateCorrectionModelRequest from "../Model/Correction/CreateCorrectionModel.js";
|
|
25
29
|
import GetModelRequest from "../Model/GetModel.js";
|
|
26
30
|
import ListModelsRequest from "../Model/ListModels.js";
|
|
27
31
|
import CreateResponseModelRequest from "../Model/Response/CreateResponseModel.js";
|
|
28
|
-
import RequestFilterable from "../Request/RequestFilterable.js";
|
|
29
32
|
import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
|
|
30
33
|
import GetSourceRequest from "../Source/GetSource.js";
|
|
31
34
|
import ListSourcesRequest from "../Source/ListSources.js";
|
|
35
|
+
import Transport from "../Transport/index.js";
|
|
32
36
|
|
|
33
37
|
export interface ClientOptions {
|
|
34
|
-
|
|
35
|
-
baseURL: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface InputClientOptions {
|
|
39
|
-
baseURL?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface SendOptions {
|
|
43
|
-
/**
|
|
44
|
-
* Alternative Fetch Provider.
|
|
45
|
-
* Used to override the default fetch provider and use polyfills or other
|
|
46
|
-
* libraries.
|
|
47
|
-
*
|
|
48
|
-
* @since 1.0.0
|
|
49
|
-
*/
|
|
50
|
-
fetch?: typeof fetch;
|
|
38
|
+
baseURL?: string | URL;
|
|
51
39
|
}
|
|
52
40
|
|
|
53
41
|
export default class Client {
|
|
54
42
|
public static DEFAULT_BASE_URL = DEFAULT_SUPPORT_BASE_URL;
|
|
55
43
|
|
|
56
|
-
public
|
|
44
|
+
public transport: Transport;
|
|
57
45
|
|
|
58
46
|
constructor(
|
|
59
47
|
authentication: Authentication,
|
|
60
|
-
options:
|
|
48
|
+
{ baseURL, ...options }: ClientOptions = {},
|
|
61
49
|
) {
|
|
62
|
-
this.
|
|
50
|
+
this.transport = new Transport({
|
|
63
51
|
requestFilterables: [new RequestStandardHeaders(), authentication],
|
|
64
|
-
baseURL: process.env.SUPPORT_BASE_URL ?? Client.DEFAULT_BASE_URL,
|
|
65
52
|
...options,
|
|
66
|
-
|
|
53
|
+
baseURL: baseURL?.toString() ?? Client.getBaseURL(),
|
|
54
|
+
});
|
|
67
55
|
}
|
|
68
56
|
|
|
69
|
-
public
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public channel = {
|
|
74
|
-
list: new ListChannelsRequest(this),
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
public contact = {
|
|
78
|
-
get: new GetContactRequest(this),
|
|
79
|
-
list: new ListContactsRequest(this),
|
|
80
|
-
};
|
|
57
|
+
public static getBaseURL(): string {
|
|
58
|
+
return process.env.SUPPORT_BASE_URL ?? this.DEFAULT_BASE_URL;
|
|
59
|
+
}
|
|
81
60
|
|
|
82
|
-
public
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
list: new ListConversationMessages(this),
|
|
88
|
-
},
|
|
89
|
-
};
|
|
61
|
+
public get action() {
|
|
62
|
+
return {
|
|
63
|
+
list: new ListActionsRequest(this.transport),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
90
66
|
|
|
91
|
-
public
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
67
|
+
public get channel() {
|
|
68
|
+
return {
|
|
69
|
+
list: new ListChannelsRequest(this.transport),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
96
72
|
|
|
97
|
-
public
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
public get contact() {
|
|
74
|
+
return {
|
|
75
|
+
get: new GetContactRequest(this.transport),
|
|
76
|
+
list: new ListContactsRequest(this.transport),
|
|
77
|
+
update: new UpdateContactRequest(this.transport),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
100
80
|
|
|
101
|
-
public
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
81
|
+
public get conversation() {
|
|
82
|
+
return {
|
|
83
|
+
get: new GetConversationRequest(this.transport),
|
|
84
|
+
list: new ListConversationsRequest(this.transport),
|
|
85
|
+
update: new UpdateConversationRequest(this.transport),
|
|
86
|
+
message: {
|
|
87
|
+
list: new ListConversationMessages(this.transport),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
111
91
|
|
|
112
|
-
public
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
92
|
+
public get label() {
|
|
93
|
+
return {
|
|
94
|
+
create: new CreateLabelRequest(this.transport),
|
|
95
|
+
get: new GetLabelRequest(this.transport),
|
|
96
|
+
list: new ListLabelsRequest(this.transport),
|
|
97
|
+
update: new UpdateLabelRequest(this.transport),
|
|
98
|
+
delete: new DeleteLabelRequest(this.transport),
|
|
99
|
+
conversation: {
|
|
100
|
+
list: new ListLabelConversations(this.transport),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
116
104
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
105
|
+
public get message() {
|
|
106
|
+
return {
|
|
107
|
+
list: new ListMessagesRequest(this.transport),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
121
110
|
|
|
122
|
-
|
|
111
|
+
public get model() {
|
|
112
|
+
return {
|
|
113
|
+
get: new GetModelRequest(this.transport),
|
|
114
|
+
list: new ListModelsRequest(this.transport),
|
|
115
|
+
response: {
|
|
116
|
+
create: new CreateResponseModelRequest(this.transport),
|
|
117
|
+
},
|
|
118
|
+
correction: {
|
|
119
|
+
create: new CreateCorrectionModelRequest(this.transport),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
public
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// See: https://github.com/node-fetch/node-fetch/issues/481#issuecomment-592491825
|
|
131
|
-
return await fetchAlternative(
|
|
132
|
-
new Request(
|
|
133
|
-
new URL(url, this.options.baseURL),
|
|
134
|
-
await this._filterRequest(request),
|
|
135
|
-
),
|
|
136
|
-
);
|
|
124
|
+
public get source() {
|
|
125
|
+
return {
|
|
126
|
+
get: new GetSourceRequest(this.transport),
|
|
127
|
+
list: new ListSourcesRequest(this.transport),
|
|
128
|
+
};
|
|
137
129
|
}
|
|
138
130
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
id: string;
|
|
@@ -15,12 +15,12 @@ export interface Options extends SendOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default class GetContactRequest {
|
|
18
|
-
constructor(protected
|
|
18
|
+
constructor(protected _transport: Client) {}
|
|
19
19
|
|
|
20
20
|
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
-
return this.
|
|
21
|
+
return this._transport
|
|
22
22
|
.send(
|
|
23
|
-
"
|
|
23
|
+
"v1/contacts/" + encodeURIComponent(id),
|
|
24
24
|
{
|
|
25
25
|
...request,
|
|
26
26
|
method: "GET",
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListContactsRequest {
|
|
17
|
-
constructor(protected
|
|
17
|
+
constructor(protected _transport: Client) {}
|
|
18
18
|
|
|
19
19
|
public async send({ request = {}, ...options }: Options = {}) {
|
|
20
|
-
return this.
|
|
20
|
+
return this._transport
|
|
21
21
|
.send(
|
|
22
|
-
"
|
|
22
|
+
"v1/contacts",
|
|
23
23
|
{
|
|
24
24
|
...request,
|
|
25
25
|
method: "GET",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
12
|
+
|
|
13
|
+
export interface Options extends SendOptions {
|
|
14
|
+
id: string;
|
|
15
|
+
body: z.infer<typeof UpdateContactRequest.SCHEMA>;
|
|
16
|
+
request?: RequestInit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class UpdateContactRequest {
|
|
20
|
+
public static SCHEMA = z.object({
|
|
21
|
+
name: z.string().optional(),
|
|
22
|
+
emailAddress: z.string().email().optional(),
|
|
23
|
+
telephoneNumber: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
constructor(protected _transport: Client) {}
|
|
27
|
+
|
|
28
|
+
public async send({ id, body, request = {}, ...options }: Options) {
|
|
29
|
+
return this._transport
|
|
30
|
+
.send(
|
|
31
|
+
"v1/contacts/" + encodeURIComponent(id),
|
|
32
|
+
{
|
|
33
|
+
...request,
|
|
34
|
+
method: "PATCH",
|
|
35
|
+
headers: {
|
|
36
|
+
...request.headers,
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(UpdateContactRequest.SCHEMA.parse(body)),
|
|
40
|
+
},
|
|
41
|
+
options,
|
|
42
|
+
)
|
|
43
|
+
.then((response) => new UpdateContactResponse(response));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type UpdateContactResponsePayload = {
|
|
48
|
+
contact: {
|
|
49
|
+
id: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
emailAddress?: string;
|
|
52
|
+
telephoneNumber?: string;
|
|
53
|
+
account: string;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
updatedAt?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export class UpdateContactResponse {
|
|
60
|
+
constructor(public response: Response) {}
|
|
61
|
+
|
|
62
|
+
public async result(): Promise<UpdateContactResponsePayload> {
|
|
63
|
+
return this.response.json();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
id: string;
|
|
@@ -15,12 +15,12 @@ export interface Options extends SendOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default class GetConversationRequest {
|
|
18
|
-
constructor(protected
|
|
18
|
+
constructor(protected _transport: Client) {}
|
|
19
19
|
|
|
20
20
|
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
-
return this.
|
|
21
|
+
return this._transport
|
|
22
22
|
.send(
|
|
23
|
-
"
|
|
23
|
+
"v1/conversations/" + encodeURIComponent(id),
|
|
24
24
|
{
|
|
25
25
|
...request,
|
|
26
26
|
method: "GET",
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListConversationsRequest {
|
|
17
|
-
constructor(protected
|
|
17
|
+
constructor(protected _transport: Client) {}
|
|
18
18
|
|
|
19
19
|
public async send({ request = {}, ...options }: Options = {}) {
|
|
20
|
-
return this.
|
|
20
|
+
return this._transport
|
|
21
21
|
.send(
|
|
22
|
-
"
|
|
22
|
+
"v1/conversations",
|
|
23
23
|
{
|
|
24
24
|
...request,
|
|
25
25
|
method: "GET",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
|
+
|
|
12
|
+
export interface Options extends SendOptions {
|
|
13
|
+
id: string;
|
|
14
|
+
request?: RequestInit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class ListLabelConversations {
|
|
18
|
+
constructor(protected _transport: Client) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
+
return this._transport
|
|
22
|
+
.send(
|
|
23
|
+
"v1/labels/" + encodeURIComponent(id) + "/conversations",
|
|
24
|
+
{
|
|
25
|
+
...request,
|
|
26
|
+
method: "GET",
|
|
27
|
+
},
|
|
28
|
+
options,
|
|
29
|
+
)
|
|
30
|
+
.then((response) => new ListLabelConversationsResponse(response));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ListLabelConversationsResponsePayload = {
|
|
35
|
+
conversations: {
|
|
36
|
+
id: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
hasEnded: boolean;
|
|
39
|
+
conversationStatus:
|
|
40
|
+
| "AwaitingContactConversationStatus"
|
|
41
|
+
| "AwaitingAgentConversationStatus"
|
|
42
|
+
| "ResolvedConversationStatus"
|
|
43
|
+
| "ClosedConversationStatus";
|
|
44
|
+
accountChannel: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export class ListLabelConversationsResponse {
|
|
51
|
+
constructor(public response: Response) {}
|
|
52
|
+
|
|
53
|
+
public async result(): Promise<ListLabelConversationsResponsePayload> {
|
|
54
|
+
return this.response.json();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import Client, { SendOptions } from "../
|
|
11
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
12
12
|
|
|
13
13
|
export interface Options extends SendOptions {
|
|
14
14
|
id: string;
|
|
@@ -21,12 +21,12 @@ export default class UpdateConversationRequest {
|
|
|
21
21
|
hasEnded: z.boolean(),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
constructor(protected
|
|
24
|
+
constructor(protected _transport: Client) {}
|
|
25
25
|
|
|
26
26
|
public async send({ id, body, request = {}, ...options }: Options) {
|
|
27
|
-
return this.
|
|
27
|
+
return this._transport
|
|
28
28
|
.send(
|
|
29
|
-
"
|
|
29
|
+
"v1/conversations/" + encodeURIComponent(id),
|
|
30
30
|
{
|
|
31
31
|
...request,
|
|
32
32
|
method: "POST",
|
package/src/Label/CreateLabel.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
import Client, { SendOptions } from "../
|
|
11
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
12
12
|
|
|
13
13
|
export interface Options extends SendOptions {
|
|
14
14
|
body: z.infer<typeof CreateLabelRequest.SCHEMA>;
|
|
@@ -18,16 +18,16 @@ export interface Options extends SendOptions {
|
|
|
18
18
|
export default class CreateLabelRequest {
|
|
19
19
|
public static SCHEMA = z.object({
|
|
20
20
|
title: z.string(),
|
|
21
|
-
description: z.
|
|
21
|
+
description: z.string().optional(),
|
|
22
22
|
account: z.string(),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
constructor(protected
|
|
25
|
+
constructor(protected _transport: Client) {}
|
|
26
26
|
|
|
27
27
|
public async send({ body, request = {}, ...options }: Options) {
|
|
28
|
-
return this.
|
|
28
|
+
return this._transport
|
|
29
29
|
.send(
|
|
30
|
-
"
|
|
30
|
+
"v1/labels",
|
|
31
31
|
{
|
|
32
32
|
...request,
|
|
33
33
|
method: "POST",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
|
+
|
|
12
|
+
export interface Options extends SendOptions {
|
|
13
|
+
id: string;
|
|
14
|
+
request?: RequestInit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class DeleteLabelRequest {
|
|
18
|
+
constructor(protected _transport: Client) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
+
return this._transport
|
|
22
|
+
.send(
|
|
23
|
+
"v1/labels/" + encodeURIComponent(id),
|
|
24
|
+
{
|
|
25
|
+
...request,
|
|
26
|
+
method: "DELETE",
|
|
27
|
+
},
|
|
28
|
+
options,
|
|
29
|
+
)
|
|
30
|
+
.then((response) => new DeleteLabelResponse(response));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type DeleteLabelResponsePayload = Record<string, never>;
|
|
35
|
+
|
|
36
|
+
export class DeleteLabelResponse {
|
|
37
|
+
constructor(public response: Response) {}
|
|
38
|
+
|
|
39
|
+
public async result(): Promise<DeleteLabelResponsePayload> {
|
|
40
|
+
return this.response.json();
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/Label/GetLabel.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import Client, { SendOptions } from "../
|
|
10
|
+
import Client, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
id: string;
|
|
@@ -15,12 +15,12 @@ export interface Options extends SendOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export default class GetLabelRequest {
|
|
18
|
-
constructor(protected
|
|
18
|
+
constructor(protected _transport: Client) {}
|
|
19
19
|
|
|
20
20
|
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
-
return this.
|
|
21
|
+
return this._transport
|
|
22
22
|
.send(
|
|
23
|
-
"
|
|
23
|
+
"v1/labels/" + encodeURIComponent(id),
|
|
24
24
|
{
|
|
25
25
|
...request,
|
|
26
26
|
method: "GET",
|
package/src/Label/ListLabels.ts
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import Transport, { SendOptions } from "../Transport/index.js";
|
|
11
11
|
|
|
12
12
|
export interface Options extends SendOptions {
|
|
13
13
|
request?: RequestInit;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default class ListLabelsRequest {
|
|
17
|
-
constructor(protected
|
|
17
|
+
constructor(protected _transport: Transport) {}
|
|
18
18
|
|
|
19
19
|
public async send({ request = {}, ...options }: Options = {}) {
|
|
20
|
-
return this.
|
|
20
|
+
return this._transport
|
|
21
21
|
.send(
|
|
22
|
-
"
|
|
22
|
+
"v1/labels",
|
|
23
23
|
{
|
|
24
24
|
...request,
|
|
25
25
|
method: "GET",
|