@great-detail/support-sdk 0.4.4 → 0.4.5

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.
Files changed (88) hide show
  1. package/package.json +2 -3
  2. package/src/Action/ListActions.ts +0 -40
  3. package/src/Action/index.ts +0 -10
  4. package/src/Authentication/KeyAuthentication.ts +0 -50
  5. package/src/Authentication/PublicAuthentication.ts +0 -32
  6. package/src/Authentication/TokenAuthentication.ts +0 -41
  7. package/src/Authentication/index.ts +0 -13
  8. package/src/Boilerplate/CreateBoilerplateCategoryBoilerplate.ts +0 -55
  9. package/src/Boilerplate/GetBoilerplate.ts +0 -41
  10. package/src/Boilerplate/ListBoilerplateCategoryBoilerplates.ts +0 -41
  11. package/src/Boilerplate/ListBoilerplates.ts +0 -37
  12. package/src/Boilerplate/UpdateBoilerplate.ts +0 -53
  13. package/src/Boilerplate/index.ts +0 -14
  14. package/src/BoilerplateCategory/CreateBoilerplateCategory.ts +0 -52
  15. package/src/BoilerplateCategory/GetBoilerplateCategory.ts +0 -40
  16. package/src/BoilerplateCategory/ListBoilerplateCategories.ts +0 -39
  17. package/src/BoilerplateCategory/UpdateBoilerplateCategory.ts +0 -52
  18. package/src/BoilerplateCategory/index.ts +0 -13
  19. package/src/Channel/ListChannels.ts +0 -53
  20. package/src/Channel/index.ts +0 -10
  21. package/src/Client/index.ts +0 -206
  22. package/src/Contact/ContactVCF/GetContactVCF.ts +0 -45
  23. package/src/Contact/CreateContact.ts +0 -51
  24. package/src/Contact/GetContact.ts +0 -41
  25. package/src/Contact/ListContacts.ts +0 -37
  26. package/src/Contact/ListLabelContacts.ts +0 -41
  27. package/src/Contact/UpdateContact.ts +0 -54
  28. package/src/Contact/index.ts +0 -14
  29. package/src/Conversation/CreateConversation.ts +0 -58
  30. package/src/Conversation/GetConversation.ts +0 -45
  31. package/src/Conversation/ListContactConversations.ts +0 -45
  32. package/src/Conversation/ListConversations.ts +0 -41
  33. package/src/Conversation/ListLabelConversations.ts +0 -45
  34. package/src/Conversation/UpdateConversation.ts +0 -64
  35. package/src/Conversation/index.ts +0 -15
  36. package/src/Error/AuthError.ts +0 -12
  37. package/src/Error/AuthenticationError.ts +0 -16
  38. package/src/Error/AuthorizationError.ts +0 -16
  39. package/src/Error/LogicError.ts +0 -20
  40. package/src/Error/NetworkError.ts +0 -12
  41. package/src/Error/SupportError.ts +0 -10
  42. package/src/Error/ValidationError.ts +0 -16
  43. package/src/Error/index.ts +0 -20
  44. package/src/Label/CreateLabel.ts +0 -49
  45. package/src/Label/DeleteLabel.ts +0 -31
  46. package/src/Label/GetLabel.ts +0 -40
  47. package/src/Label/ListLabels.ts +0 -36
  48. package/src/Label/UpdateLabel.ts +0 -52
  49. package/src/Label/index.ts +0 -14
  50. package/src/Message/ListConversationMessages.ts +0 -49
  51. package/src/Message/ListMessages.ts +0 -45
  52. package/src/Message/index.ts +0 -11
  53. package/src/Model/Correction/CreateCorrectionModel.ts +0 -44
  54. package/src/Model/GetModel.ts +0 -39
  55. package/src/Model/ListModels.ts +0 -35
  56. package/src/Model/Response/CreateResponseModel.ts +0 -53
  57. package/src/Model/index.ts +0 -15
  58. package/src/Note/CreateContactNote.ts +0 -49
  59. package/src/Note/CreateConversationNote.ts +0 -49
  60. package/src/Note/GetNote.ts +0 -38
  61. package/src/Note/ListContactNotes.ts +0 -38
  62. package/src/Note/ListConversationNotes.ts +0 -38
  63. package/src/Note/UpdateNote.ts +0 -49
  64. package/src/Note/index.ts +0 -15
  65. package/src/NotificationSubscription/CreateContactNotificationSubscription.ts +0 -57
  66. package/src/NotificationSubscription/index.ts +0 -10
  67. package/src/Request/RequestFilterable.ts +0 -16
  68. package/src/Request/RequestStandardHeaders.ts +0 -32
  69. package/src/Source/GetSource.ts +0 -40
  70. package/src/Source/ListSources.ts +0 -36
  71. package/src/Source/index.ts +0 -11
  72. package/src/Transport/FetchTransport.ts +0 -100
  73. package/src/Transport/index.ts +0 -18
  74. package/src/Webhook/index.ts +0 -55
  75. package/src/__tests__/Client/Client.test.ts +0 -38
  76. package/src/cli/actions.ts +0 -31
  77. package/src/cli/channels.ts +0 -31
  78. package/src/cli/contacts.ts +0 -45
  79. package/src/cli/conversations.ts +0 -48
  80. package/src/cli/index.ts +0 -46
  81. package/src/cli/labels.ts +0 -62
  82. package/src/cli/messages.ts +0 -31
  83. package/src/cli/models.ts +0 -45
  84. package/src/cli/sources.ts +0 -45
  85. package/src/cli.ts +0 -13
  86. package/src/constants/environment.ts +0 -36
  87. package/src/constants/index.ts +0 -31
  88. package/src/index.ts +0 -39
