@ikatec/digisac-api-sdk 4.8.0 → 4.10.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 +36 -12
- package/dist/apis/absence/AbsenceApi.cjs +12 -0
- package/dist/apis/absence/AbsenceApi.cjs.map +1 -1
- package/dist/apis/absence/AbsenceApi.d.ts +9 -0
- package/dist/apis/absence/AbsenceApi.d.ts.map +1 -1
- package/dist/apis/absence/AbsenceApi.mjs +12 -0
- package/dist/apis/absence/AbsenceApi.mjs.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.cjs +8 -0
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.cjs.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.d.ts +8 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.d.ts.map +1 -1
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.mjs +8 -0
- package/dist/apis/acceptanceTerms/AcceptanceTermsApi.mjs.map +1 -1
- package/dist/apis/accounts/AccountsApi.cjs +5 -0
- package/dist/apis/accounts/AccountsApi.cjs.map +1 -1
- package/dist/apis/accounts/AccountsApi.d.ts +5 -0
- package/dist/apis/accounts/AccountsApi.d.ts.map +1 -1
- package/dist/apis/accounts/AccountsApi.mjs +5 -0
- package/dist/apis/accounts/AccountsApi.mjs.map +1 -1
- package/dist/apis/accounts/types.d.ts +2 -0
- package/dist/apis/accounts/types.d.ts.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.cjs +12 -0
- package/dist/apis/activityLog/ActivityLogApi.cjs.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.d.ts +8 -0
- package/dist/apis/activityLog/ActivityLogApi.d.ts.map +1 -1
- package/dist/apis/activityLog/ActivityLogApi.mjs +12 -0
- package/dist/apis/activityLog/ActivityLogApi.mjs.map +1 -1
- package/dist/apis/categories/CategoriesApi.cjs +7 -0
- package/dist/apis/categories/CategoriesApi.cjs.map +1 -1
- package/dist/apis/categories/CategoriesApi.d.ts +7 -1
- package/dist/apis/categories/CategoriesApi.d.ts.map +1 -1
- package/dist/apis/categories/CategoriesApi.mjs +7 -0
- package/dist/apis/categories/CategoriesApi.mjs.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.cjs +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.cjs.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.d.ts.map +1 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.mjs +5 -1
- package/dist/apis/clientFeedback/ClientFeedbackApi.mjs.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs +8 -0
- package/dist/apis/contactBlockLists/ContactBlockListsApi.cjs.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts +8 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.d.ts.map +1 -1
- package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs +8 -0
- package/dist/apis/contactBlockLists/ContactBlockListsApi.mjs.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs +7 -0
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.cjs.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts +7 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.d.ts.map +1 -1
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs +7 -0
- package/dist/apis/contactBlockListsControls/ContactBlockListsControlsApi.mjs.map +1 -1
- package/dist/apis/contacts/ContactsApi.cjs +16 -3
- package/dist/apis/contacts/ContactsApi.cjs.map +1 -1
- package/dist/apis/contacts/ContactsApi.d.ts +16 -5
- package/dist/apis/contacts/ContactsApi.d.ts.map +1 -1
- package/dist/apis/contacts/ContactsApi.mjs +16 -3
- package/dist/apis/contacts/ContactsApi.mjs.map +1 -1
- package/dist/apis/contacts/types.d.ts +6 -1
- package/dist/apis/contacts/types.d.ts.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.cjs +17 -0
- package/dist/apis/creditMovements/CreditMovementsApi.cjs.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.d.ts +11 -0
- package/dist/apis/creditMovements/CreditMovementsApi.d.ts.map +1 -1
- package/dist/apis/creditMovements/CreditMovementsApi.mjs +17 -0
- package/dist/apis/creditMovements/CreditMovementsApi.mjs.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.cjs +7 -0
- package/dist/apis/customFields/CustomFieldsApi.cjs.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.d.ts +7 -1
- package/dist/apis/customFields/CustomFieldsApi.d.ts.map +1 -1
- package/dist/apis/customFields/CustomFieldsApi.mjs +7 -0
- package/dist/apis/customFields/CustomFieldsApi.mjs.map +1 -1
- package/dist/apis/departments/DepartmentsApi.cjs +21 -0
- package/dist/apis/departments/DepartmentsApi.cjs.map +1 -1
- package/dist/apis/departments/DepartmentsApi.d.ts +20 -2
- package/dist/apis/departments/DepartmentsApi.d.ts.map +1 -1
- package/dist/apis/departments/DepartmentsApi.mjs +21 -0
- package/dist/apis/departments/DepartmentsApi.mjs.map +1 -1
- package/dist/apis/departments/types.d.ts +5 -0
- package/dist/apis/departments/types.d.ts.map +1 -1
- package/dist/apis/distribution/DistributionApi.cjs +7 -0
- package/dist/apis/distribution/DistributionApi.cjs.map +1 -1
- package/dist/apis/distribution/DistributionApi.d.ts +7 -1
- package/dist/apis/distribution/DistributionApi.d.ts.map +1 -1
- package/dist/apis/distribution/DistributionApi.mjs +7 -0
- package/dist/apis/distribution/DistributionApi.mjs.map +1 -1
- package/dist/apis/files/FilesApi.cjs +49 -0
- package/dist/apis/files/FilesApi.cjs.map +1 -1
- package/dist/apis/files/FilesApi.d.ts +45 -2
- package/dist/apis/files/FilesApi.d.ts.map +1 -1
- package/dist/apis/files/FilesApi.mjs +49 -0
- package/dist/apis/files/FilesApi.mjs.map +1 -1
- package/dist/apis/files/types.d.ts +45 -7
- package/dist/apis/files/types.d.ts.map +1 -1
- package/dist/apis/holiday/HolidayApi.cjs +7 -0
- package/dist/apis/holiday/HolidayApi.cjs.map +1 -1
- package/dist/apis/holiday/HolidayApi.d.ts +7 -1
- package/dist/apis/holiday/HolidayApi.d.ts.map +1 -1
- package/dist/apis/holiday/HolidayApi.mjs +7 -0
- package/dist/apis/holiday/HolidayApi.mjs.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.cjs +7 -0
- package/dist/apis/integrations/IntegrationsApi.cjs.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.d.ts +7 -1
- package/dist/apis/integrations/IntegrationsApi.d.ts.map +1 -1
- package/dist/apis/integrations/IntegrationsApi.mjs +7 -0
- package/dist/apis/integrations/IntegrationsApi.mjs.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs +7 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts +7 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs +7 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs.map +1 -1
- package/dist/apis/interactiveMessages/types.d.ts +61 -3
- package/dist/apis/interactiveMessages/types.d.ts.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.cjs +7 -0
- package/dist/apis/kanbanBoards/KanbanBoardsApi.cjs.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.d.ts +7 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.d.ts.map +1 -1
- package/dist/apis/kanbanBoards/KanbanBoardsApi.mjs +7 -0
- package/dist/apis/kanbanBoards/KanbanBoardsApi.mjs.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.cjs +7 -0
- package/dist/apis/kanbanCards/KanbanCardsApi.cjs.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.d.ts +7 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.d.ts.map +1 -1
- package/dist/apis/kanbanCards/KanbanCardsApi.mjs +7 -0
- package/dist/apis/kanbanCards/KanbanCardsApi.mjs.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs +8 -0
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.cjs.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts +8 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.d.ts.map +1 -1
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs +8 -0
- package/dist/apis/knowledgeBase/KnowledgeBaseApi.mjs.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs +8 -0
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.cjs.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts +8 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.d.ts.map +1 -1
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs +8 -0
- package/dist/apis/knowledgeBaseItem/KnowledgeBaseItemApi.mjs.map +1 -1
- package/dist/apis/messages/MessagesApi.cjs +23 -3
- package/dist/apis/messages/MessagesApi.cjs.map +1 -1
- package/dist/apis/messages/MessagesApi.d.ts +19 -3
- package/dist/apis/messages/MessagesApi.d.ts.map +1 -1
- package/dist/apis/messages/MessagesApi.mjs +23 -3
- package/dist/apis/messages/MessagesApi.mjs.map +1 -1
- package/dist/apis/messages/types.d.ts +3 -0
- package/dist/apis/messages/types.d.ts.map +1 -1
- package/dist/apis/notifications/NotificationsApi.cjs +7 -0
- package/dist/apis/notifications/NotificationsApi.cjs.map +1 -1
- package/dist/apis/notifications/NotificationsApi.d.ts +7 -1
- package/dist/apis/notifications/NotificationsApi.d.ts.map +1 -1
- package/dist/apis/notifications/NotificationsApi.mjs +7 -0
- package/dist/apis/notifications/NotificationsApi.mjs.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.cjs +7 -0
- package/dist/apis/organizations/OrganizationsApi.cjs.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.d.ts +7 -1
- package/dist/apis/organizations/OrganizationsApi.d.ts.map +1 -1
- package/dist/apis/organizations/OrganizationsApi.mjs +7 -0
- package/dist/apis/organizations/OrganizationsApi.mjs.map +1 -1
- package/dist/apis/people/PeopleApi.cjs +7 -0
- package/dist/apis/people/PeopleApi.cjs.map +1 -1
- package/dist/apis/people/PeopleApi.d.ts +7 -1
- package/dist/apis/people/PeopleApi.d.ts.map +1 -1
- package/dist/apis/people/PeopleApi.mjs +7 -0
- package/dist/apis/people/PeopleApi.mjs.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.cjs +16 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.cjs.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.d.ts +10 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.d.ts.map +1 -1
- package/dist/apis/planAiHistory/PlanAiHistoryApi.mjs +16 -0
- package/dist/apis/planAiHistory/PlanAiHistoryApi.mjs.map +1 -1
- package/dist/apis/roles/RolesApi.cjs +7 -0
- package/dist/apis/roles/RolesApi.cjs.map +1 -1
- package/dist/apis/roles/RolesApi.d.ts +6 -1
- package/dist/apis/roles/RolesApi.d.ts.map +1 -1
- package/dist/apis/roles/RolesApi.mjs +7 -0
- package/dist/apis/roles/RolesApi.mjs.map +1 -1
- package/dist/apis/services/ServicesApi.cjs +68 -0
- package/dist/apis/services/ServicesApi.cjs.map +1 -1
- package/dist/apis/services/ServicesApi.d.ts +53 -1
- package/dist/apis/services/ServicesApi.d.ts.map +1 -1
- package/dist/apis/services/ServicesApi.mjs +68 -0
- package/dist/apis/services/ServicesApi.mjs.map +1 -1
- package/dist/apis/services/types.d.ts +68 -1
- package/dist/apis/services/types.d.ts.map +1 -1
- package/dist/apis/stickers/StickersApi.cjs +20 -0
- package/dist/apis/stickers/StickersApi.cjs.map +1 -1
- package/dist/apis/stickers/StickersApi.d.ts +15 -0
- package/dist/apis/stickers/StickersApi.d.ts.map +1 -1
- package/dist/apis/stickers/StickersApi.mjs +20 -0
- package/dist/apis/stickers/StickersApi.mjs.map +1 -1
- package/dist/apis/tags/TagsApi.cjs +7 -0
- package/dist/apis/tags/TagsApi.cjs.map +1 -1
- package/dist/apis/tags/TagsApi.d.ts +7 -1
- package/dist/apis/tags/TagsApi.d.ts.map +1 -1
- package/dist/apis/tags/TagsApi.mjs +7 -0
- package/dist/apis/tags/TagsApi.mjs.map +1 -1
- package/dist/apis/timetable/TimetableApi.cjs +7 -0
- package/dist/apis/timetable/TimetableApi.cjs.map +1 -1
- package/dist/apis/timetable/TimetableApi.d.ts +7 -1
- package/dist/apis/timetable/TimetableApi.d.ts.map +1 -1
- package/dist/apis/timetable/TimetableApi.mjs +7 -0
- package/dist/apis/timetable/TimetableApi.mjs.map +1 -1
- package/dist/apis/users/UsersApi.cjs +8 -0
- package/dist/apis/users/UsersApi.cjs.map +1 -1
- package/dist/apis/users/UsersApi.d.ts +8 -1
- package/dist/apis/users/UsersApi.d.ts.map +1 -1
- package/dist/apis/users/UsersApi.mjs +8 -0
- package/dist/apis/users/UsersApi.mjs.map +1 -1
- package/dist/apis/users/types.d.ts +15 -0
- package/dist/apis/users/types.d.ts.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.cjs +7 -0
- package/dist/apis/webhooks/WebhooksApi.cjs.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.d.ts +7 -1
- package/dist/apis/webhooks/WebhooksApi.d.ts.map +1 -1
- package/dist/apis/webhooks/WebhooksApi.mjs +7 -0
- package/dist/apis/webhooks/WebhooksApi.mjs.map +1 -1
- package/dist/core/ApiClient.d.ts +14 -0
- package/dist/core/ApiClient.d.ts.map +1 -1
- package/dist/core/ArchivableCrudApi.cjs.map +1 -1
- package/dist/core/ArchivableCrudApi.d.ts +1 -1
- package/dist/core/ArchivableCrudApi.d.ts.map +1 -1
- package/dist/core/ArchivableCrudApi.mjs.map +1 -1
- package/dist/core/BaseApiClient.cjs +24 -3
- package/dist/core/BaseApiClient.cjs.map +1 -1
- package/dist/core/BaseApiClient.d.ts +14 -0
- package/dist/core/BaseApiClient.d.ts.map +1 -1
- package/dist/core/BaseApiClient.mjs +24 -3
- package/dist/core/BaseApiClient.mjs.map +1 -1
- package/dist/core/requestExternal.cjs +33 -0
- package/dist/core/requestExternal.cjs.map +1 -0
- package/dist/core/requestExternal.d.ts +9 -0
- package/dist/core/requestExternal.d.ts.map +1 -0
- package/dist/core/requestExternal.mjs +32 -0
- package/dist/core/requestExternal.mjs.map +1 -0
- package/package.json +1 -1
- package/src/apis/absence/AbsenceApi.ts +19 -0
- package/src/apis/acceptanceTerms/AcceptanceTermsApi.ts +13 -1
- package/src/apis/accounts/AccountsApi.ts +5 -0
- package/src/apis/accounts/types.ts +2 -0
- package/src/apis/activityLog/ActivityLogApi.ts +18 -0
- package/src/apis/categories/CategoriesApi.ts +12 -1
- package/src/apis/clientFeedback/ClientFeedbackApi.ts +5 -1
- package/src/apis/contactBlockLists/ContactBlockListsApi.ts +13 -1
- package/src/apis/contactBlockListsControls/ContactBlockListsControlsApi.ts +12 -1
- package/src/apis/contacts/ContactsApi.test.ts +20 -4
- package/src/apis/contacts/ContactsApi.ts +24 -5
- package/src/apis/contacts/types.ts +7 -1
- package/src/apis/creditMovements/CreditMovementsApi.ts +27 -0
- package/src/apis/customFields/CustomFieldsApi.ts +12 -1
- package/src/apis/departments/DepartmentsApi.test.ts +88 -0
- package/src/apis/departments/DepartmentsApi.ts +41 -2
- package/src/apis/departments/types.ts +6 -0
- package/src/apis/distribution/DistributionApi.ts +12 -1
- package/src/apis/files/FilesApi.test.ts +122 -0
- package/src/apis/files/FilesApi.ts +107 -2
- package/src/apis/files/types.ts +48 -7
- package/src/apis/holiday/HolidayApi.ts +16 -1
- package/src/apis/integrations/IntegrationsApi.ts +12 -1
- package/src/apis/interactiveMessages/InteractiveMessagesApi.ts +12 -1
- package/src/apis/interactiveMessages/types.ts +67 -1
- package/src/apis/kanbanBoards/KanbanBoardsApi.ts +12 -1
- package/src/apis/kanbanCards/KanbanCardsApi.ts +12 -1
- package/src/apis/knowledgeBase/KnowledgeBaseApi.ts +13 -1
- package/src/apis/knowledgeBaseItem/KnowledgeBaseItemApi.ts +13 -1
- package/src/apis/messages/MessagesApi.test.ts +13 -7
- package/src/apis/messages/MessagesApi.ts +29 -3
- package/src/apis/messages/types.ts +3 -0
- package/src/apis/notifications/NotificationsApi.ts +12 -1
- package/src/apis/organizations/OrganizationsApi.ts +12 -1
- package/src/apis/payloads.test-d.ts +275 -0
- package/src/apis/payloads.test.ts +41 -0
- package/src/apis/people/PeopleApi.ts +16 -1
- package/src/apis/planAiHistory/PlanAiHistoryApi.ts +26 -0
- package/src/apis/roles/RolesApi.ts +10 -1
- package/src/apis/services/ServicesApi.test.ts +45 -0
- package/src/apis/services/ServicesApi.ts +91 -1
- package/src/apis/services/types.ts +63 -1
- package/src/apis/stickers/StickersApi.ts +32 -0
- package/src/apis/tags/TagsApi.ts +16 -1
- package/src/apis/timetable/TimetableApi.ts +12 -1
- package/src/apis/users/UsersApi.ts +17 -1
- package/src/apis/users/types.ts +11 -0
- package/src/apis/webhooks/WebhooksApi.ts +16 -1
- package/src/core/ApiClient.ts +24 -0
- package/src/core/ArchivableCrudApi.ts +2 -1
- package/src/core/BaseApiClient.test.ts +98 -0
- package/src/core/BaseApiClient.ts +49 -4
- package/src/core/requestExternal.ts +43 -0
|
@@ -1,13 +1,52 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { ArchivableCrudApi } from '../../core/ArchivableCrudApi'
|
|
3
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
Department,
|
|
6
|
+
CreateDepartmentPayload,
|
|
7
|
+
UpdateDepartmentPayload,
|
|
8
|
+
ArchiveDepartmentPayload,
|
|
9
|
+
} from './types'
|
|
4
10
|
|
|
5
11
|
export class DepartmentsApi extends ArchivableCrudApi<
|
|
6
12
|
Department,
|
|
7
13
|
CreateDepartmentPayload,
|
|
8
|
-
UpdateDepartmentPayload
|
|
14
|
+
UpdateDepartmentPayload,
|
|
15
|
+
ListQuery<Department>,
|
|
16
|
+
'OK'
|
|
9
17
|
> {
|
|
10
18
|
constructor(client: ApiClient) {
|
|
11
19
|
super(client, '/departments')
|
|
12
20
|
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Archives (`archive: true`) or restores (`archive: false`) a department through the route used
|
|
24
|
+
* by the UI, which enforces what {@link archive}/{@link unarchive} (a plain `PUT { archivedAt }`)
|
|
25
|
+
* skip: archiving refuses (403 `Cannot archive department.`, with the reasons and the open
|
|
26
|
+
* tickets count) a department in use, and clears it as the default department of contacts and
|
|
27
|
+
* connections, marks its schedules as done and unlinks its users and quick replies. Resolves the
|
|
28
|
+
* stored department (not transformed); an unknown id answers 500.
|
|
29
|
+
* @permissions departments.view OR departments.archive
|
|
30
|
+
*/
|
|
31
|
+
archiveWithValidation(
|
|
32
|
+
id: string,
|
|
33
|
+
body: ArchiveDepartmentPayload,
|
|
34
|
+
headers?: Record<string, string>,
|
|
35
|
+
): Promise<Department> {
|
|
36
|
+
return this.client.post<Department, ArchiveDepartmentPayload>(
|
|
37
|
+
`${this.basePath}/${id}/archive`,
|
|
38
|
+
body,
|
|
39
|
+
headers,
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Deletes a department. Resolves the text `'OK'`; a department that is the default of the account
|
|
45
|
+
* or that is referenced in the attendant name visibility settings is refused, and an unknown id
|
|
46
|
+
* answers 500.
|
|
47
|
+
* @permissions departments.view OR departments.archive
|
|
48
|
+
*/
|
|
49
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
50
|
+
return super.deleteById(id, headers)
|
|
51
|
+
}
|
|
13
52
|
}
|
|
@@ -26,3 +26,9 @@ export type UpdateDepartmentPayload = {
|
|
|
26
26
|
distributionId?: string | null
|
|
27
27
|
archivedAt?: string | null
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
/** Body of `DepartmentsApi.archiveWithValidation`. */
|
|
31
|
+
export type ArchiveDepartmentPayload = {
|
|
32
|
+
/** `true` archives, `false` restores. */
|
|
33
|
+
archive: boolean
|
|
34
|
+
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Distribution, CreateDistributionPayload, UpdateDistributionPayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class DistributionApi extends BaseCrudApi<
|
|
6
7
|
Distribution,
|
|
7
8
|
CreateDistributionPayload,
|
|
8
|
-
UpdateDistributionPayload
|
|
9
|
+
UpdateDistributionPayload,
|
|
10
|
+
ListQuery<Distribution>,
|
|
11
|
+
void
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/distribution')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a distribution. Resolves with no body, also for an unknown id (200).
|
|
19
|
+
* @permissions distribution.view OR distribution.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<void> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
13
24
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { FilesApi } from './FilesApi'
|
|
3
|
+
import type { ApiClient } from '../../core/ApiClient'
|
|
4
|
+
import { ApiConnectionError, ApiError } from '../../core/errors'
|
|
5
|
+
import type { CreateToUploadResult } from './types'
|
|
6
|
+
|
|
7
|
+
// ── Mock client factory ──────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
function createMockClient(): ApiClient {
|
|
10
|
+
return {
|
|
11
|
+
setAccessToken: vi.fn().mockReturnThis(),
|
|
12
|
+
request: vi.fn(),
|
|
13
|
+
get: vi.fn(),
|
|
14
|
+
post: vi.fn(),
|
|
15
|
+
put: vi.fn(),
|
|
16
|
+
patch: vi.fn(),
|
|
17
|
+
delete: vi.fn(),
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const URL_TO_UPLOAD = 'https://storage.example.com/acc-1/file-1.plain?X-Amz-Signature=abc'
|
|
22
|
+
|
|
23
|
+
// ── Tests ────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
describe('FilesApi', () => {
|
|
26
|
+
let client: ReturnType<typeof createMockClient>
|
|
27
|
+
let api: FilesApi
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
client = createMockClient()
|
|
31
|
+
api = new FilesApi(client)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
vi.restoreAllMocks()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe('createToUpload', () => {
|
|
39
|
+
it('calls client.post with /files/create-to-upload and body', async () => {
|
|
40
|
+
const created: CreateToUploadResult = {
|
|
41
|
+
urlToUpload: URL_TO_UPLOAD,
|
|
42
|
+
id: 'file-1',
|
|
43
|
+
name: 'report.txt',
|
|
44
|
+
mimetype: 'text/plain',
|
|
45
|
+
}
|
|
46
|
+
vi.mocked(client.post).mockResolvedValue(created)
|
|
47
|
+
const body = { name: 'report.txt', mimetype: 'text/plain', attachedType: 'campaign.file' }
|
|
48
|
+
const result = await api.createToUpload(body)
|
|
49
|
+
expect(client.post).toHaveBeenCalledWith('/files/create-to-upload', body, undefined)
|
|
50
|
+
expect(result).toEqual(created)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('upload', () => {
|
|
55
|
+
it('sends through client.requestExternal when the client has it', async () => {
|
|
56
|
+
const requestExternal = vi.fn().mockResolvedValue(new Response(null, { status: 200 }))
|
|
57
|
+
const fetchSpy = vi.spyOn(globalThis, 'fetch')
|
|
58
|
+
api = new FilesApi({ ...client, requestExternal })
|
|
59
|
+
await api.upload(URL_TO_UPLOAD, 'content', 'text/plain')
|
|
60
|
+
expect(requestExternal).toHaveBeenCalledWith('PUT', URL_TO_UPLOAD, 'content', {
|
|
61
|
+
'Content-Type': 'text/plain',
|
|
62
|
+
})
|
|
63
|
+
expect(fetchSpy).not.toHaveBeenCalled()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('without client.requestExternal, PUTs the content to the signed URL with the global fetch', async () => {
|
|
67
|
+
const spy = vi
|
|
68
|
+
.spyOn(globalThis, 'fetch')
|
|
69
|
+
.mockResolvedValue(new Response(null, { status: 200 }))
|
|
70
|
+
await api.upload(URL_TO_UPLOAD, 'content', 'text/plain')
|
|
71
|
+
expect(spy).toHaveBeenCalledWith(URL_TO_UPLOAD, {
|
|
72
|
+
method: 'PUT',
|
|
73
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
74
|
+
body: 'content',
|
|
75
|
+
})
|
|
76
|
+
expect(client.request).not.toHaveBeenCalled()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('throws ApiError when the storage refuses the upload', async () => {
|
|
80
|
+
vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
|
81
|
+
new Response('<Error><Code>SignatureDoesNotMatch</Code></Error>', {
|
|
82
|
+
status: 403,
|
|
83
|
+
statusText: 'Forbidden',
|
|
84
|
+
}),
|
|
85
|
+
)
|
|
86
|
+
const captured = await api.upload(URL_TO_UPLOAD, 'content', 'text/plain').catch((e) => e)
|
|
87
|
+
expect(captured).toBeInstanceOf(ApiError)
|
|
88
|
+
expect((captured as ApiError).status).toBe(403)
|
|
89
|
+
expect((captured as ApiError).body).toBe('<Error><Code>SignatureDoesNotMatch</Code></Error>')
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('throws ApiConnectionError when the request fails', async () => {
|
|
93
|
+
vi.spyOn(globalThis, 'fetch').mockRejectedValue(new TypeError('fetch failed'))
|
|
94
|
+
await expect(api.upload(URL_TO_UPLOAD, 'content', 'text/plain')).rejects.toBeInstanceOf(
|
|
95
|
+
ApiConnectionError,
|
|
96
|
+
)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('deleteById', () => {
|
|
101
|
+
it('calls client.delete with /files/:id and resolves { success }', async () => {
|
|
102
|
+
vi.mocked(client.delete).mockResolvedValue({ success: true })
|
|
103
|
+
const result = await api.deleteById('file-1')
|
|
104
|
+
expect(client.delete).toHaveBeenCalledWith('/files/file-1', undefined)
|
|
105
|
+
expect(result).toEqual({ success: true })
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
describe('deprecated reads and update (no backend route)', () => {
|
|
110
|
+
it('still call the same paths', async () => {
|
|
111
|
+
await api.getById('file-1')
|
|
112
|
+
await api.getMany({ where: { id: 'file-1' } })
|
|
113
|
+
await api.updateById('file-1', { name: 'x' })
|
|
114
|
+
expect(client.get).toHaveBeenCalledWith('/files/file-1', undefined)
|
|
115
|
+
expect(client.get).toHaveBeenCalledWith(
|
|
116
|
+
`/files?query=${encodeURIComponent(JSON.stringify({ where: { id: 'file-1' } }))}`,
|
|
117
|
+
undefined,
|
|
118
|
+
)
|
|
119
|
+
expect(client.put).toHaveBeenCalledWith('/files/file-1', { name: 'x' }, undefined)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
})
|
|
@@ -1,9 +1,114 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
2
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
|
-
import
|
|
3
|
+
import { requestExternal } from '../../core/requestExternal'
|
|
4
|
+
import type { GetByIdQuery, ListQuery, Paginated } from '../../core/types'
|
|
5
|
+
import type {
|
|
6
|
+
File,
|
|
7
|
+
CreateFilePayload,
|
|
8
|
+
UpdateFilePayload,
|
|
9
|
+
CreateToUploadPayload,
|
|
10
|
+
CreateToUploadResult,
|
|
11
|
+
DeleteFileResult,
|
|
12
|
+
} from './types'
|
|
4
13
|
|
|
5
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Files of the account. The backend serves `POST /files` (the record only, no content),
|
|
16
|
+
* `POST /files/create-to-upload` (record + signed URL to upload the content), `POST
|
|
17
|
+
* /files/duplicate-file`, `DELETE /files/:id` and the signed download `GET
|
|
18
|
+
* /files/:accountId/:filename`; there is no list, read by id nor update.
|
|
19
|
+
*/
|
|
20
|
+
export class FilesApi extends BaseCrudApi<
|
|
21
|
+
File,
|
|
22
|
+
CreateFilePayload,
|
|
23
|
+
UpdateFilePayload,
|
|
24
|
+
ListQuery<File>,
|
|
25
|
+
DeleteFileResult
|
|
26
|
+
> {
|
|
6
27
|
constructor(client: ApiClient) {
|
|
7
28
|
super(client, '/files')
|
|
8
29
|
}
|
|
30
|
+
|
|
31
|
+
/** @deprecated Not served: the backend has no GET /files, so this route answers 404. */
|
|
32
|
+
override getMany(
|
|
33
|
+
query: ListQuery<File> & { paginate: false },
|
|
34
|
+
headers?: Record<string, string>,
|
|
35
|
+
): Promise<File[]>
|
|
36
|
+
/** @deprecated Not served: the backend has no GET /files, so this route answers 404. */
|
|
37
|
+
override getMany(
|
|
38
|
+
query?: ListQuery<File> & { paginate?: true },
|
|
39
|
+
headers?: Record<string, string>,
|
|
40
|
+
): Promise<Paginated<File>>
|
|
41
|
+
/** @deprecated Not served: the backend has no GET /files, so this route answers 404. */
|
|
42
|
+
override getMany(
|
|
43
|
+
query?: ListQuery<File>,
|
|
44
|
+
headers?: Record<string, string>,
|
|
45
|
+
): Promise<Paginated<File> | File[]>
|
|
46
|
+
override getMany(
|
|
47
|
+
query?: ListQuery<File>,
|
|
48
|
+
headers?: Record<string, string>,
|
|
49
|
+
): Promise<Paginated<File> | File[]> {
|
|
50
|
+
return super.getMany(query, headers)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @deprecated Not served: the backend has no GET /files, so this route answers 404. */
|
|
54
|
+
override getOne(query?: ListQuery<File>, headers?: Record<string, string>): Promise<File | null> {
|
|
55
|
+
return super.getOne(query, headers)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @deprecated Not served: the backend has no GET /files/:id, so this route answers 404. */
|
|
59
|
+
override getById(
|
|
60
|
+
id: string,
|
|
61
|
+
query?: GetByIdQuery<File>,
|
|
62
|
+
headers?: Record<string, string>,
|
|
63
|
+
): Promise<File> {
|
|
64
|
+
return super.getById(id, query, headers)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** @deprecated Not served: the backend has no PUT /files/:id, so this route answers 404. */
|
|
68
|
+
override updateById(
|
|
69
|
+
id: string,
|
|
70
|
+
body: UpdateFilePayload,
|
|
71
|
+
headers?: Record<string, string>,
|
|
72
|
+
): Promise<File> {
|
|
73
|
+
return super.updateById(id, body, headers)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Deletes a file. Resolves `{ success: true }`, also for an unknown id; a file of another
|
|
78
|
+
* account answers 403.
|
|
79
|
+
*/
|
|
80
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<DeleteFileResult> {
|
|
81
|
+
return super.deleteById(id, headers)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates the record of a file and returns the signed URL to upload its content: send the
|
|
86
|
+
* content with {@link upload}. An audio that must be converted (a voice message for the
|
|
87
|
+
* connection) is sent in `base64` instead, and then no `urlToUpload` is returned. `name` and
|
|
88
|
+
* `mimetype` are required (500 without them; an audio without `name` is named `recording`).
|
|
89
|
+
*/
|
|
90
|
+
createToUpload(
|
|
91
|
+
body: CreateToUploadPayload,
|
|
92
|
+
headers?: Record<string, string>,
|
|
93
|
+
): Promise<CreateToUploadResult> {
|
|
94
|
+
return this.client.post<CreateToUploadResult, CreateToUploadPayload>(
|
|
95
|
+
`${this.basePath}/create-to-upload`,
|
|
96
|
+
body,
|
|
97
|
+
headers,
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Uploads the content of a file to the `urlToUpload` returned by {@link createToUpload}. The URL
|
|
103
|
+
* is signed by the storage, so the request goes straight to it, without the API token (the
|
|
104
|
+
* storage refuses an `Authorization` header). `mimetype` must be the one sent to
|
|
105
|
+
* `createToUpload`. Sent through `client.requestExternal` (the global `fetch` for a client
|
|
106
|
+
* without it). A non-2xx answer of the storage throws `ApiError`.
|
|
107
|
+
*/
|
|
108
|
+
async upload(urlToUpload: string, content: BodyInit, mimetype: string): Promise<void> {
|
|
109
|
+
const headers = { 'Content-Type': mimetype }
|
|
110
|
+
await (this.client.requestExternal
|
|
111
|
+
? this.client.requestExternal('PUT', urlToUpload, content, headers)
|
|
112
|
+
: requestExternal('PUT', urlToUpload, content, headers))
|
|
113
|
+
}
|
|
9
114
|
}
|
package/src/apis/files/types.ts
CHANGED
|
@@ -23,22 +23,32 @@ export type FileStorage =
|
|
|
23
23
|
|
|
24
24
|
export type File = {
|
|
25
25
|
id: string
|
|
26
|
+
/** Signed URL to download the content. */
|
|
26
27
|
url: string
|
|
27
28
|
name: string | null
|
|
29
|
+
/** Name of the file in the storage (`<id>.<extension>`). */
|
|
30
|
+
publicFilename: string | null
|
|
28
31
|
checksum: string | null
|
|
29
32
|
mimetype: string
|
|
30
33
|
extension: string
|
|
31
|
-
isEncrypted: boolean
|
|
32
|
-
iv: string | null
|
|
33
|
-
attachedId: string | null
|
|
34
|
-
attachedType: string | null
|
|
35
|
-
storage: FileStorage
|
|
36
34
|
data: FileData
|
|
37
35
|
accountId: string
|
|
38
|
-
serviceId: string | null
|
|
39
36
|
createdAt: string
|
|
40
37
|
updatedAt: string
|
|
41
|
-
|
|
38
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
39
|
+
isEncrypted?: boolean
|
|
40
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
41
|
+
iv?: string | null
|
|
42
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
43
|
+
attachedId?: string | null
|
|
44
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
45
|
+
attachedType?: string | null
|
|
46
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
47
|
+
storage?: FileStorage
|
|
48
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
49
|
+
serviceId?: string | null
|
|
50
|
+
/** @deprecated Never answered: the file transformer leaves it out. */
|
|
51
|
+
deletedAt?: string | null
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
export type CreateFilePayload = {
|
|
@@ -56,3 +66,34 @@ export type UpdateFilePayload = {
|
|
|
56
66
|
attachedId?: string | null
|
|
57
67
|
attachedType?: string | null
|
|
58
68
|
}
|
|
69
|
+
|
|
70
|
+
/** Body of `FilesApi.createToUpload`. */
|
|
71
|
+
export type CreateToUploadPayload = {
|
|
72
|
+
/** File name (commas are replaced by spaces). Required, except for an audio. */
|
|
73
|
+
name?: string
|
|
74
|
+
mimetype: string
|
|
75
|
+
/** What the file is attached to, e.g. `'message.file'` (default), `'campaign.file'`, `'quickreply.file'`. */
|
|
76
|
+
attachedType?: string
|
|
77
|
+
/** Connection that will send the file (used to decide the audio conversion). */
|
|
78
|
+
serviceId?: string
|
|
79
|
+
/** Audio sent as a voice message (default `true`). */
|
|
80
|
+
isPtt?: boolean
|
|
81
|
+
/** Audio sent as a document, with no conversion (default `false`). */
|
|
82
|
+
sendAsDocument?: boolean
|
|
83
|
+
/** Content of an audio that must be converted (required in that case). */
|
|
84
|
+
base64?: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Result of `FilesApi.createToUpload`. */
|
|
88
|
+
export type CreateToUploadResult = {
|
|
89
|
+
/** Signed URL to send the content to (`FilesApi.upload`); absent when the audio was converted. */
|
|
90
|
+
urlToUpload?: string
|
|
91
|
+
id: string
|
|
92
|
+
name: string
|
|
93
|
+
mimetype: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Result of `FilesApi.deleteById`. */
|
|
97
|
+
export type DeleteFileResult = {
|
|
98
|
+
success: boolean
|
|
99
|
+
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Holiday, CreateHolidayPayload, UpdateHolidayPayload } from './types'
|
|
4
5
|
|
|
5
|
-
export class HolidayApi extends BaseCrudApi<
|
|
6
|
+
export class HolidayApi extends BaseCrudApi<
|
|
7
|
+
Holiday,
|
|
8
|
+
CreateHolidayPayload,
|
|
9
|
+
UpdateHolidayPayload,
|
|
10
|
+
ListQuery<Holiday>,
|
|
11
|
+
'OK'
|
|
12
|
+
> {
|
|
6
13
|
constructor(client: ApiClient) {
|
|
7
14
|
super(client, '/holiday')
|
|
8
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a holiday. Resolves the text `'OK'`.
|
|
19
|
+
* @permissions holidays.view OR holidays.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
9
24
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { Integration, CreateIntegrationPayload, UpdateIntegrationPayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class IntegrationsApi extends BaseCrudApi<
|
|
6
7
|
Integration,
|
|
7
8
|
CreateIntegrationPayload,
|
|
8
|
-
UpdateIntegrationPayload
|
|
9
|
+
UpdateIntegrationPayload,
|
|
10
|
+
ListQuery<Integration>,
|
|
11
|
+
'OK'
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/integrations')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes an integration. Resolves the text `'OK'`; an unknown id answers 500.
|
|
19
|
+
* @permissions integrations.view OR integrations.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
13
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type {
|
|
4
5
|
InteractiveMessage,
|
|
@@ -9,9 +10,19 @@ import type {
|
|
|
9
10
|
export class InteractiveMessagesApi extends BaseCrudApi<
|
|
10
11
|
InteractiveMessage,
|
|
11
12
|
CreateInteractiveMessagePayload,
|
|
12
|
-
UpdateInteractiveMessagePayload
|
|
13
|
+
UpdateInteractiveMessagePayload,
|
|
14
|
+
ListQuery<InteractiveMessage>,
|
|
15
|
+
'OK'
|
|
13
16
|
> {
|
|
14
17
|
constructor(client: ApiClient) {
|
|
15
18
|
super(client, '/interactive-messages')
|
|
16
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Deletes an interactive message. Resolves the text `'OK'`; an unknown id answers 500.
|
|
23
|
+
* @permissions interactive-messages.destroy OR interactive-messages.management.all.departments
|
|
24
|
+
*/
|
|
25
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
26
|
+
return super.deleteById(id, headers)
|
|
27
|
+
}
|
|
17
28
|
}
|
|
@@ -10,6 +10,37 @@ type InteractiveMessageButton = {
|
|
|
10
10
|
|
|
11
11
|
type InteractiveMessageBodyFooter = string | { text: string }
|
|
12
12
|
|
|
13
|
+
export type ChannelRedirectChannel = 'whatsapp' | 'telegram' | 'instagram' | 'webchat'
|
|
14
|
+
|
|
15
|
+
export type ChannelRedirectIdentifierType = 'phone' | 'botName'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Digisac-only setting of a `cta_url` message: the channel its URL was built for. It sits next to
|
|
19
|
+
* `action`, never inside `action.parameters`, and is stripped before the message reaches Meta. The
|
|
20
|
+
* backend reads it to add the ticket parameters to the URL on send. A missing key means
|
|
21
|
+
* `{ enabled: false }`.
|
|
22
|
+
*/
|
|
23
|
+
export type ChannelRedirect = {
|
|
24
|
+
enabled: boolean
|
|
25
|
+
channel?: ChannelRedirectChannel
|
|
26
|
+
/** `'phone'` for WhatsApp; `'phone'` or `'botName'` for Telegram; unset for the others. */
|
|
27
|
+
identifierType?: ChannelRedirectIdentifierType
|
|
28
|
+
/** Phone as `+<DDI><number>` without mask, or the Telegram bot / Instagram user name. */
|
|
29
|
+
identifier?: string
|
|
30
|
+
/** Id of the Webchat service, when `channel` is `'webchat'`. */
|
|
31
|
+
serviceId?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type CtaUrlAction = {
|
|
35
|
+
name: 'cta_url'
|
|
36
|
+
parameters: {
|
|
37
|
+
/** 1–20 characters after trim, without `{{…}}` variables. */
|
|
38
|
+
display_text: string
|
|
39
|
+
/** 1–2000 characters after trim, starting with `http://` or `https://`. */
|
|
40
|
+
url: string
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
13
44
|
// --- Response types ---
|
|
14
45
|
|
|
15
46
|
type InteractiveMedia = {
|
|
@@ -60,9 +91,27 @@ type ButtonInteractiveMessageContent = {
|
|
|
60
91
|
}
|
|
61
92
|
}
|
|
62
93
|
|
|
94
|
+
export type CtaUrlInteractiveMessageContent = {
|
|
95
|
+
type: 'cta_url'
|
|
96
|
+
header?: ButtonInteractiveMessageContent['header']
|
|
97
|
+
body: InteractiveMessageBodyFooter
|
|
98
|
+
footer?: InteractiveMessageBodyFooter
|
|
99
|
+
action: CtaUrlAction
|
|
100
|
+
channelRedirect?: ChannelRedirect
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Has no header or footer: WhatsApp refuses them on this type. */
|
|
104
|
+
export type RequestContactInfoInteractiveMessageContent = {
|
|
105
|
+
type: 'request_contact_info'
|
|
106
|
+
body: InteractiveMessageBodyFooter
|
|
107
|
+
action: { name?: string }
|
|
108
|
+
}
|
|
109
|
+
|
|
63
110
|
export type InteractiveMessageContent =
|
|
64
111
|
| ListInteractiveMessageContent
|
|
65
112
|
| ButtonInteractiveMessageContent
|
|
113
|
+
| CtaUrlInteractiveMessageContent
|
|
114
|
+
| RequestContactInfoInteractiveMessageContent
|
|
66
115
|
|
|
67
116
|
// --- Input types (create/update) ---
|
|
68
117
|
|
|
@@ -90,9 +139,26 @@ type ButtonInteractiveMessageContentInput = {
|
|
|
90
139
|
}
|
|
91
140
|
}
|
|
92
141
|
|
|
142
|
+
type CtaUrlInteractiveMessageContentInput = {
|
|
143
|
+
type: 'cta_url'
|
|
144
|
+
header?: ButtonInteractiveMessageContentInput['header']
|
|
145
|
+
body: InteractiveMessageBodyFooter
|
|
146
|
+
footer?: InteractiveMessageBodyFooter
|
|
147
|
+
action: CtaUrlAction
|
|
148
|
+
channelRedirect?: ChannelRedirect
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type RequestContactInfoInteractiveMessageContentInput = {
|
|
152
|
+
type: 'request_contact_info'
|
|
153
|
+
body: InteractiveMessageBodyFooter
|
|
154
|
+
action: { name: 'request_contact_info' }
|
|
155
|
+
}
|
|
156
|
+
|
|
93
157
|
type InteractiveMessageContentInput =
|
|
94
158
|
| ListInteractiveMessageContentInput
|
|
95
159
|
| ButtonInteractiveMessageContentInput
|
|
160
|
+
| CtaUrlInteractiveMessageContentInput
|
|
161
|
+
| RequestContactInfoInteractiveMessageContentInput
|
|
96
162
|
|
|
97
163
|
type InteractiveMessageFilePayload =
|
|
98
164
|
| { id: string }
|
|
@@ -103,7 +169,7 @@ type InteractiveMessageFilePayload =
|
|
|
103
169
|
export type InteractiveMessage = {
|
|
104
170
|
id: string
|
|
105
171
|
name: string
|
|
106
|
-
type: 'list' | 'button'
|
|
172
|
+
type: 'list' | 'button' | 'cta_url' | 'request_contact_info'
|
|
107
173
|
interactive: InteractiveMessageContent
|
|
108
174
|
archivedAt: string | null
|
|
109
175
|
accountId: string
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { KanbanBoard, CreateKanbanBoardPayload, UpdateKanbanBoardPayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class KanbanBoardsApi extends BaseCrudApi<
|
|
6
7
|
KanbanBoard,
|
|
7
8
|
CreateKanbanBoardPayload,
|
|
8
|
-
UpdateKanbanBoardPayload
|
|
9
|
+
UpdateKanbanBoardPayload,
|
|
10
|
+
ListQuery<KanbanBoard>,
|
|
11
|
+
'OK'
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/kanban-boards')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a board with its columns. Resolves the text `'OK'`; an unknown id answers 500.
|
|
19
|
+
* @permissions kanban.boards.destroy
|
|
20
|
+
*/
|
|
21
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
22
|
+
return super.deleteById(id, headers)
|
|
23
|
+
}
|
|
13
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type {
|
|
4
5
|
KanbanCard,
|
|
@@ -10,12 +11,22 @@ import type {
|
|
|
10
11
|
export class KanbanCardsApi extends BaseCrudApi<
|
|
11
12
|
KanbanCard,
|
|
12
13
|
CreateKanbanCardPayload,
|
|
13
|
-
UpdateKanbanCardPayload
|
|
14
|
+
UpdateKanbanCardPayload,
|
|
15
|
+
ListQuery<KanbanCard>,
|
|
16
|
+
'OK'
|
|
14
17
|
> {
|
|
15
18
|
constructor(client: ApiClient) {
|
|
16
19
|
super(client, '/kanban-cards')
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Deletes a card. Resolves the text `'OK'`.
|
|
24
|
+
* @permissions kanban.cards.move
|
|
25
|
+
*/
|
|
26
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<'OK'> {
|
|
27
|
+
return super.deleteById(id, headers)
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
/**
|
|
20
31
|
* Moves a card within its column or to another column (see {@link ReorderKanbanCardPayload}).
|
|
21
32
|
* Resolves to the card with its new `position` and `columnId`.
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import type { ApiClient } from '../../core/ApiClient'
|
|
2
|
+
import type { ListQuery } from '../../core/types'
|
|
2
3
|
import { BaseCrudApi } from '../../core/BaseCrudApi'
|
|
3
4
|
import type { KnowledgeBase, CreateKnowledgeBasePayload, UpdateKnowledgeBasePayload } from './types'
|
|
4
5
|
|
|
5
6
|
export class KnowledgeBaseApi extends BaseCrudApi<
|
|
6
7
|
KnowledgeBase,
|
|
7
8
|
CreateKnowledgeBasePayload,
|
|
8
|
-
UpdateKnowledgeBasePayload
|
|
9
|
+
UpdateKnowledgeBasePayload,
|
|
10
|
+
ListQuery<KnowledgeBase>,
|
|
11
|
+
false
|
|
9
12
|
> {
|
|
10
13
|
constructor(client: ApiClient) {
|
|
11
14
|
super(client, '/knowledge-base')
|
|
12
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a knowledge base. Resolves `false` even when it deleted (the backend answers nothing
|
|
19
|
+
* from the deletion), so do not read it as the result: check with `getById`. An unknown id
|
|
20
|
+
* answers 500.
|
|
21
|
+
*/
|
|
22
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<false> {
|
|
23
|
+
return super.deleteById(id, headers)
|
|
24
|
+
}
|
|
13
25
|
}
|