@webitel/api-services 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/package.json +1 -1
  2. package/src/api/clients/__tests__/wireParamsCoverage.spec.ts +286 -0
  3. package/src/api/clients/activeCalls/activeCalls.ts +72 -0
  4. package/src/api/clients/agentPauseCauses/agentPauseCauses.ts +182 -0
  5. package/src/api/clients/agentSkills/agentSkills.ts +193 -0
  6. package/src/api/clients/agents/__tests__/agents.wireParams.spec.ts +51 -0
  7. package/src/api/clients/agents/agents.ts +203 -18
  8. package/src/api/clients/auditForms/auditForms.ts +6 -2
  9. package/src/api/clients/auditForms/auditRates.ts +91 -0
  10. package/src/api/clients/backendProfiles/backendProfiles.ts +194 -0
  11. package/src/api/clients/buckets/buckets.ts +21 -25
  12. package/src/api/clients/callHistory/callAnnotations.ts +91 -0
  13. package/src/api/clients/callHistory/callHistory.ts +76 -7
  14. package/src/api/clients/casePriorities/__tests__/casePriorities.spec.ts +50 -0
  15. package/src/api/clients/casePriorities/casePriorities.ts +25 -41
  16. package/src/api/clients/caseStatusConditions/caseStatusConditions.ts +19 -29
  17. package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
  18. package/src/api/clients/catalog/catalog.ts +2 -8
  19. package/src/api/clients/changelogs/changelogs.ts +8 -0
  20. package/src/api/clients/chatplans/chatplans.ts +173 -0
  21. package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
  22. package/src/api/clients/communications/communications.ts +38 -42
  23. package/src/api/clients/dialplans/dialplans.ts +197 -0
  24. package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
  25. package/src/api/clients/fileServices/fileServices.ts +7 -2
  26. package/src/api/clients/flows/flow.ts +54 -43
  27. package/src/api/clients/fts/fts.ts +61 -0
  28. package/src/api/clients/history/transcript/callTranscript.ts +10 -20
  29. package/src/api/clients/importTemplates/importTemplates.ts +180 -0
  30. package/src/api/clients/index.ts +30 -0
  31. package/src/api/clients/lists/blacklistNumbers.ts +155 -0
  32. package/src/api/clients/lists/blacklists.ts +20 -25
  33. package/src/api/clients/logs/logs.ts +157 -0
  34. package/src/api/clients/media/media.ts +19 -15
  35. package/src/api/clients/object/object.ts +3 -14
  36. package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
  37. package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
  38. package/src/api/clients/outboundResources/outboundResources.ts +225 -0
  39. package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
  40. package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
  41. package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
  42. package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
  43. package/src/api/clients/queues/queueLogs.ts +8 -3
  44. package/src/api/clients/queues/queueMembers.ts +3 -3
  45. package/src/api/clients/queues/queues.ts +52 -0
  46. package/src/api/clients/regions/regions.ts +21 -25
  47. package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
  48. package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
  49. package/src/api/clients/skills/skillAgents.ts +190 -0
  50. package/src/api/clients/skills/skills.ts +21 -25
  51. package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
  52. package/src/api/clients/teamHooks/teamHooks.ts +195 -0
  53. package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
  54. package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
  55. package/src/api/clients/teams/teams.ts +31 -31
  56. package/src/api/clients/triggers/triggerJobs.ts +63 -0
  57. package/src/api/clients/triggers/triggers.ts +266 -0
  58. package/src/api/clients/userSettings/userSettings.ts +8 -9
  59. package/src/api/clients/users/users.ts +2 -0
  60. package/src/api/clients/workingConditions/workingConditions.ts +184 -0
  61. package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
  62. package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
  63. package/types/.tsbuildinfo +1 -1
  64. package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
  65. package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
  66. package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
  67. package/types/api/clients/agents/agents.d.ts +23 -2
  68. package/types/api/clients/auditForms/auditForms.d.ts +7 -0
  69. package/types/api/clients/auditForms/auditRates.d.ts +10 -0
  70. package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
  71. package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
  72. package/types/api/clients/callHistory/callHistory.d.ts +24 -3
  73. package/types/api/clients/chatplans/chatplans.d.ts +21 -0
  74. package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
  75. package/types/api/clients/dialplans/dialplans.d.ts +16 -0
  76. package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
  77. package/types/api/clients/fileServices/fileServices.d.ts +1 -1
  78. package/types/api/clients/fts/fts.d.ts +7 -0
  79. package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
  80. package/types/api/clients/index.d.ts +30 -0
  81. package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
  82. package/types/api/clients/logs/logs.d.ts +15 -0
  83. package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
  84. package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
  85. package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
  86. package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
  87. package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
  88. package/types/api/clients/queues/queues.d.ts +5 -0
  89. package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
  90. package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
  91. package/types/api/clients/skills/skillAgents.d.ts +13 -0
  92. package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
  93. package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
  94. package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
  95. package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
  96. package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
  97. package/types/api/clients/triggers/triggers.d.ts +22 -0
  98. package/types/api/clients/userSettings/userSettings.d.ts +2 -2
  99. package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
  100. package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,286 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ /**
4
+ * Checks that every client sends query parameters the API actually accepts.
5
+ *
6
+ * ## What it does
7
+ *
8
+ * For each `*API` the barrel exports, it calls every read method (`getList`,
9
+ * `get`, `getLookup`, `getFlowTags`, and so on) with a typical caller payload,
10
+ * intercepts the call to the generated `gen-wire` service, and validates the
11
+ * parameters object against that endpoint's generated zod schema. A test fails
12
+ * if a client sends a key the endpoint does not declare, or sends a declared
13
+ * key with the wrong type.
14
+ *
15
+ * ## Why it is needed
16
+ *
17
+ * These clients used to call the old `webitel-sdk` factories with positional
18
+ * arguments — `searchAgentTeam(page, size, search, sort)`. The names of the
19
+ * local variables never reached the request; the factory decided the parameter
20
+ * names from the argument order. Passing an object instead makes the keys
21
+ * *become* the parameter names, so their spelling suddenly matters, and a
22
+ * mistake is invisible: the backend ignores a parameter it does not recognise,
23
+ * so the filter just silently stops working. No error, no failing request.
24
+ *
25
+ * TypeScript only catches this when the object is written inline, and several
26
+ * clients build it as a variable first, or cast it to get dotted protobuf keys
27
+ * like `joined_at.from` past the excess-property check — which switches the
28
+ * check off for every other key too. That is exactly how six queue filters
29
+ * (`queueId`, `agentId`, `bucketId` and friends) shipped doing nothing.
30
+ *
31
+ * Sweeping rather than listing clients by hand matters for two reasons: a
32
+ * client added later is covered without anyone remembering to write a test,
33
+ * and the expectation comes from the generated schema instead of from whoever
34
+ * writes the test. The older hand-written `queueLogs.spec.ts` shows why that
35
+ * second point counts — it pinned the wrong parameter names, so it described
36
+ * the bug instead of catching it.
37
+ *
38
+ * ## Notes
39
+ *
40
+ * `.strict()` is load-bearing. A plain `safeParse` silently *strips* unknown
41
+ * keys and reports success, so it would wave the exact bug straight through.
42
+ *
43
+ * Write methods are left out on purpose. They send a body, and the generated
44
+ * `*Body` schemas are incomplete — several omit the field that defines the
45
+ * record (`properties` on cognitive profiles, `value` on schema variables,
46
+ * `schema` on flows) — so checking a body against one would fail on correct
47
+ * code. Per-client field-set checks cover writes instead.
48
+ *
49
+ * Specific parameter *mappings* — that a caller's `team` must arrive as
50
+ * `team_id` — live in the per-client specs next to each client, because this
51
+ * sweep only proves that whatever was sent is declared, not that nothing was
52
+ * dropped on the way.
53
+ *
54
+ * NOTE: this spec was written by Claude (AI), not by a human.
55
+ */
56
+ const captured: {
57
+ method: string;
58
+ args: unknown[];
59
+ }[] = [];
60
+
61
+ vi.mock('../../../gen-wire', async (importOriginal) => {
62
+ const actual = await importOriginal<Record<string, unknown>>();
63
+
64
+ const recorder = new Proxy(
65
+ {},
66
+ {
67
+ get:
68
+ (_target, method: string) =>
69
+ (...args: unknown[]) => {
70
+ captured.push({
71
+ method,
72
+ args,
73
+ });
74
+ return Promise.resolve({
75
+ data: {},
76
+ });
77
+ },
78
+ },
79
+ );
80
+
81
+ const mocked: Record<string, unknown> = {
82
+ ...actual,
83
+ };
84
+ for (const key of Object.keys(actual)) {
85
+ if (typeof actual[key] === 'function' && /^get[A-Z]/.test(key)) {
86
+ mocked[key] = () => recorder;
87
+ }
88
+ }
89
+ return mocked;
90
+ });
91
+
92
+ const clients = await import('../index');
93
+ const gw = await import('../../../gen-wire');
94
+
95
+ /** What a datalist store sends to a list: camelCase keys and a `search` term. */
96
+ const listPayload = {
97
+ page: 2,
98
+ size: 25,
99
+ search: 'acme',
100
+ sort: '+name',
101
+ fields: [
102
+ 'id',
103
+ 'name',
104
+ ],
105
+ // required by the nested clients, ignored by the flat ones
106
+ parentId: '1',
107
+ };
108
+
109
+ /** What a card sends to a single read. */
110
+ const itemPayload = {
111
+ itemId: '2',
112
+ parentId: '1',
113
+ };
114
+
115
+ /**
116
+ * `get` is the only single-item read in the shared shape; everything else
117
+ * matched by `isRead` takes list params.
118
+ */
119
+ const payloadFor = (method: string) =>
120
+ method === 'get' ? itemPayload : listPayload;
121
+
122
+ /*
123
+ * Enumerated up front: reaching for a missing export on a mocked module throws
124
+ * rather than yielding `undefined`, and plenty of reads take only a path id, so
125
+ * their `*QueryParams` schema legitimately does not exist.
126
+ */
127
+ const gwExports = new Set(Object.keys(gw));
128
+
129
+ const schemaFor = (method: string) => {
130
+ const name = `${method[0].toUpperCase()}${method.slice(1)}QueryParams`;
131
+ if (!gwExports.has(name)) return undefined;
132
+ const schema = (gw as Record<string, unknown>)[name];
133
+ return schema && typeof schema === 'object' && 'strict' in schema
134
+ ? (schema as {
135
+ strict: () => {
136
+ safeParse: (v: unknown) => {
137
+ success: boolean;
138
+ error?: {
139
+ issues: {
140
+ code: string;
141
+ keys?: string[];
142
+ }[];
143
+ };
144
+ };
145
+ };
146
+ })
147
+ : undefined;
148
+ };
149
+
150
+ type ApiObject = Record<string, unknown>;
151
+
152
+ /**
153
+ * Reads by naming convention. Writes are skipped on purpose: they pass a body,
154
+ * and the generated `*Body` schemas are incomplete — several omit the field
155
+ * that defines the record (`properties` on cognitive profiles, `value` on
156
+ * schema variables, `schema` on flows), so checking a body against one would
157
+ * fail on correct code.
158
+ */
159
+ const isRead = (method: string) => /^(get|search|list|find)/.test(method);
160
+
161
+ /**
162
+ * `CallHistoryAPI` is a deliberate thin passthrough: `getList` forwards the
163
+ * caller's object to the generated method untouched, so callers hand it wire
164
+ * params directly (see `HistoryAPIRepository` in cc-workspaces, its only
165
+ * caller). Feeding it the datalist store's shape would only prove that the
166
+ * store's shape is not the wire's.
167
+ */
168
+ const passthrough = new Set([
169
+ 'CallHistoryAPI',
170
+ ]);
171
+
172
+ /**
173
+ * Supplied by this sweep so nested clients have a parent to hang off; a client
174
+ * consumes it rather than forwarding it, so it is not a wire key.
175
+ */
176
+ const suppliedByTest = new Set([
177
+ 'parentId',
178
+ 'parent_id',
179
+ 'itemId',
180
+ 'item_id',
181
+ ]);
182
+
183
+ /**
184
+ * These endpoints declare `sort` as repeated (`string[]`), and the datalist
185
+ * store sends the single string every other endpoint takes. `contacts.ts`
186
+ * already wraps it — `sort: searchParams.sort ? [searchParams.sort] : ['+name']`
187
+ * — so the shape does matter somewhere; whether the gateway coerces a bare
188
+ * string for the rest is unconfirmed against a live backend.
189
+ *
190
+ * Listed rather than filtered out, so the set shrinks as clients are fixed and
191
+ * nothing new hides behind it.
192
+ */
193
+ /**
194
+ * `MessagesServiceAPI.getChatHistory` merges `getDefaultGetParams()`, so it
195
+ * sends `page` and `size` to `catalogGetHistory` — an endpoint that paginates
196
+ * with `limit` and an `offset.id` cursor and declares neither. Its `search` and
197
+ * `sort` are undeclared too; the endpoint takes `q`.
198
+ *
199
+ * Left alone rather than guessed at: swapping page/size for limit changes how
200
+ * chat history pages, which wants someone who knows that UI. Recorded here so
201
+ * the sweep stays green without the finding going quiet.
202
+ */
203
+ const knownPaginationShape = new Set([
204
+ 'catalogGetHistory',
205
+ ]);
206
+
207
+ const knownSortShape = new Set([
208
+ 'catalogGetDialogs',
209
+ 'listConditions',
210
+ 'listDynamicGroups',
211
+ 'listEmails',
212
+ 'listGroups',
213
+ 'listIMClients',
214
+ 'listPhones',
215
+ 'listVariables',
216
+ 'searchData',
217
+ 'searchOAuthService',
218
+ 'searchType',
219
+ 'searchTypes',
220
+ ]);
221
+
222
+ const readMethods = Object.entries(clients)
223
+ .filter(([name, api]) => /API$/.test(name) && !passthrough.has(name) && api)
224
+ .flatMap(([name, api]) =>
225
+ Object.entries(api as ApiObject)
226
+ .filter(([method, fn]) => typeof fn === 'function' && isRead(method))
227
+ .map(
228
+ ([method, fn]) =>
229
+ [
230
+ `${name}.${method}`,
231
+ fn as (params: unknown) => Promise<unknown>,
232
+ ] as const,
233
+ ),
234
+ );
235
+
236
+ describe('every client read sends declared wire params', () => {
237
+ it('found read methods to sweep', () => {
238
+ expect(readMethods.length).toBeGreaterThan(120);
239
+ });
240
+
241
+ it.each(readMethods)('%s', async (name, call) => {
242
+ // validated in full: unknown keys *and* value types
243
+ captured.length = 0;
244
+
245
+ try {
246
+ await call(payloadFor(name.split('.')[1]));
247
+ } catch {
248
+ // a client may reject on the empty mock response; the params it
249
+ // already sent are still what we came to inspect
250
+ }
251
+
252
+ const unknownKeys = captured.flatMap(({ method, args }) => {
253
+ const schema = schemaFor(method);
254
+ if (!schema) return [];
255
+
256
+ const params = args.find(
257
+ (arg) => arg && typeof arg === 'object' && !Array.isArray(arg),
258
+ );
259
+ if (!params) return [];
260
+
261
+ const result = schema.strict().safeParse(params);
262
+ return result.success
263
+ ? []
264
+ : (result.error?.issues ?? []).flatMap((issue) => {
265
+ if (issue.code === 'unrecognized_keys') {
266
+ if (knownPaginationShape.has(method)) return [];
267
+ return (issue.keys ?? [])
268
+ .filter((key) => !suppliedByTest.has(key))
269
+ .map((key) => `${method}.${key}`);
270
+ }
271
+ const path =
272
+ (
273
+ issue as {
274
+ path?: unknown[];
275
+ }
276
+ ).path ?? [];
277
+ if (path[0] === 'sort' && knownSortShape.has(method)) return [];
278
+ return [
279
+ `${method}: ${issue.code} at ${path.join('.') || '(root)'}`,
280
+ ];
281
+ });
282
+ });
283
+
284
+ expect(unknownKeys).toEqual([]);
285
+ });
286
+ });
@@ -0,0 +1,72 @@
1
+ import { getCallService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ merge,
6
+ notify,
7
+ snakeToCamel,
8
+ starToSearch,
9
+ } from '../../transformers';
10
+ import type { ApiParams } from '../_shared/types';
11
+
12
+ /**
13
+ * Calls currently in progress. Durations and timestamps come back raw;
14
+ * formatting them is the caller's job.
15
+ */
16
+ const getActiveCallsList = async (params: ApiParams) => {
17
+ const {
18
+ page,
19
+ size,
20
+ search,
21
+ sort,
22
+ fields,
23
+ user,
24
+ agent,
25
+ queue,
26
+ team,
27
+ gateway,
28
+ supervisor,
29
+ direction,
30
+ result,
31
+ skipParent,
32
+ } = applyTransform(params, [
33
+ merge(getDefaultGetParams()),
34
+ starToSearch('search'),
35
+ ]);
36
+
37
+ try {
38
+ const response = await getCallService().searchActiveCall({
39
+ page,
40
+ size,
41
+ // the generated param is `q`; `search` is what the datalist store sends
42
+ q: search,
43
+ sort,
44
+ fields,
45
+ user_id: user,
46
+ agent_id: agent,
47
+ queue_id: queue,
48
+ team_id: team,
49
+ gateway_id: gateway,
50
+ supervisor_id: supervisor,
51
+ direction,
52
+ state: result,
53
+ skip_parent: skipParent,
54
+ });
55
+ const { items, next } = applyTransform(response.data, [
56
+ snakeToCamel(),
57
+ merge(getDefaultGetListResponse()),
58
+ ]);
59
+ return {
60
+ items,
61
+ next,
62
+ };
63
+ } catch (err) {
64
+ throw applyTransform(err, [
65
+ notify,
66
+ ]);
67
+ }
68
+ };
69
+
70
+ export const ActiveCallsAPI = {
71
+ getList: getActiveCallsList,
72
+ };
@@ -0,0 +1,182 @@
1
+ import { getAgentPauseCauseService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ mergeEach,
8
+ notify,
9
+ sanitize,
10
+ snakeToCamel,
11
+ starToSearch,
12
+ } from '../../transformers';
13
+ import type {
14
+ AddItemParams,
15
+ ApiParams,
16
+ DeleteItemParams,
17
+ GetItemParams,
18
+ PatchItemParams,
19
+ UpdateItemParams,
20
+ } from '../_shared/types';
21
+
22
+ const defaultObject = {
23
+ name: '',
24
+ limitMin: 0,
25
+ allowAdmin: false,
26
+ allowSupervisor: false,
27
+ allowAgent: false,
28
+ };
29
+
30
+ const fieldsToSend = [
31
+ 'name',
32
+ 'limitMin',
33
+ 'allowAdmin',
34
+ 'allowSupervisor',
35
+ 'allowAgent',
36
+ 'description',
37
+ ];
38
+
39
+ const getAgentPauseCausesList = async (params: ApiParams) => {
40
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
41
+ merge(getDefaultGetParams()),
42
+ starToSearch('search'),
43
+ camelToSnake(),
44
+ ]);
45
+
46
+ try {
47
+ const response = await getAgentPauseCauseService().searchAgentPauseCause({
48
+ page,
49
+ size,
50
+ // the generated param is `q`; `search` is what the datalist store sends
51
+ q: search,
52
+ sort,
53
+ fields,
54
+ id,
55
+ });
56
+ const { items, next } = applyTransform(response.data, [
57
+ snakeToCamel(),
58
+ merge(getDefaultGetListResponse()),
59
+ ]);
60
+ return {
61
+ items: applyTransform(items, [
62
+ mergeEach(defaultObject),
63
+ ]),
64
+ next,
65
+ };
66
+ } catch (err) {
67
+ throw applyTransform(err, [
68
+ notify,
69
+ ]);
70
+ }
71
+ };
72
+
73
+ const getAgentPauseCause = async ({ itemId: id }: GetItemParams) => {
74
+ try {
75
+ const response = await getAgentPauseCauseService().readAgentPauseCause(
76
+ Number(id),
77
+ );
78
+ return applyTransform(response.data, [
79
+ snakeToCamel(),
80
+ merge(defaultObject),
81
+ ]);
82
+ } catch (err) {
83
+ throw applyTransform(err, [
84
+ notify,
85
+ ]);
86
+ }
87
+ };
88
+
89
+ const addAgentPauseCause = async ({ itemInstance }: AddItemParams) => {
90
+ const item = applyTransform(itemInstance, [
91
+ sanitize(fieldsToSend),
92
+ camelToSnake(),
93
+ ]);
94
+ try {
95
+ const response =
96
+ await getAgentPauseCauseService().createAgentPauseCause(item);
97
+ return applyTransform(response.data, [
98
+ snakeToCamel(),
99
+ ]);
100
+ } catch (err) {
101
+ throw applyTransform(err, [
102
+ notify,
103
+ ]);
104
+ }
105
+ };
106
+
107
+ const patchAgentPauseCause = async ({ changes, id }: PatchItemParams) => {
108
+ const body = applyTransform(changes, [
109
+ sanitize(fieldsToSend),
110
+ camelToSnake(),
111
+ ]);
112
+ try {
113
+ const response = await getAgentPauseCauseService().patchAgentPauseCause(
114
+ Number(id),
115
+ body,
116
+ );
117
+ return applyTransform(response.data, [
118
+ snakeToCamel(),
119
+ ]);
120
+ } catch (err) {
121
+ throw applyTransform(err, [
122
+ notify,
123
+ ]);
124
+ }
125
+ };
126
+
127
+ const updateAgentPauseCause = async ({
128
+ itemInstance,
129
+ itemId: id,
130
+ }: UpdateItemParams) => {
131
+ const item = applyTransform(itemInstance, [
132
+ sanitize(fieldsToSend),
133
+ camelToSnake(),
134
+ ]);
135
+ try {
136
+ const response = await getAgentPauseCauseService().updateAgentPauseCause(
137
+ Number(id),
138
+ item,
139
+ );
140
+ return applyTransform(response.data, [
141
+ snakeToCamel(),
142
+ ]);
143
+ } catch (err) {
144
+ throw applyTransform(err, [
145
+ notify,
146
+ ]);
147
+ }
148
+ };
149
+
150
+ const deleteAgentPauseCause = async ({ id }: DeleteItemParams) => {
151
+ try {
152
+ const response = await getAgentPauseCauseService().deleteAgentPauseCause(
153
+ Number(id),
154
+ );
155
+ return applyTransform(response.data, []);
156
+ } catch (err) {
157
+ throw applyTransform(err, [
158
+ notify,
159
+ ]);
160
+ }
161
+ };
162
+
163
+ const getAgentPauseCausesLookup = (
164
+ params: Parameters<typeof getAgentPauseCausesList>[0],
165
+ ) =>
166
+ getAgentPauseCausesList({
167
+ ...params,
168
+ fields: params.fields || [
169
+ 'id',
170
+ 'name',
171
+ ],
172
+ });
173
+
174
+ export const AgentPauseCausesAPI = {
175
+ getList: getAgentPauseCausesList,
176
+ get: getAgentPauseCause,
177
+ add: addAgentPauseCause,
178
+ patch: patchAgentPauseCause,
179
+ update: updateAgentPauseCause,
180
+ delete: deleteAgentPauseCause,
181
+ getLookup: getAgentPauseCausesLookup,
182
+ };