@ikatec/digisac-api-sdk 4.11.0 → 4.12.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/apis/categories/types.d.ts +1 -0
- package/dist/apis/categories/types.d.ts.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs +15 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.cjs.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts +13 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.d.ts.map +1 -1
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs +15 -0
- package/dist/apis/interactiveMessages/InteractiveMessagesApi.mjs.map +1 -1
- package/dist/apis/interactiveMessages/types.d.ts +8 -2
- package/dist/apis/interactiveMessages/types.d.ts.map +1 -1
- package/dist/apis/me/MeApi.cjs +36 -29
- package/dist/apis/me/MeApi.cjs.map +1 -1
- package/dist/apis/me/MeApi.d.ts +33 -22
- package/dist/apis/me/MeApi.d.ts.map +1 -1
- package/dist/apis/me/MeApi.mjs +36 -29
- package/dist/apis/me/MeApi.mjs.map +1 -1
- package/dist/apis/me/types.d.ts +67 -4
- package/dist/apis/me/types.d.ts.map +1 -1
- package/dist/apis/transcripts/TranscriptsApi.cjs +12 -2
- package/dist/apis/transcripts/TranscriptsApi.cjs.map +1 -1
- package/dist/apis/transcripts/TranscriptsApi.d.ts +11 -5
- package/dist/apis/transcripts/TranscriptsApi.d.ts.map +1 -1
- package/dist/apis/transcripts/TranscriptsApi.mjs +12 -2
- package/dist/apis/transcripts/TranscriptsApi.mjs.map +1 -1
- package/dist/apis/transcripts/types.d.ts +4 -0
- package/dist/apis/transcripts/types.d.ts.map +1 -1
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs +52 -0
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.cjs.map +1 -1
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts +45 -2
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.d.ts.map +1 -1
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs +52 -0
- package/dist/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.mjs.map +1 -1
- package/dist/apis/whatsappBusinessTemplates/types.d.ts +34 -1
- package/dist/apis/whatsappBusinessTemplates/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/categories/types.ts +1 -0
- package/src/apis/interactiveMessages/InteractiveMessagesApi.test.ts +59 -0
- package/src/apis/interactiveMessages/InteractiveMessagesApi.ts +26 -0
- package/src/apis/interactiveMessages/types.ts +8 -2
- package/src/apis/me/MeApi.test.ts +44 -0
- package/src/apis/me/MeApi.ts +83 -28
- package/src/apis/me/types.ts +75 -4
- package/src/apis/payloads.test-d.ts +36 -2
- package/src/apis/transcripts/TranscriptsApi.test.ts +14 -21
- package/src/apis/transcripts/TranscriptsApi.ts +15 -6
- package/src/apis/transcripts/types.ts +4 -0
- package/src/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.test.ts +86 -0
- package/src/apis/whatsappBusinessTemplates/WhatsappBusinessTemplatesApi.ts +75 -1
- package/src/apis/whatsappBusinessTemplates/types.ts +38 -1
|
@@ -1,17 +1,91 @@
|
|
|
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
|
WhatsappBusinessTemplate,
|
|
5
6
|
CreateWhatsappBusinessTemplatePayload,
|
|
6
7
|
UpdateWhatsappBusinessTemplatePayload,
|
|
8
|
+
WhatsappBusinessTemplateHsmLimit,
|
|
7
9
|
} from './types'
|
|
8
10
|
|
|
11
|
+
/**
|
|
12
|
+
* WhatsApp Business templates. Create, update, reads and count are local; `sendToReview`, `refreshTemplates`,
|
|
13
|
+
* `resume` and the delete of a template of a `whatsapp-business` connection call the provider (Meta, 360Dialog).
|
|
14
|
+
* `getById` answers `null` for an unknown id.
|
|
15
|
+
*/
|
|
9
16
|
export class WhatsappBusinessTemplatesApi extends BaseCrudApi<
|
|
10
17
|
WhatsappBusinessTemplate,
|
|
11
18
|
CreateWhatsappBusinessTemplatePayload,
|
|
12
|
-
UpdateWhatsappBusinessTemplatePayload
|
|
19
|
+
UpdateWhatsappBusinessTemplatePayload,
|
|
20
|
+
ListQuery<WhatsappBusinessTemplate>,
|
|
21
|
+
unknown
|
|
13
22
|
> {
|
|
14
23
|
constructor(client: ApiClient) {
|
|
15
24
|
super(client, '/whatsapp-business-templates')
|
|
16
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Counts the templates matching the query.
|
|
29
|
+
* @permissions hsm.view
|
|
30
|
+
*/
|
|
31
|
+
count(
|
|
32
|
+
query?: ListQuery<WhatsappBusinessTemplate>,
|
|
33
|
+
headers?: Record<string, string>,
|
|
34
|
+
): Promise<{ count: number }> {
|
|
35
|
+
return this.client.get<{ count: number }>(
|
|
36
|
+
`${this.basePath}/count${this.toQueryString(query)}`,
|
|
37
|
+
headers,
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Reads the template limit of the plan of the account. Send the `accountId` of the current user: the route is
|
|
43
|
+
* outside the error handler of the backend, so an unknown id gets no answer (the request waits for the timeout).
|
|
44
|
+
* @permissions hsm.view
|
|
45
|
+
*/
|
|
46
|
+
getHsmLimit(
|
|
47
|
+
accountId: string,
|
|
48
|
+
headers?: Record<string, string>,
|
|
49
|
+
): Promise<WhatsappBusinessTemplateHsmLimit> {
|
|
50
|
+
return this.client.get<WhatsappBusinessTemplateHsmLimit>(
|
|
51
|
+
`${this.basePath}/${accountId}/hsmLimit`,
|
|
52
|
+
headers,
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Deletes a template. On a `whatsapp-business` connection it goes to the provider (and answers what it answers);
|
|
58
|
+
* a draft of another connection type is deleted locally (answers the stored template). An unknown id answers 500.
|
|
59
|
+
* @permissions hsm.view OR hsm.destroy
|
|
60
|
+
*/
|
|
61
|
+
override deleteById(id: string, headers?: Record<string, string>): Promise<unknown> {
|
|
62
|
+
return super.deleteById(id, headers)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* SENDS the template to Meta for approval (through the provider of the connection). An unknown or archived
|
|
67
|
+
* template answers 500 before anything is sent.
|
|
68
|
+
* @permissions hsm.view OR hsm.send OR hsm.send.before.expire
|
|
69
|
+
*/
|
|
70
|
+
sendToReview(id: string, headers?: Record<string, string>): Promise<unknown> {
|
|
71
|
+
return this.client.post<unknown>(`${this.basePath}/${id}/send-to-review`, undefined, headers)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Reads the templates of the connected `whatsapp-business` connections from the provider and syncs them (it may
|
|
76
|
+
* archive the local templates the provider no longer has). Resolves the text `'OK'`.
|
|
77
|
+
* @permissions hsm.view
|
|
78
|
+
*/
|
|
79
|
+
refreshTemplates(headers?: Record<string, string>): Promise<'OK'> {
|
|
80
|
+
return this.client.post<'OK'>(`${this.basePath}/refresh-templates`, undefined, headers)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Reads the template balance from 360Dialog. The backend looks for the 360Dialog connection on the whole platform,
|
|
85
|
+
* not only in the account, and calls 360Dialog when it finds one.
|
|
86
|
+
* @permissions hsm.view
|
|
87
|
+
*/
|
|
88
|
+
resume(headers?: Record<string, string>): Promise<Record<string, unknown>[]> {
|
|
89
|
+
return this.client.get<Record<string, unknown>[]>(`${this.basePath}/resume`, headers)
|
|
90
|
+
}
|
|
17
91
|
}
|
|
@@ -10,7 +10,8 @@ export type WhatsappBusinessTemplateHeaderFormat = 'TEXT' | 'IMAGE' | 'VIDEO' |
|
|
|
10
10
|
|
|
11
11
|
export type WhatsappBusinessTemplateButton = {
|
|
12
12
|
type: string
|
|
13
|
-
|
|
13
|
+
/** Overwritten by the backend on `REQUEST_CONTACT_INFO` buttons. */
|
|
14
|
+
text?: string
|
|
14
15
|
url?: string
|
|
15
16
|
params?: string[]
|
|
16
17
|
phone_number?: string
|
|
@@ -44,11 +45,40 @@ export type WhatsappBusinessTemplate = {
|
|
|
44
45
|
createdAt: string
|
|
45
46
|
updatedAt: string
|
|
46
47
|
deletedAt: string | null
|
|
48
|
+
/** Only the listing includes it by default; `getById` answers it with `include: ['fileExample']`. */
|
|
49
|
+
fileExample?: WhatsappBusinessTemplateFileExample | null
|
|
50
|
+
// relationships
|
|
51
|
+
service?: Record<string, unknown>
|
|
52
|
+
account?: Record<string, unknown>
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The media example of a template with a media header. */
|
|
56
|
+
export type WhatsappBusinessTemplateFileExample = Record<string, unknown>
|
|
57
|
+
|
|
58
|
+
/** The media example sent on create/update (`base64Url` as a data URL). */
|
|
59
|
+
export type WhatsappBusinessTemplateFileExampleInput = {
|
|
60
|
+
fileName: string
|
|
61
|
+
base64Url: string
|
|
62
|
+
mimetype: string
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
export type WhatsappBusinessTemplateHsmLimit = {
|
|
66
|
+
hsmLimit: number
|
|
67
|
+
hsmUsedLimit: number
|
|
68
|
+
/** The balance left (a number), or `true` when the account has no limit. */
|
|
69
|
+
hasLimit: number | boolean
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Stored locally (nothing goes to Meta until `sendToReview`). `status` is `''` for a draft and `namespace` is `''`
|
|
74
|
+
* until Meta answers — both are required by the database (500 without them).
|
|
75
|
+
*/
|
|
49
76
|
export type CreateWhatsappBusinessTemplatePayload = {
|
|
50
77
|
name: string
|
|
51
78
|
internalName: string
|
|
79
|
+
status: string
|
|
80
|
+
namespace: string
|
|
81
|
+
fileExample?: WhatsappBusinessTemplateFileExampleInput
|
|
52
82
|
components: WhatsappBusinessTemplateComponent[]
|
|
53
83
|
serviceId: string
|
|
54
84
|
messageType: WhatsappBusinessTemplateMessageType
|
|
@@ -56,7 +86,14 @@ export type CreateWhatsappBusinessTemplatePayload = {
|
|
|
56
86
|
category: WhatsappBusinessTemplateCategory
|
|
57
87
|
}
|
|
58
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The backend validates the same 7 fields of the create on the update (`name`, `internalName`, `components`,
|
|
91
|
+
* `serviceId`, `messageType`, `language`, `category`), but ignores `name`.
|
|
92
|
+
*/
|
|
59
93
|
export type UpdateWhatsappBusinessTemplatePayload = {
|
|
94
|
+
status?: string
|
|
95
|
+
namespace?: string
|
|
96
|
+
fileExample?: WhatsappBusinessTemplateFileExampleInput
|
|
60
97
|
name?: string
|
|
61
98
|
internalName?: string
|
|
62
99
|
components?: WhatsappBusinessTemplateComponent[]
|