@@ -1,53 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- request?: RequestInit;
14
- }
15
-
16
- export type ListChannelsResponse = {
17
- channels: ({
18
- id: string;
19
- name?: string;
20
- channelStatus: "ActiveChannelStatus" | "PotentialChannelStatus";
21
- account: string;
22
- createdAt: string;
23
- updatedAt?: string;
24
- } & (
25
- | {
26
- source: "meta-whatsapp";
27
- metaWhatsapp: {
28
- id: string;
29
- whatsappAccountID: string;
30
- whatsappPhoneNumberID: string;
31
- accessToken: string;
32
- };
33
- }
34
- | {
35
- source: "twilio-sendgrid";
36
- twilioSendgrid: {
37
- id: string;
38
- apiKey: string;
39
- };
40
- }
41
- ))[];
42
- };
43
-
44
- export default class ListChannels {
45
- constructor(protected _transport: FetchTransport) {}
46
-
47
- public async send({ request = {} }: Options = {}) {
48
- return this._transport.send<ListChannelsResponse>("v1/channels", {
49
- ...request,
50
- method: "GET",
51
- });
52
- }
53
- }
@@ -1,10 +0,0 @@
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
- export { type ListChannelsResponse } from "./ListChannels.js";
@@ -1,206 +0,0 @@
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 ListActions from "../Action/ListActions.js";
11
- import Authentication from "../Authentication/index.js";
12
- import CreateBoilerplateCategoryBoilerplate from "../Boilerplate/CreateBoilerplateCategoryBoilerplate.js";
13
- import GetBoilerplate from "../Boilerplate/GetBoilerplate.js";
14
- import ListBoilerplateCategoryBoilerplates from "../Boilerplate/ListBoilerplateCategoryBoilerplates.js";
15
- import ListBoilerplates from "../Boilerplate/ListBoilerplates.js";
16
- import UpdateBoilerplate from "../Boilerplate/UpdateBoilerplate.js";
17
- import CreateBoilerplateCategory from "../BoilerplateCategory/CreateBoilerplateCategory.js";
18
- import GetBoilerplateCategory from "../BoilerplateCategory/GetBoilerplateCategory.js";
19
- import ListBoilerplateCategories from "../BoilerplateCategory/ListBoilerplateCategories.js";
20
- import UpdateBoilerplateCategory from "../BoilerplateCategory/UpdateBoilerplateCategory.js";
21
- import ListChannels from "../Channel/ListChannels.js";
22
- import { BASE_URL_ENV_VAR } from "../constants/environment.js";
23
- import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
24
- import GetContactVCFURL from "../Contact/ContactVCF/GetContactVCF.js";
25
- import CreateContact from "../Contact/CreateContact.js";
26
- import GetContact from "../Contact/GetContact.js";
27
- import ListContacts from "../Contact/ListContacts.js";
28
- import ListLabelContacts from "../Contact/ListLabelContacts.js";
29
- import UpdateContact from "../Contact/UpdateContact.js";
30
- import GetConversation from "../Conversation/GetConversation.js";
31
- import ListContactConversations from "../Conversation/ListContactConversations.js";
32
- import ListConversations from "../Conversation/ListConversations.js";
33
- import ListLabelConversations from "../Conversation/ListLabelConversations.js";
34
- import UpdateConversation from "../Conversation/UpdateConversation.js";
35
- import CreateLabel from "../Label/CreateLabel.js";
36
- import DeleteLabel from "../Label/DeleteLabel.js";
37
- import GetLabel from "../Label/GetLabel.js";
38
- import ListLabels from "../Label/ListLabels.js";
39
- import UpdateLabel from "../Label/UpdateLabel.js";
40
- import ListConversationMessages from "../Message/ListConversationMessages.js";
41
- import ListMessages from "../Message/ListMessages.js";
42
- import CreateCorrectionModel from "../Model/Correction/CreateCorrectionModel.js";
43
- import GetModel from "../Model/GetModel.js";
44
- import ListModels from "../Model/ListModels.js";
45
- import CreateResponseModel from "../Model/Response/CreateResponseModel.js";
46
- import CreateContactNote from "../Note/CreateContactNote.js";
47
- import CreateConversationNote from "../Note/CreateConversationNote.js";
48
- import GetNote from "../Note/GetNote.js";
49
- import ListContactNotes from "../Note/ListContactNotes.js";
50
- import ListConversationNotes from "../Note/ListConversationNotes.js";
51
- import UpdateNote from "../Note/UpdateNote.js";
52
- import CreateContactNotificationSubscription from "../NotificationSubscription/CreateContactNotificationSubscription.js";
53
- import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
54
- import GetSource from "../Source/GetSource.js";
55
- import ListSources from "../Source/ListSources.js";
56
- import FetchTransport from "../Transport/FetchTransport.js";
57
- import Webhook from "../Webhook/index.js";
58
-
59
- export interface Options {
60
- baseURL?: string | URL;
61
- }
62
-
63
- export default class Client {
64
- public static DEFAULT_BASE_URL = DEFAULT_SUPPORT_BASE_URL;
65
-
66
- public _transport: FetchTransport;
67
-
68
- constructor(
69
- authentication: Authentication,
70
- { baseURL, ...options }: Options = {},
71
- ) {
72
- this._transport = new FetchTransport({
73
- requestFilterables: [new RequestStandardHeaders(), authentication],
74
- ...options,
75
- baseURL: baseURL?.toString() ?? Client.getBaseURL(),
76
- });
77
- }
78
-
79
- public static getBaseURL(): string {
80
- return process.env[BASE_URL_ENV_VAR] ?? this.DEFAULT_BASE_URL;
81
- }
82
-
83
- public get action() {
84
- return {
85
- list: new ListActions(this._transport),
86
- };
87
- }
88
-
89
- public get boilerplate() {
90
- return {
91
- get: new GetBoilerplate(this._transport),
92
- list: new ListBoilerplates(this._transport),
93
- update: new UpdateBoilerplate(this._transport),
94
- };
95
- }
96
-
97
- public get boilerplateCategory() {
98
- return {
99
- get: new GetBoilerplateCategory(this._transport),
100
- list: new ListBoilerplateCategories(this._transport),
101
- create: new CreateBoilerplateCategory(this._transport),
102
- update: new UpdateBoilerplateCategory(this._transport),
103
- boilerplate: {
104
- list: new ListBoilerplateCategoryBoilerplates(this._transport),
105
- create: new CreateBoilerplateCategoryBoilerplate(this._transport),
106
- },
107
- };
108
- }
109
-
110
- public get channel() {
111
- return {
112
- list: new ListChannels(this._transport),
113
- };
114
- }
115
-
116
- public get contact() {
117
- return {
118
- get: new GetContact(this._transport),
119
- list: new ListContacts(this._transport),
120
- update: new UpdateContact(this._transport),
121
- create: new CreateContact(this._transport),
122
- conversation: {
123
- list: new ListContactConversations(this._transport),
124
- },
125
- note: {
126
- list: new ListContactNotes(this._transport),
127
- create: new CreateContactNote(this._transport),
128
- },
129
- notificationSubscription: {
130
- create: new CreateContactNotificationSubscription(this._transport),
131
- },
132
- vcf: {
133
- get: new GetContactVCFURL(this._transport),
134
- },
135
- };
136
- }
137
-
138
- public get conversation() {
139
- return {
140
- get: new GetConversation(this._transport),
141
- list: new ListConversations(this._transport),
142
- update: new UpdateConversation(this._transport),
143
- create: new CreateConversationNote(this._transport),
144
- message: {
145
- list: new ListConversationMessages(this._transport),
146
- },
147
- note: {
148
- list: new ListConversationNotes(this._transport),
149
- create: new CreateConversationNote(this._transport),
150
- },
151
- };
152
- }
153
-
154
- public get label() {
155
- return {
156
- create: new CreateLabel(this._transport),
157
- get: new GetLabel(this._transport),
158
- list: new ListLabels(this._transport),
159
- update: new UpdateLabel(this._transport),
160
- delete: new DeleteLabel(this._transport),
161
- contact: {
162
- list: new ListLabelContacts(this._transport),
163
- },
164
- conversation: {
165
- list: new ListLabelConversations(this._transport),
166
- },
167
- };
168
- }
169
-
170
- public get message() {
171
- return {
172
- list: new ListMessages(this._transport),
173
- };
174
- }
175
-
176
- public get model() {
177
- return {
178
- get: new GetModel(this._transport),
179
- list: new ListModels(this._transport),
180
- response: {
181
- create: new CreateResponseModel(this._transport),
182
- },
183
- correction: {
184
- create: new CreateCorrectionModel(this._transport),
185
- },
186
- };
187
- }
188
-
189
- public get note() {
190
- return {
191
- get: new GetNote(this._transport),
192
- update: new UpdateNote(this._transport),
193
- };
194
- }
195
-
196
- public get source() {
197
- return {
198
- get: new GetSource(this._transport),
199
- list: new ListSources(this._transport),
200
- };
201
- }
202
-
203
- public get webhook() {
204
- return new Webhook(this);
205
- }
206
- }
@@ -1,45 +0,0 @@
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 FetchTransport from "../../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- id: string;
14
- vcf?:
15
- | {
16
- variant?: "vcard";
17
- format?: "vcf" | "qr";
18
- }
19
- | {
20
- variant: "jcard";
21
- format?: "json";
22
- };
23
- }
24
-
25
- export default class GetContactVCFURL {
26
- constructor(protected _transport: FetchTransport) {}
27
-
28
- public getRelativeURL({ id, vcf = {} }: Options) {
29
- const variant = vcf.variant ?? "vcard";
30
- const format = vcf.format ?? (vcf.variant === "vcard" ? "vcf" : "json");
31
-
32
- return (
33
- "v1/contacts/" +
34
- encodeURIComponent(id) +
35
- "/vcf?variant=" +
36
- encodeURIComponent(variant) +
37
- "&format=" +
38
- encodeURIComponent(format)
39
- );
40
- }
41
-
42
- public getURL(options: Options) {
43
- return this._transport.getURL(this.getRelativeURL(options));
44
- }
45
- }
@@ -1,51 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
12
-
13
- export interface Options {
14
- body: z.infer<typeof CreateContact.SCHEMA>;
15
- request?: RequestInit;
16
- }
17
-
18
- export type CreateContactResponse = {
19
- contact: {
20
- id: string;
21
- name?: string;
22
- emailAddress?: string;
23
- telephoneNumber?: string;
24
- account: string;
25
- createdAt: string;
26
- updatedAt?: string;
27
- };
28
- };
29
-
30
- export default class CreateContact {
31
- public static SCHEMA = z.object({
32
- name: z.string(),
33
- account: z.string(),
34
- emailAddress: z.string().email().optional(),
35
- telephoneNumber: z.string().optional(),
36
- });
37
-
38
- constructor(protected _transport: FetchTransport) {}
39
-
40
- public async send({ body, request = {} }: Options) {
41
- return this._transport.send<CreateContactResponse>("v1/contacts", {
42
- ...request,
43
- method: "POST",
44
- headers: {
45
- ...request.headers,
46
- "Content-Type": "application/json",
47
- },
48
- body: JSON.stringify(CreateContact.SCHEMA.parse(body)),
49
- });
50
- }
51
- }
@@ -1,41 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- id: string;
14
- request?: RequestInit;
15
- }
16
-
17
- export type GetContactResponse = {
18
- contact: {
19
- id: string;
20
- name?: string;
21
- emailAddress?: string;
22
- telephoneNumber?: string;
23
- account: string;
24
- createdAt: string;
25
- updatedAt?: string;
26
- };
27
- };
28
-
29
- export default class GetContact {
30
- constructor(protected _transport: FetchTransport) {}
31
-
32
- public async send({ id, request = {} }: Options) {
33
- return this._transport.send<GetContactResponse>(
34
- "v1/contacts/" + encodeURIComponent(id),
35
- {
36
- ...request,
37
- method: "GET",
38
- },
39
- );
40
- }
41
- }
@@ -1,37 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- request?: RequestInit;
14
- }
15
-
16
- export type ListContactsResponse = {
17
- contacts: {
18
- id: string;
19
- name?: string;
20
- emailAddress?: string;
21
- telephoneNumber?: string;
22
- account: string;
23
- createdAt: string;
24
- updatedAt?: string;
25
- }[];
26
- };
27
-
28
- export default class ListContacts {
29
- constructor(protected _transport: FetchTransport) {}
30
-
31
- public async send({ request = {} }: Options = {}) {
32
- return this._transport.send<ListContactsResponse>("v1/contacts", {
33
- ...request,
34
- method: "GET",
35
- });
36
- }
37
- }
@@ -1,41 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- id: string;
14
- request?: RequestInit;
15
- }
16
-
17
- export type ListLabelContactsResponse = {
18
- contacts: {
19
- id: string;
20
- name?: string;
21
- emailAddress?: string;
22
- telephoneNumber?: string;
23
- account: string;
24
- createdAt: string;
25
- updatedAt?: string;
26
- }[];
27
- };
28
-
29
- export default class ListLabelContacts {
30
- constructor(protected _transport: FetchTransport) {}
31
-
32
- public async send({ id, request = {} }: Options) {
33
- return this._transport.send<ListLabelContactsResponse>(
34
- "v1/labels/" + encodeURIComponent(id) + "/contacts",
35
- {
36
- ...request,
37
- method: "GET",
38
- },
39
- );
40
- }
41
- }
@@ -1,54 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
12
-
13
- export interface Options {
14
- id: string;
15
- body: z.infer<typeof UpdateContact.SCHEMA>;
16
- request?: RequestInit;
17
- }
18
-
19
- export type UpdateContactResponse = {
20
- contact: {
21
- id: string;
22
- name?: string;
23
- emailAddress?: string;
24
- telephoneNumber?: string;
25
- account: string;
26
- createdAt: string;
27
- updatedAt?: string;
28
- };
29
- };
30
-
31
- export default class UpdateContact {
32
- public static SCHEMA = z.object({
33
- name: z.string().optional(),
34
- emailAddress: z.string().email().optional(),
35
- telephoneNumber: z.string().optional(),
36
- });
37
-
38
- constructor(protected _transport: FetchTransport) {}
39
-
40
- public async send({ id, body, request = {} }: Options) {
41
- return this._transport.send<UpdateContactResponse>(
42
- "v1/contacts/" + encodeURIComponent(id),
43
- {
44
- ...request,
45
- method: "PATCH",
46
- headers: {
47
- ...request.headers,
48
- "Content-Type": "application/json",
49
- },
50
- body: JSON.stringify(UpdateContact.SCHEMA.parse(body)),
51
- },
52
- );
53
- }
54
- }
@@ -1,14 +0,0 @@
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
- export { type CreateContactResponse } from "./CreateContact.js";
11
- export { type GetContactResponse } from "./GetContact.js";
12
- export { type ListContactsResponse } from "./ListContacts.js";
13
- export { type ListLabelContactsResponse } from "./ListLabelContacts.js";
14
- export { type UpdateContactResponse } from "./UpdateContact.js";
@@ -1,58 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
12
-
13
- export interface Options {
14
- body: z.infer<typeof CreateConversation.SCHEMA>;
15
- request?: RequestInit;
16
- }
17
-
18
- export type CreateConversationResponse = {
19
- conversation: {
20
- id: string;
21
- name?: string;
22
- hasEnded: boolean;
23
- conversationStatus:
24
- | "AwaitingContactConversationStatus"
25
- | "AwaitingAgentConversationStatus"
26
- | "ResolvedConversationStatus"
27
- | "ClosedConversationStatus";
28
- accountChannel: string;
29
- createdAt: string;
30
- updatedAt: string;
31
- };
32
- };
33
-
34
- export default class CreateConversation {
35
- public static SCHEMA = z.object({
36
- name: z.string().optional(),
37
- });
38
-
39
- constructor(protected _transport: FetchTransport) {}
40
-
41
- /**
42
- * @deprecated Not Yet Implemented
43
- */
44
- public async send({ body, request = {} }: Options) {
45
- return this._transport.send<CreateConversationResponse>(
46
- "v1/conversations",
47
- {
48
- ...request,
49
- method: "POST",
50
- headers: {
51
- ...request.headers,
52
- "Content-Type": "application/json",
53
- },
54
- body: JSON.stringify(CreateConversation.SCHEMA.parse(body)),
55
- },
56
- );
57
- }
58
- }
@@ -1,45 +0,0 @@
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 FetchTransport from "../Transport/FetchTransport.js";
11
-
12
- export interface Options {
13
- id: string;
14
- request?: RequestInit;
15
- }
16
-
17
- export type GetConversationResponse = {
18
- conversation: {
19
- id: string;
20
- name?: string;
21
- hasEnded: boolean;
22
- conversationStatus:
23
- | "AwaitingContactConversationStatus"
24
- | "AwaitingAgentConversationStatus"
25
- | "ResolvedConversationStatus"
26
- | "ClosedConversationStatus";
27
- accountChannel: string;
28
- createdAt: string;
29
- updatedAt: string;
30
- };
31
- };
32
-
33
- export default class GetConversation {
34
- constructor(protected _transport: FetchTransport) {}
35
-
36
- public async send({ id, request = {} }: Options) {
37
- return this._transport.send<GetConversationResponse>(
38
- "v1/conversations/" + encodeURIComponent(id),
39
- {
40
- ...request,
41
- method: "GET",
42
- },
43
- );
44
- }
45
- }