@ikatec/digisac-api-sdk 4.6.0 → 4.8.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 +11 -8
- package/dist/apis/campaigns/CampaignsApi.cjs +122 -55
- package/dist/apis/campaigns/CampaignsApi.cjs.map +1 -1
- package/dist/apis/campaigns/CampaignsApi.d.ts +86 -24
- package/dist/apis/campaigns/CampaignsApi.d.ts.map +1 -1
- package/dist/apis/campaigns/CampaignsApi.mjs +120 -55
- package/dist/apis/campaigns/CampaignsApi.mjs.map +1 -1
- package/dist/apis/campaigns/types.d.ts +153 -14
- package/dist/apis/campaigns/types.d.ts.map +1 -1
- package/dist/apis/tickets/TicketsApi.cjs +74 -1
- package/dist/apis/tickets/TicketsApi.cjs.map +1 -1
- package/dist/apis/tickets/TicketsApi.d.ts +68 -3
- package/dist/apis/tickets/TicketsApi.d.ts.map +1 -1
- package/dist/apis/tickets/TicketsApi.mjs +74 -1
- package/dist/apis/tickets/TicketsApi.mjs.map +1 -1
- package/dist/apis/tickets/types.d.ts +69 -8
- package/dist/apis/tickets/types.d.ts.map +1 -1
- package/dist/incommingWebhooks/index.d.ts +10 -2
- package/dist/incommingWebhooks/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/campaigns/CampaignsApi.test.ts +177 -44
- package/src/apis/campaigns/CampaignsApi.ts +167 -45
- package/src/apis/campaigns/types.ts +165 -14
- package/src/apis/payloads.test-d.ts +74 -1
- package/src/apis/queryFormat.test.ts +48 -0
- package/src/apis/tickets/TicketsApi.test.ts +142 -5
- package/src/apis/tickets/TicketsApi.ts +135 -3
- package/src/apis/tickets/types.ts +76 -6
- package/src/incommingWebhooks/index.test-d.ts +14 -1
- package/src/incommingWebhooks/index.ts +11 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TicketsApi.mjs","names":[],"sources":["../../../src/apis/tickets/TicketsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type {\n Ticket,\n CreateTicketPayload,\n UpdateTicketPayload,\n CloseManyTicketsPayload,\n} from './types'\n\nexport class TicketsApi extends BaseCrudApi<Ticket, CreateTicketPayload, UpdateTicketPayload> {\n constructor(client: ApiClient) {\n super(client, '/tickets')\n }\n\n /**\n * Closes multiple tickets in a single request. This is the only ticket-close\n * endpoint exposed by the API — there is no per-ticket close/update route.\n *\n * Pass `{ ids }` to close specific tickets, or `{ allContactsSelected: true, query }`\n * to close every OPEN ticket matching `query` (the backend forces `isOpen: true`)
|
|
1
|
+
{"version":3,"file":"TicketsApi.mjs","names":[],"sources":["../../../src/apis/tickets/TicketsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type {\n Ticket,\n CreateTicketPayload,\n UpdateTicketPayload,\n CloseManyTicketsPayload,\n TicketsCount,\n TicketsCountManyQuery,\n TicketsCountPostPayload,\n TicketsCounts,\n TicketsListQuery,\n} from './types'\n\n/**\n * Tickets. The backend only serves them for reading (`getMany`, `getOne`, `getById`, the counts,\n * the first waiting time and the exports) plus `closeMany`: a ticket is opened and transferred by\n * `ContactsApi.transferTicket`. The reads check no permission (any authenticated user): the\n * `@permissions` of the inherited `getMany`, `getOne` and `getById` do not apply here. `getById`\n * of an unknown id resolves `null`. For a user who is not an admin, `getMany` leaves out the\n * tickets of the contacts of the connections restricted to that user; the counts and `getById`\n * do not.\n */\nexport class TicketsApi extends BaseCrudApi<Ticket, CreateTicketPayload, UpdateTicketPayload> {\n constructor(client: ApiClient) {\n super(client, '/tickets')\n }\n\n /** @deprecated Not served: `POST /tickets` answers 404 `Route not found.`. Open a ticket through `ContactsApi.transferTicket`. */\n override create(body: CreateTicketPayload, headers?: Record<string, string>): Promise<Ticket> {\n return super.create(body, headers)\n }\n\n /** @deprecated Not served: `PUT /tickets/{id}` answers 404 `Route not found.`. Transfer through `ContactsApi.transferTicket`, close through `closeMany`. */\n override updateById(\n id: string,\n body: UpdateTicketPayload,\n headers?: Record<string, string>,\n ): Promise<Ticket> {\n return super.updateById(id, body, headers)\n }\n\n /** @deprecated Not served: `DELETE /tickets/{id}` answers 404 `Route not found.`. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<Ticket> {\n return super.deleteById(id, headers)\n }\n\n /**\n * Closes multiple tickets in a single request. This is the only ticket-close\n * endpoint exposed by the API — there is no per-ticket close/update route.\n *\n * Pass `{ ids }` to close specific tickets, or `{ allContactsSelected: true, query }`\n * to close every OPEN ticket matching `query` (the backend forces `isOpen: true`): an empty\n * `where` closes every open ticket of the account. The answer has no body. Ids of closed,\n * unknown or other accounts' tickets are skipped in silence; no id and no\n * `allContactsSelected` answers 400 `ids not found`.\n * @permissions tickets.close.all OR tickets.close.me\n */\n closeMany(payload: CloseManyTicketsPayload, headers?: Record<string, string>): Promise<void> {\n return this.client.put<void, CloseManyTicketsPayload>(\n `${this.basePath}/close-many`,\n payload,\n headers,\n )\n }\n\n /**\n * Counts the tickets matching the query. With `queries`, answers one count per query, in the\n * same order (the root filters are then ignored).\n */\n count(query: TicketsCountManyQuery, headers?: Record<string, string>): Promise<TicketsCounts>\n count(query?: TicketsListQuery, headers?: Record<string, string>): Promise<TicketsCount>\n count(\n query?: TicketsListQuery | TicketsCountManyQuery,\n headers?: Record<string, string>,\n ): Promise<TicketsCount | TicketsCounts> {\n return this.client.get<TicketsCount | TicketsCounts>(\n `${this.basePath}/count${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * POST variant of `count`, for queries too long for the URL. See {@link TicketsCountPostPayload}:\n * `query` is required.\n */\n countPost(\n body: TicketsCountPostPayload & { query: { queries: TicketsListQuery[] } },\n headers?: Record<string, string>,\n ): Promise<TicketsCounts>\n countPost(body: TicketsCountPostPayload, headers?: Record<string, string>): Promise<TicketsCount>\n countPost(\n body: TicketsCountPostPayload,\n headers?: Record<string, string>,\n ): Promise<TicketsCount | TicketsCounts> {\n return this.client.post<TicketsCount | TicketsCounts, TicketsCountPostPayload>(\n `${this.basePath}/count`,\n body,\n headers,\n )\n }\n\n /** Counts the open tickets of the contacts of a connection. An unknown id counts 0. */\n countOpenByService(serviceId: string, headers?: Record<string, string>): Promise<number> {\n return this.client.get<number>(`${this.basePath}/count-open/${serviceId}`, headers)\n }\n\n /** Counts the open tickets of a department. An unknown id counts 0. */\n countOpenByDepartment(departmentId: string, headers?: Record<string, string>): Promise<number> {\n return this.client.get<number>(\n `${this.basePath}/count-open-by-department/${departmentId}`,\n headers,\n )\n }\n\n /** Counts the open tickets assigned to a user. An unknown id counts 0. */\n countOpenByUser(userId: string, headers?: Record<string, string>): Promise<number> {\n return this.client.get<number>(`${this.basePath}/count-open-by-user/${userId}`, headers)\n }\n\n /**\n * The first waiting time of the ticket (`metrics.waitingTime`) as `HH:mm:ss`; `'00:00:00'` while\n * it was not measured. The hours wrap every 24 h (a wait of 25 h answers `'01:00:00'`): read\n * `metrics.waitingTime` (seconds) for the full value. An unknown id answers 500.\n */\n getFirstWaitingTime(id: string, headers?: Record<string, string>): Promise<string> {\n return this.client.get<string>(`${this.basePath}/${id}/first-waiting-time`, headers)\n }\n\n /**\n * Exports the conversation of a ticket as text, by its protocol (contact, attendants, subjects,\n * summary, dates and the messages without the internal comments), sent as the attachment\n * `<protocol>.txt` (Content-Type `plain/text`). Without a protocol the body is empty\n * (`undefined`); an unknown protocol never answers.\n */\n exportTxt(protocol: string, headers?: Record<string, string>): Promise<string> {\n return this.client.post<string, { protocol: string }>(\n `${this.basePath}/export`,\n { protocol },\n headers,\n )\n }\n\n /**\n * Exports the tickets matching the query as CSV (`;`, a header of 20 columns in the language of\n * the user, dates in the timezone of the account), streamed without a Content-Type.\n *\n * The query must include `contact` with its `service` (the History screen also includes\n * `contact.tags`, `contact.person`, `user`, `department`, `ticketTopics` and `firstMessage`),\n * and `order` must name unambiguous columns (e.g. `startedAt`): when a row fails after the header\n * is sent, the answer never ends. Leave `page` out: the route pages through every match itself\n * (`perPage` only sets the size of each batch), and a `page` in the query is read on every\n * batch, so its rows are repeated or the CSV comes with the header only.\n */\n exportHistory(query: TicketsListQuery, headers?: Record<string, string>): Promise<string> {\n return this.client.post<string>(\n `${this.basePath}/export-history${this.toQueryString(query)}`,\n undefined,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,IAAa,aAAb,cAAgC,YAA8D;CAC5F,YAAY,QAAmB;AAC7B,QAAM,QAAQ,WAAW;;;CAI3B,AAAS,OAAO,MAA2B,SAAmD;AAC5F,SAAO,MAAM,OAAO,MAAM,QAAQ;;;CAIpC,AAAS,WACP,IACA,MACA,SACiB;AACjB,SAAO,MAAM,WAAW,IAAI,MAAM,QAAQ;;;CAI5C,AAAS,WAAW,IAAY,SAAmD;AACjF,SAAO,MAAM,WAAW,IAAI,QAAQ;;;;;;;;;;;;;CActC,UAAU,SAAkC,SAAiD;AAC3F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,cACjB,SACA,QACD;;CASH,MACE,OACA,SACuC;AACvC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,QAAQ,KAAK,cAAc,MAAM,IAClD,QACD;;CAYH,UACE,MACA,SACuC;AACvC,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,SACjB,MACA,QACD;;;CAIH,mBAAmB,WAAmB,SAAmD;AACvF,SAAO,KAAK,OAAO,IAAY,GAAG,KAAK,SAAS,cAAc,aAAa,QAAQ;;;CAIrF,sBAAsB,cAAsB,SAAmD;AAC7F,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,4BAA4B,gBAC7C,QACD;;;CAIH,gBAAgB,QAAgB,SAAmD;AACjF,SAAO,KAAK,OAAO,IAAY,GAAG,KAAK,SAAS,sBAAsB,UAAU,QAAQ;;;;;;;CAQ1F,oBAAoB,IAAY,SAAmD;AACjF,SAAO,KAAK,OAAO,IAAY,GAAG,KAAK,SAAS,GAAG,GAAG,sBAAsB,QAAQ;;;;;;;;CAStF,UAAU,UAAkB,SAAmD;AAC7E,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,UACjB,EAAE,UAAU,EACZ,QACD;;;;;;;;;;;;;CAcH,cAAc,OAAyB,SAAmD;AACxF,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,iBAAiB,KAAK,cAAc,MAAM,IAC3D,QACA,QACD"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { ListQuery } from '../../core/types';
|
|
2
|
+
import type { Account } from '../accounts/types';
|
|
1
3
|
import type { Contact } from '../contacts/types';
|
|
2
4
|
import type { Department } from '../departments/types';
|
|
3
5
|
import type { Message } from '../messages/types';
|
|
4
6
|
import type { Service } from '../services/types';
|
|
7
|
+
import type { TicketTopic } from '../ticketTopics/types';
|
|
5
8
|
import type { User } from '../users/types';
|
|
6
9
|
export type TicketOrigin = 'automatic' | 'manual' | 'widget';
|
|
7
10
|
export type TicketMetrics = {
|
|
@@ -20,6 +23,14 @@ export type TicketMetrics = {
|
|
|
20
23
|
/** Average waiting time per transfer. */
|
|
21
24
|
waitingTimeTransfersAvg?: number;
|
|
22
25
|
isActiveTicket?: boolean;
|
|
26
|
+
/** Longest waiting time in seconds, among the opening and the transfers. */
|
|
27
|
+
maxWaitingTime?: number;
|
|
28
|
+
/** Department where the longest wait happened. */
|
|
29
|
+
maxWaitingTimeDepartmentId?: string;
|
|
30
|
+
/** Name of that department when the wait was measured (the history export prefers the current name). */
|
|
31
|
+
maxWaitingTimeDepartmentName?: string;
|
|
32
|
+
maxWaitingTimeStartedAt?: string;
|
|
33
|
+
maxWaitingTimeEndedAt?: string;
|
|
23
34
|
};
|
|
24
35
|
export type TicketTransferAction = 'opened' | 'transferred' | 'closed';
|
|
25
36
|
/**
|
|
@@ -55,6 +66,16 @@ export type TicketTransfer = {
|
|
|
55
66
|
firstMessage?: Message | null;
|
|
56
67
|
lastMessage?: Message | null;
|
|
57
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* A ticket as `GET /tickets` and `GET /tickets/{id}` answer it. The relationships come only when
|
|
71
|
+
* asked in `include`, except `firstMessage` and `lastMessage`, which always come: `null` when not
|
|
72
|
+
* included (or when the ticket has no message).
|
|
73
|
+
*
|
|
74
|
+
* The `include` whitelist of the route takes `contact` (and `contact.avatar`, `.thumbAvatar`,
|
|
75
|
+
* `.lastMessage`, `.tags`, `.service`, `.person`), `department`, `user`, `account`, `ticketTopics`,
|
|
76
|
+
* `firstMessage` and `ticketTransfers` (with `fromUser`, `toUser`, `fromDepartment`,
|
|
77
|
+
* `toDepartment`, `byUser`); anything else is dropped in silence.
|
|
78
|
+
*/
|
|
58
79
|
export type Ticket = {
|
|
59
80
|
id: string;
|
|
60
81
|
isOpen: boolean;
|
|
@@ -64,13 +85,18 @@ export type Ticket = {
|
|
|
64
85
|
metrics: TicketMetrics;
|
|
65
86
|
startedAt: string | null;
|
|
66
87
|
endedAt: string | null;
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
/** Only in the `ticket.*` webhooks (the stored ticket): the routes of `/tickets` never send it. */
|
|
89
|
+
isDistributing?: boolean;
|
|
90
|
+
/** Only in the `ticket.*` webhooks (the stored ticket): the routes of `/tickets` never send it. */
|
|
91
|
+
distributingAt?: string | null;
|
|
92
|
+
/** Only in the `ticket.*` webhooks (the stored ticket): the routes of `/tickets` never send it. */
|
|
93
|
+
count?: number | null;
|
|
69
94
|
accountId: string;
|
|
70
95
|
departmentId: string;
|
|
71
96
|
contactId: string;
|
|
72
97
|
userId: string | null;
|
|
73
|
-
|
|
98
|
+
/** @deprecated Never comes: a ticket has no connection of its own. Read `contact.serviceId`. */
|
|
99
|
+
serviceId?: string | null;
|
|
74
100
|
firstMessageId: string | null;
|
|
75
101
|
lastMessageId: string | null;
|
|
76
102
|
currentTicketTransferId: string | null;
|
|
@@ -79,10 +105,17 @@ export type Ticket = {
|
|
|
79
105
|
contact?: Contact;
|
|
80
106
|
department?: Department;
|
|
81
107
|
user?: User | null;
|
|
108
|
+
account?: Account;
|
|
109
|
+
ticketTopics?: TicketTopic[];
|
|
110
|
+
firstMessage?: Message | null;
|
|
111
|
+
/** @deprecated Always `null`: `lastMessage` is out of the include whitelist. Include `contact.lastMessage`. */
|
|
112
|
+
lastMessage?: Message | null;
|
|
113
|
+
/** @deprecated Never comes: `service` is out of the include whitelist. Include `contact.service`. */
|
|
82
114
|
service?: Service | null;
|
|
83
115
|
ticketTransfers?: TicketTransfer[];
|
|
84
116
|
};
|
|
85
|
-
export type TicketRelationships = 'contact' | 'department' | 'user' | 'service' | 'ticketTransfers';
|
|
117
|
+
export type TicketRelationships = 'contact' | 'department' | 'user' | 'account' | 'ticketTopics' | 'firstMessage' | 'lastMessage' | 'service' | 'ticketTransfers';
|
|
118
|
+
/** @deprecated Not served: the backend has no `POST /tickets`. A ticket is opened by `ContactsApi.transferTicket`. */
|
|
86
119
|
export type CreateTicketPayload = {
|
|
87
120
|
contactId: string;
|
|
88
121
|
departmentId: string;
|
|
@@ -90,12 +123,20 @@ export type CreateTicketPayload = {
|
|
|
90
123
|
comments?: string;
|
|
91
124
|
origin?: TicketOrigin;
|
|
92
125
|
};
|
|
126
|
+
/** @deprecated Not served: the backend has no `PUT /tickets/{id}`. Transfer through `ContactsApi.transferTicket`, close through `TicketsApi.closeMany`. */
|
|
93
127
|
export type UpdateTicketPayload = {
|
|
94
128
|
departmentId?: string;
|
|
95
129
|
userId?: string | null;
|
|
96
130
|
comments?: string | null;
|
|
97
131
|
isOpen?: boolean;
|
|
98
132
|
};
|
|
133
|
+
/** What `closeMany` records on every ticket it closes. */
|
|
134
|
+
export type CloseTicketsData = {
|
|
135
|
+
/** Subjects of the closing (one id or a list). */
|
|
136
|
+
ticketTopicIds?: string[] | string;
|
|
137
|
+
/** Summary of the closing, stored in `comments`. */
|
|
138
|
+
comments?: string;
|
|
139
|
+
};
|
|
99
140
|
/**
|
|
100
141
|
* Body for `PUT /tickets/close-many`.
|
|
101
142
|
*
|
|
@@ -104,14 +145,34 @@ export type UpdateTicketPayload = {
|
|
|
104
145
|
* `query` field is a JSON-stringified list query (e.g. `JSON.stringify({ where: {} })`);
|
|
105
146
|
* the backend always forces `where.isOpen = true`.
|
|
106
147
|
*/
|
|
107
|
-
export type CloseManyTicketsPayload = {
|
|
148
|
+
export type CloseManyTicketsPayload = ({
|
|
108
149
|
ids: string[];
|
|
109
|
-
|
|
110
|
-
comments?: string;
|
|
111
|
-
} | {
|
|
150
|
+
} & CloseTicketsData) | ({
|
|
112
151
|
allContactsSelected: true;
|
|
113
152
|
query: {
|
|
114
153
|
query: string;
|
|
115
154
|
};
|
|
155
|
+
} & CloseTicketsData);
|
|
156
|
+
/** A list query of tickets, as `count` and `exportHistory` take it. */
|
|
157
|
+
export type TicketsListQuery = ListQuery<Ticket>;
|
|
158
|
+
/** `count` with `queries`: one count per query, in the same order. */
|
|
159
|
+
export type TicketsCountManyQuery = TicketsListQuery & {
|
|
160
|
+
queries: TicketsListQuery[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Body of `POST /tickets/count`. The filters go at the root, as in a list query, and `query` is
|
|
164
|
+
* required: without it the route answers 500. `query: {}` counts the root filters into
|
|
165
|
+
* `{ count }`; `query: { queries }` ignores them and answers `{ counts }`, one per query.
|
|
166
|
+
*/
|
|
167
|
+
export type TicketsCountPostPayload = TicketsListQuery & {
|
|
168
|
+
query: {
|
|
169
|
+
queries?: TicketsListQuery[];
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export type TicketsCount = {
|
|
173
|
+
count: number;
|
|
174
|
+
};
|
|
175
|
+
export type TicketsCounts = {
|
|
176
|
+
counts: number[];
|
|
116
177
|
};
|
|
117
178
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/tickets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MA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15
15
|
import type { User, UserRelationships } from '../apis/users';
|
|
16
16
|
export type WebhookEvent = 'message.created' | 'message.updated' | 'ticket.created' | 'ticket.updated' | 'service.created' | 'service.updated' | 'service.destroyed' | 'contact.created' | 'contact.updated' | 'contact.destroyed' | 'people.created' | 'people.updated' | 'people.destroyed' | 'organization.created' | 'organization.updated' | 'organization.destroyed' | 'user.created' | 'user.updated' | 'user.destroyed' | 'department.created' | 'department.updated' | 'department.destroyed' | 'ticketTopics.created' | 'ticketTopics.updated' | 'ticketTopics.destroyed' | 'role.created' | 'role.updated' | 'role.destroyed' | 'bot.created' | 'bot.updated' | 'bot.destroyed' | 'bot.command' | 'bot.enter-context' | 'bot.leave-context' | 'bot.api-signal' | 'quickReplies.created' | 'quickReplies.updated' | 'quickReplies.destroyed' | 'tag.created' | 'tag.updated' | 'tag.destroyed' | 'campaign.created' | 'campaign.updated' | 'campaign.destroyed' | 'pipeline.created' | 'pipeline.updated';
|
|
17
|
+
/**
|
|
18
|
+
* `data` of `ticket.created` and `ticket.updated`: the stored ticket (so `isDistributing`,
|
|
19
|
+
* `distributingAt` and `count` come, and `serviceId` does not) plus its stored contact, which the
|
|
20
|
+
* sender always attaches. Read the connection of the ticket in `contact.serviceId`.
|
|
21
|
+
*/
|
|
22
|
+
export type TicketWebhookData = Omit<Ticket, TicketRelationships> & {
|
|
23
|
+
contact: Omit<Contact, ContactRelationships>;
|
|
24
|
+
};
|
|
17
25
|
export type BotCommandData = {
|
|
18
26
|
id: string;
|
|
19
27
|
contactId: string;
|
|
@@ -24,8 +32,8 @@ export type BotCommandData = {
|
|
|
24
32
|
export interface WebhookEventPayloadMap {
|
|
25
33
|
'message.created': Omit<Message, MessageRelationships>;
|
|
26
34
|
'message.updated': Omit<Message, MessageRelationships>;
|
|
27
|
-
'ticket.created':
|
|
28
|
-
'ticket.updated':
|
|
35
|
+
'ticket.created': TicketWebhookData;
|
|
36
|
+
'ticket.updated': TicketWebhookData;
|
|
29
37
|
'service.created': Omit<Service, ServiceRelationships>;
|
|
30
38
|
'service.updated': Omit<Service, ServiceRelationships>;
|
|
31
39
|
'service.destroyed': Omit<Service, ServiceRelationships>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/incommingWebhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAI5D,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,oBAAoB,GACpB,oBAAoB,GACpB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,aAAa,GACb,eAAe,GACf,aAAa,GACb,mBAAmB,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,aAAa,GACb,aAAa,GACb,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,GAClB,kBAAkB,CAAA;AAItB,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAA;IACtD,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAA;IACtD,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/incommingWebhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE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CAAA;IAC1B,aAAa,EAAE,cAAc,CAAA;IAC7B,mBAAmB,EAAE,SAAS,CAAA;IAC9B,mBAAmB,EAAE,SAAS,CAAA;IAC9B,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,sBAAsB,EAAE,IAAI,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAA;IACjE,sBAAsB,EAAE,IAAI,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAA;IACjE,wBAAwB,EAAE,IAAI,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAA;IACnE,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAC1C,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAC1C,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAC5C,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAA;IACzD,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAA;IACzD,oBAAoB,EAAE,IAAI,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAA;IAC3D,kBAAkB,EAAE,cAAc,CAAA;IAClC,kBAAkB,EAAE,cAAc,CAAA;CACnC;AAID,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI;IAClE,KAAK,EAAE,CAAC,CAAA;IACR,IAAI,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import { CampaignsApi } from './CampaignsApi'
|
|
|
3
3
|
import type { ApiClient } from '../../core/ApiClient'
|
|
4
4
|
import type {
|
|
5
5
|
Campaign,
|
|
6
|
+
CampaignContactsPage,
|
|
7
|
+
CampaignTimelineEvent,
|
|
6
8
|
CreateCampaignPayload,
|
|
7
9
|
CampaignStats,
|
|
8
10
|
SetIntervalPayload,
|
|
@@ -43,11 +45,7 @@ const campaign: Campaign = {
|
|
|
43
45
|
totalContacts: null,
|
|
44
46
|
totalContactsImported: null,
|
|
45
47
|
totalValidContacts: null,
|
|
46
|
-
sentContacts: null,
|
|
47
|
-
viewedContacts: null,
|
|
48
|
-
contactCount: null,
|
|
49
48
|
mustOpenTicket: false,
|
|
50
|
-
marketingIntegration: false,
|
|
51
49
|
accountId: 'acc-1',
|
|
52
50
|
serviceId: 'svc-1',
|
|
53
51
|
defaultDepartmentId: null,
|
|
@@ -188,32 +186,44 @@ describe('CampaignsApi', () => {
|
|
|
188
186
|
|
|
189
187
|
describe('sendById', () => {
|
|
190
188
|
it('calls client.post with /campaigns/:id/send', async () => {
|
|
191
|
-
vi.mocked(client.post).mockResolvedValue(campaign)
|
|
189
|
+
vi.mocked(client.post).mockResolvedValue({ ...campaign, status: 'processing' })
|
|
192
190
|
const result = await api.sendById('cmp-1')
|
|
193
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/send')
|
|
194
|
-
expect(result).toEqual(campaign)
|
|
191
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/send', undefined, undefined)
|
|
192
|
+
expect(result).toEqual({ ...campaign, status: 'processing' })
|
|
195
193
|
})
|
|
196
194
|
})
|
|
197
195
|
|
|
198
|
-
// ── pauseById
|
|
196
|
+
// ── pauseById / resumeById / retryById ───────────────────────────
|
|
199
197
|
|
|
200
198
|
describe('pauseById', () => {
|
|
201
|
-
it('calls client.post with /campaigns/:id/pause', async () => {
|
|
202
|
-
vi.mocked(client.post).mockResolvedValue(
|
|
199
|
+
it('calls client.post with /campaigns/:id/pause and resolves the boolean', async () => {
|
|
200
|
+
vi.mocked(client.post).mockResolvedValue(true)
|
|
203
201
|
const result = await api.pauseById('cmp-1')
|
|
204
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/pause')
|
|
205
|
-
expect(result).
|
|
202
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/pause', undefined, undefined)
|
|
203
|
+
expect(result).toBe(true)
|
|
206
204
|
})
|
|
207
205
|
})
|
|
208
206
|
|
|
209
|
-
// ── resumeById ───────────────────────────────────────────────────
|
|
210
|
-
|
|
211
207
|
describe('resumeById', () => {
|
|
212
|
-
it('calls client.post with /campaigns/:id/resume', async () => {
|
|
213
|
-
vi.mocked(client.post).mockResolvedValue(
|
|
208
|
+
it('calls client.post with /campaigns/:id/resume and resolves the boolean', async () => {
|
|
209
|
+
vi.mocked(client.post).mockResolvedValue(true)
|
|
214
210
|
const result = await api.resumeById('cmp-1')
|
|
215
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/resume')
|
|
216
|
-
expect(result).
|
|
211
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/resume', undefined, undefined)
|
|
212
|
+
expect(result).toBe(true)
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
describe('retryById', () => {
|
|
217
|
+
it('calls client.post with /campaigns/:id/retry', async () => {
|
|
218
|
+
vi.mocked(client.post).mockResolvedValue('OK')
|
|
219
|
+
const result = await api.retryById('cmp-1')
|
|
220
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/retry', undefined, undefined)
|
|
221
|
+
expect(result).toBe('OK')
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('resolves false for an unknown campaign', async () => {
|
|
225
|
+
vi.mocked(client.post).mockResolvedValue(false)
|
|
226
|
+
await expect(api.retryById('unknown')).resolves.toBe(false)
|
|
217
227
|
})
|
|
218
228
|
})
|
|
219
229
|
|
|
@@ -223,7 +233,7 @@ describe('CampaignsApi', () => {
|
|
|
223
233
|
it('calls client.post with /campaigns/:id/duplicate', async () => {
|
|
224
234
|
vi.mocked(client.post).mockResolvedValue(campaign)
|
|
225
235
|
const result = await api.duplicateById('cmp-1')
|
|
226
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/duplicate')
|
|
236
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/duplicate', undefined, undefined)
|
|
227
237
|
expect(result).toEqual(campaign)
|
|
228
238
|
})
|
|
229
239
|
})
|
|
@@ -233,6 +243,16 @@ describe('CampaignsApi', () => {
|
|
|
233
243
|
describe('getStatsById', () => {
|
|
234
244
|
it('calls client.get with /campaigns/:id/stats', async () => {
|
|
235
245
|
const stats: CampaignStats = {
|
|
246
|
+
total: 100,
|
|
247
|
+
sent: 100,
|
|
248
|
+
failed: 10,
|
|
249
|
+
sending: 0,
|
|
250
|
+
sentToServer: 5,
|
|
251
|
+
received: 85,
|
|
252
|
+
viewed: 70,
|
|
253
|
+
played: 0,
|
|
254
|
+
answered: 30,
|
|
255
|
+
sentAndNotReceived: 5,
|
|
236
256
|
campaignInfo: {
|
|
237
257
|
totalValidContacts: 100,
|
|
238
258
|
totalContacts: 110,
|
|
@@ -240,74 +260,184 @@ describe('CampaignsApi', () => {
|
|
|
240
260
|
firedSuccessCount: 90,
|
|
241
261
|
firedFailedCount: 10,
|
|
242
262
|
totalMessagesCount: 100,
|
|
263
|
+
sentMessagesCount: 100,
|
|
243
264
|
totalFiredCount: 100,
|
|
244
265
|
firedBlockedByMessageRuleCount: 0,
|
|
245
266
|
},
|
|
246
|
-
messageInfo: {
|
|
267
|
+
messageInfo: {
|
|
268
|
+
error: 5,
|
|
269
|
+
sending: 0,
|
|
270
|
+
sentToServer: 5,
|
|
271
|
+
received: 85,
|
|
272
|
+
viewed: 70,
|
|
273
|
+
played: 0,
|
|
274
|
+
answered: 30,
|
|
275
|
+
},
|
|
247
276
|
}
|
|
248
277
|
vi.mocked(client.get).mockResolvedValue(stats)
|
|
249
278
|
const result = await api.getStatsById('cmp-1')
|
|
250
|
-
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/stats')
|
|
279
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/stats', undefined)
|
|
251
280
|
expect(result).toEqual(stats)
|
|
252
281
|
})
|
|
253
282
|
})
|
|
254
283
|
|
|
284
|
+
// ── getTimeline ──────────────────────────────────────────────────
|
|
285
|
+
|
|
286
|
+
describe('getTimeline', () => {
|
|
287
|
+
it('calls client.get with /campaigns/:id/timeline', async () => {
|
|
288
|
+
const events: CampaignTimelineEvent[] = [
|
|
289
|
+
{
|
|
290
|
+
id: 'finished',
|
|
291
|
+
type: 'finished',
|
|
292
|
+
timestamp: '2026-10-14T15:02:40.770Z',
|
|
293
|
+
actor: 'Sistema',
|
|
294
|
+
triggerType: 'automatic',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: 'created',
|
|
298
|
+
type: 'created',
|
|
299
|
+
timestamp: '2026-10-14T15:02:33.795Z',
|
|
300
|
+
actor: 'Ana',
|
|
301
|
+
triggerType: 'manual',
|
|
302
|
+
},
|
|
303
|
+
]
|
|
304
|
+
vi.mocked(client.get).mockResolvedValue(events)
|
|
305
|
+
const result = await api.getTimeline('cmp-1')
|
|
306
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/timeline', undefined)
|
|
307
|
+
expect(result).toEqual(events)
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
// ── getContacts ──────────────────────────────────────────────────
|
|
312
|
+
|
|
313
|
+
describe('getContacts', () => {
|
|
314
|
+
const page: CampaignContactsPage = {
|
|
315
|
+
data: [],
|
|
316
|
+
total: 0,
|
|
317
|
+
limit: 15,
|
|
318
|
+
skip: 0,
|
|
319
|
+
currentPage: 1,
|
|
320
|
+
lastPage: 1,
|
|
321
|
+
from: 0,
|
|
322
|
+
to: 0,
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
it('calls client.get with /campaigns/:id/contacts when no query is provided', async () => {
|
|
326
|
+
vi.mocked(client.get).mockResolvedValue(page)
|
|
327
|
+
const result = await api.getContacts('cmp-1')
|
|
328
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/contacts', undefined)
|
|
329
|
+
expect(result).toEqual(page)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('serializes the query', async () => {
|
|
333
|
+
vi.mocked(client.get).mockResolvedValue(page)
|
|
334
|
+
await api.getContacts('cmp-1', { page: 2, contactStatus: ['not_sent'], sortBy: 'sentAt' })
|
|
335
|
+
const url = vi.mocked(client.get).mock.calls[0]?.[0] as string
|
|
336
|
+
expect(url.startsWith('/campaigns/cmp-1/contacts?')).toBe(true)
|
|
337
|
+
expect(decodeURIComponent(url)).toContain('"contactStatus":["not_sent"]')
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
|
|
255
341
|
// ── setIntervalById ──────────────────────────────────────────────
|
|
256
342
|
|
|
257
343
|
describe('setIntervalById', () => {
|
|
258
344
|
it('calls client.post with /campaigns/:id/interval and body', async () => {
|
|
259
|
-
vi.mocked(client.post).mockResolvedValue(
|
|
260
|
-
const data: SetIntervalPayload = { minInterval:
|
|
345
|
+
vi.mocked(client.post).mockResolvedValue(true)
|
|
346
|
+
const data: SetIntervalPayload = { minInterval: 5, maxInterval: 10 }
|
|
261
347
|
const result = await api.setIntervalById('cmp-1', data)
|
|
262
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/interval', data)
|
|
263
|
-
expect(result).
|
|
348
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/cmp-1/interval', data, undefined)
|
|
349
|
+
expect(result).toBe(true)
|
|
264
350
|
})
|
|
265
351
|
})
|
|
266
352
|
|
|
267
|
-
// ── getContactCount
|
|
353
|
+
// ── getContactCount / countReadyByService ────────────────────────
|
|
268
354
|
|
|
269
355
|
describe('getContactCount', () => {
|
|
270
356
|
it('calls client.get with /campaigns/:id/contactCount', async () => {
|
|
271
357
|
vi.mocked(client.get).mockResolvedValue(42)
|
|
272
358
|
const result = await api.getContactCount('cmp-1')
|
|
273
|
-
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/contactCount')
|
|
359
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/contactCount', undefined)
|
|
274
360
|
expect(result).toBe(42)
|
|
275
361
|
})
|
|
276
362
|
})
|
|
277
363
|
|
|
364
|
+
describe('countReadyByService', () => {
|
|
365
|
+
it('calls client.get with /campaigns/count-ready/:serviceId', async () => {
|
|
366
|
+
vi.mocked(client.get).mockResolvedValue(4)
|
|
367
|
+
const result = await api.countReadyByService('svc-1')
|
|
368
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/count-ready/svc-1', undefined)
|
|
369
|
+
expect(result).toBe(4)
|
|
370
|
+
})
|
|
371
|
+
})
|
|
372
|
+
|
|
278
373
|
// ── setAutoPauseMode ─────────────────────────────────────────────
|
|
279
374
|
|
|
280
375
|
describe('setAutoPauseMode', () => {
|
|
281
376
|
it('calls client.put with /campaigns/autoPauseMode and body', async () => {
|
|
282
|
-
vi.mocked(client.put).mockResolvedValue(
|
|
283
|
-
const data: AutoPauseModePayload = { mode: '
|
|
377
|
+
vi.mocked(client.put).mockResolvedValue('OK')
|
|
378
|
+
const data: AutoPauseModePayload = { mode: 'medium-health' }
|
|
284
379
|
const result = await api.setAutoPauseMode(data)
|
|
285
|
-
expect(client.put).toHaveBeenCalledWith('/campaigns/autoPauseMode', data)
|
|
286
|
-
expect(result).
|
|
380
|
+
expect(client.put).toHaveBeenCalledWith('/campaigns/autoPauseMode', data, undefined)
|
|
381
|
+
expect(result).toBe('OK')
|
|
287
382
|
})
|
|
288
383
|
})
|
|
289
384
|
|
|
290
|
-
// ──
|
|
385
|
+
// ── exports ──────────────────────────────────────────────────────
|
|
291
386
|
|
|
292
387
|
describe('exportCampaignResult', () => {
|
|
293
|
-
it('calls client.post with /campaigns/export/csv and
|
|
294
|
-
vi.mocked(client.post).mockResolvedValue(
|
|
295
|
-
const data: ExportCampaignResultPayload = {
|
|
388
|
+
it('calls client.post with /campaigns/export/csv and the where of the campaign', async () => {
|
|
389
|
+
vi.mocked(client.post).mockResolvedValue('Nome do contato;Número do contato\n')
|
|
390
|
+
const data: ExportCampaignResultPayload = {
|
|
391
|
+
where: { campaignId: 'cmp-1' },
|
|
392
|
+
type: 'semiColon',
|
|
393
|
+
}
|
|
296
394
|
const result = await api.exportCampaignResult(data)
|
|
297
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/export/csv', data)
|
|
298
|
-
expect(result).
|
|
395
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/export/csv', data, undefined)
|
|
396
|
+
expect(result).toBe('Nome do contato;Número do contato\n')
|
|
299
397
|
})
|
|
300
398
|
})
|
|
301
399
|
|
|
302
|
-
// ── exportTemplateCsv ────────────────────────────────────────────
|
|
303
|
-
|
|
304
400
|
describe('exportTemplateCsv', () => {
|
|
305
401
|
it('calls client.post with /campaigns/exportTemplate and body', async () => {
|
|
306
|
-
vi.mocked(client.post).mockResolvedValue(
|
|
402
|
+
vi.mocked(client.post).mockResolvedValue('Nome;Telefone;Username\n')
|
|
307
403
|
const data: ExportTemplateCsvPayload = { hsmId: 'hsm-1' }
|
|
308
404
|
const result = await api.exportTemplateCsv(data)
|
|
309
|
-
expect(client.post).toHaveBeenCalledWith('/campaigns/exportTemplate', data)
|
|
310
|
-
expect(result).
|
|
405
|
+
expect(client.post).toHaveBeenCalledWith('/campaigns/exportTemplate', data, undefined)
|
|
406
|
+
expect(result).toBe('Nome;Telefone;Username\n')
|
|
407
|
+
})
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
describe('exportImportErrors', () => {
|
|
411
|
+
it('calls client.get with /campaigns/:id/import-errors', async () => {
|
|
412
|
+
vi.mocked(client.get).mockResolvedValue('Linha,Nome,Número,Username,Motivo\n')
|
|
413
|
+
const result = await api.exportImportErrors('cmp-1')
|
|
414
|
+
expect(client.get).toHaveBeenCalledWith('/campaigns/cmp-1/import-errors', undefined)
|
|
415
|
+
expect(result).toBe('Linha,Nome,Número,Username,Motivo\n')
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
it('sends the delimiter in the query string', async () => {
|
|
419
|
+
vi.mocked(client.get).mockResolvedValue('Linha;Nome;Número;Username;Motivo\n')
|
|
420
|
+
await api.exportImportErrors('cmp-1', { delimiter: ';' })
|
|
421
|
+
expect(client.get).toHaveBeenCalledWith(
|
|
422
|
+
'/campaigns/cmp-1/import-errors?delimiter=%3B',
|
|
423
|
+
undefined,
|
|
424
|
+
)
|
|
425
|
+
})
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
// ── deleteMany ───────────────────────────────────────────────────
|
|
429
|
+
|
|
430
|
+
describe('deleteMany', () => {
|
|
431
|
+
it('calls client.request with DELETE /campaigns/delete-many and the ids', async () => {
|
|
432
|
+
vi.mocked(client.request).mockResolvedValue(true)
|
|
433
|
+
const result = await api.deleteMany(['cmp-1', 'cmp-2'])
|
|
434
|
+
expect(client.request).toHaveBeenCalledWith(
|
|
435
|
+
'DELETE',
|
|
436
|
+
'/campaigns/delete-many',
|
|
437
|
+
{ ids: ['cmp-1', 'cmp-2'] },
|
|
438
|
+
undefined,
|
|
439
|
+
)
|
|
440
|
+
expect(result).toBe(true)
|
|
311
441
|
})
|
|
312
442
|
})
|
|
313
443
|
|
|
@@ -315,10 +445,13 @@ describe('CampaignsApi', () => {
|
|
|
315
445
|
|
|
316
446
|
describe('getHsmLimit', () => {
|
|
317
447
|
it('calls client.get with /whatsapp-business-templates/:accountId/hsmLimit', async () => {
|
|
318
|
-
const limit: HsmLimit = { hsmLimit: 1000, hsmUsedLimit: 150 }
|
|
448
|
+
const limit: HsmLimit = { hsmLimit: 1000, hsmUsedLimit: 150, hasLimit: 850 }
|
|
319
449
|
vi.mocked(client.get).mockResolvedValue(limit)
|
|
320
450
|
const result = await api.getHsmLimit('acc-1')
|
|
321
|
-
expect(client.get).toHaveBeenCalledWith(
|
|
451
|
+
expect(client.get).toHaveBeenCalledWith(
|
|
452
|
+
'/whatsapp-business-templates/acc-1/hsmLimit',
|
|
453
|
+
undefined,
|
|
454
|
+
)
|
|
322
455
|
expect(result).toEqual(limit)
|
|
323
456
|
})
|
|
324
457
|
})
|