@webitel/api-services 1.0.9 → 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 (107) 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 +21 -31
  17. package/src/api/clients/caseStatuses/caseStatuses.ts +10 -21
  18. package/src/api/clients/cases/cases.ts +6 -3
  19. package/src/api/clients/catalog/catalog.ts +2 -8
  20. package/src/api/clients/changelogs/changelogs.ts +8 -0
  21. package/src/api/clients/chatplans/chatplans.ts +173 -0
  22. package/src/api/clients/cognitiveProfiles/cognitiveProfiles.ts +209 -0
  23. package/src/api/clients/communications/communications.ts +38 -42
  24. package/src/api/clients/dialplans/dialplans.ts +197 -0
  25. package/src/api/clients/emailProfiles/emailProfiles.ts +222 -0
  26. package/src/api/clients/fileServices/fileServices.ts +7 -2
  27. package/src/api/clients/flows/flow.ts +54 -43
  28. package/src/api/clients/fts/fts.ts +61 -0
  29. package/src/api/clients/history/transcript/callTranscript.ts +10 -20
  30. package/src/api/clients/importTemplates/importTemplates.ts +180 -0
  31. package/src/api/clients/index.ts +30 -0
  32. package/src/api/clients/lists/blacklistNumbers.ts +155 -0
  33. package/src/api/clients/lists/blacklists.ts +20 -25
  34. package/src/api/clients/logs/logs.ts +157 -0
  35. package/src/api/clients/media/media.ts +19 -15
  36. package/src/api/clients/object/object.ts +3 -14
  37. package/src/api/clients/outboundResourceGroups/outboundResourceGroups.ts +187 -0
  38. package/src/api/clients/outboundResourceGroups/resourcesInGroup.ts +169 -0
  39. package/src/api/clients/outboundResources/outboundResources.ts +225 -0
  40. package/src/api/clients/outboundResources/resourceDisplays.ts +165 -0
  41. package/src/api/clients/pauseTemplates/pauseTemplates.ts +203 -0
  42. package/src/api/clients/queues/__tests__/queueLogs.spec.ts +3 -3
  43. package/src/api/clients/queues/__tests__/queueMembers.spec.ts +4 -4
  44. package/src/api/clients/queues/queueLogs.ts +8 -3
  45. package/src/api/clients/queues/queueMembers.ts +3 -3
  46. package/src/api/clients/queues/queues.ts +52 -0
  47. package/src/api/clients/regions/regions.ts +21 -25
  48. package/src/api/clients/schemaVariables/schemaVariables.ts +167 -0
  49. package/src/api/clients/shiftTemplates/shiftTemplates.ts +176 -0
  50. package/src/api/clients/skills/skillAgents.ts +190 -0
  51. package/src/api/clients/skills/skills.ts +21 -25
  52. package/src/api/clients/storagePolicies/storagePolicies.ts +270 -0
  53. package/src/api/clients/teamHooks/teamHooks.ts +195 -0
  54. package/src/api/clients/teamTriggers/agentTriggers.ts +77 -0
  55. package/src/api/clients/teamTriggers/teamFlows.ts +194 -0
  56. package/src/api/clients/teams/teams.ts +31 -31
  57. package/src/api/clients/triggers/triggerJobs.ts +63 -0
  58. package/src/api/clients/triggers/triggers.ts +266 -0
  59. package/src/api/clients/userSettings/userSettings.ts +8 -9
  60. package/src/api/clients/users/users.ts +2 -0
  61. package/src/api/clients/workingConditions/workingConditions.ts +184 -0
  62. package/src/api/clients/workspaceWidgets/workspaceWidgets.ts +73 -0
  63. package/src/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.ts +3 -3
  64. package/src/api/clients/wtTypes/adjunctTypes/adjunctTypes.ts +1 -1
  65. package/src/api/clients//321/201ontacts/contactChatMessagesHistory.ts +15 -26
  66. package/types/.tsbuildinfo +1 -1
  67. package/types/api/clients/activeCalls/activeCalls.d.ts +7 -0
  68. package/types/api/clients/agentPauseCauses/agentPauseCauses.d.ts +21 -0
  69. package/types/api/clients/agentSkills/agentSkills.d.ts +12 -0
  70. package/types/api/clients/agents/agents.d.ts +23 -2
  71. package/types/api/clients/auditForms/auditForms.d.ts +7 -0
  72. package/types/api/clients/auditForms/auditRates.d.ts +10 -0
  73. package/types/api/clients/backendProfiles/backendProfiles.d.ts +21 -0
  74. package/types/api/clients/callHistory/callAnnotations.d.ts +12 -0
  75. package/types/api/clients/callHistory/callHistory.d.ts +24 -3
  76. package/types/api/clients/caseStatusConditions/caseStatusConditions.d.ts +4 -4
  77. package/types/api/clients/cases/cases.d.ts +5 -2
  78. package/types/api/clients/chatplans/chatplans.d.ts +21 -0
  79. package/types/api/clients/cognitiveProfiles/cognitiveProfiles.d.ts +21 -0
  80. package/types/api/clients/dialplans/dialplans.d.ts +16 -0
  81. package/types/api/clients/emailProfiles/emailProfiles.d.ts +27 -0
  82. package/types/api/clients/fileServices/fileServices.d.ts +1 -1
  83. package/types/api/clients/fts/fts.d.ts +7 -0
  84. package/types/api/clients/importTemplates/importTemplates.d.ts +21 -0
  85. package/types/api/clients/index.d.ts +30 -0
  86. package/types/api/clients/lists/blacklistNumbers.d.ts +11 -0
  87. package/types/api/clients/logs/logs.d.ts +15 -0
  88. package/types/api/clients/outboundResourceGroups/outboundResourceGroups.d.ts +20 -0
  89. package/types/api/clients/outboundResourceGroups/resourcesInGroup.d.ts +11 -0
  90. package/types/api/clients/outboundResources/outboundResources.d.ts +21 -0
  91. package/types/api/clients/outboundResources/resourceDisplays.d.ts +11 -0
  92. package/types/api/clients/pauseTemplates/pauseTemplates.d.ts +20 -0
  93. package/types/api/clients/queues/queues.d.ts +5 -0
  94. package/types/api/clients/schemaVariables/schemaVariables.d.ts +21 -0
  95. package/types/api/clients/shiftTemplates/shiftTemplates.d.ts +20 -0
  96. package/types/api/clients/skills/skillAgents.d.ts +13 -0
  97. package/types/api/clients/storagePolicies/storagePolicies.d.ts +26 -0
  98. package/types/api/clients/teamHooks/teamHooks.d.ts +12 -0
  99. package/types/api/clients/teamTriggers/agentTriggers.d.ts +23 -0
  100. package/types/api/clients/teamTriggers/teamFlows.d.ts +12 -0
  101. package/types/api/clients/triggers/triggerJobs.d.ts +7 -0
  102. package/types/api/clients/triggers/triggers.d.ts +22 -0
  103. package/types/api/clients/userSettings/userSettings.d.ts +2 -2
  104. package/types/api/clients/workingConditions/workingConditions.d.ts +20 -0
  105. package/types/api/clients/workspaceWidgets/workspaceWidgets.d.ts +3 -0
  106. package/types/api/clients/wtTypes/adjunctTypeRecords/adjunctTypeRecords.d.ts +2 -2
  107. package/types/api/clients/wtTypes/adjunctTypes/adjunctTypes.d.ts +2 -2
@@ -0,0 +1,61 @@
1
+ import { getFtsservice } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ notify,
8
+ sanitize,
9
+ snakeToCamel,
10
+ } from '../../transformers';
11
+ import type { ApiParams } from '../_shared/types';
12
+
13
+ /** Full-text search across objects. Callers pass the query as `fts`. */
14
+ const getFtsList = async (params: ApiParams) => {
15
+ const fieldsToSend = [
16
+ 'page',
17
+ 'size',
18
+ 'q',
19
+ 'sort',
20
+ 'fields',
21
+ 'object_name',
22
+ ];
23
+
24
+ const { page, size, q, sort, fields, object_name } = applyTransform(params, [
25
+ merge(getDefaultGetParams()),
26
+ (params: ApiParams) => ({
27
+ ...params,
28
+ q: params.fts,
29
+ }),
30
+ sanitize(fieldsToSend),
31
+ camelToSnake(),
32
+ ]);
33
+
34
+ try {
35
+ const response = await getFtsservice().search({
36
+ page,
37
+ size,
38
+ q,
39
+ sort,
40
+ fields,
41
+ object_name,
42
+ });
43
+ const { items, next } = applyTransform(response.data, [
44
+ merge(getDefaultGetListResponse()),
45
+ ]);
46
+ return {
47
+ items: applyTransform(items, [
48
+ snakeToCamel(),
49
+ ]),
50
+ next,
51
+ };
52
+ } catch (err) {
53
+ throw applyTransform(err, [
54
+ notify,
55
+ ]);
56
+ }
57
+ };
58
+
59
+ export const FtsAPI = {
60
+ getList: getFtsList,
61
+ };
@@ -1,9 +1,5 @@
1
- import { FileTranscriptServiceApiFactory } from 'webitel-sdk';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultInstance,
5
- getDefaultOpenAPIConfig,
6
- } from '../../../defaults';
1
+ import { getFileTranscriptService } from '../../../../gen-wire';
2
+ import { getDefaultGetListResponse } from '../../../defaults';
7
3
  import {
8
4
  applyTransform,
9
5
  camelToSnake,
@@ -13,15 +9,6 @@ import {
13
9
  } from '../../../transformers';
14
10
  import type { ApiId, ApiParams } from '../../_shared/types';
15
11
 
16
- const instance = getDefaultInstance();
17
- const configuration = getDefaultOpenAPIConfig();
18
-
19
- const transcriptService = FileTranscriptServiceApiFactory(
20
- configuration,
21
- '',
22
- instance,
23
- );
24
-
25
12
  const getTranscript = async ({
26
13
  id,
27
14
  page = 1,
@@ -32,10 +19,12 @@ const getTranscript = async ({
32
19
  size?: number;
33
20
  }) => {
34
21
  try {
35
- const response = await transcriptService.getFileTranscriptPhrases(
22
+ const response = await getFileTranscriptService().getFileTranscriptPhrases(
36
23
  String(id),
37
- page,
38
- size,
24
+ {
25
+ page,
26
+ size,
27
+ },
39
28
  );
40
29
  const { items } = applyTransform(response.data, [
41
30
  snakeToCamel(),
@@ -64,7 +53,7 @@ const createTranscript = async ({ callId }: { callId: string }) => {
64
53
  ]);
65
54
 
66
55
  try {
67
- const response = await transcriptService.createFileTranscript({
56
+ const response = await getFileTranscriptService().createFileTranscript({
68
57
  uuid,
69
58
  });
70
59
  return applyTransform(response.data, [
@@ -109,7 +98,8 @@ const deleteTranscript = async (item: ApiParams) => {
109
98
  ]);
110
99
 
111
100
  try {
112
- const response = await transcriptService.deleteFileTranscript(body);
101
+ const response =
102
+ await getFileTranscriptService().deleteFileTranscript(body);
113
103
  return applyTransform(response.data, []);
114
104
  } catch (err) {
115
105
  throw applyTransform(err, [
@@ -0,0 +1,180 @@
1
+ import { getImportTemplateService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ notify,
8
+ sanitize,
9
+ snakeToCamel,
10
+ starToSearch,
11
+ } from '../../transformers';
12
+ import type {
13
+ AddItemParams,
14
+ ApiParams,
15
+ DeleteItemParams,
16
+ GetItemParams,
17
+ PatchItemParams,
18
+ UpdateItemParams,
19
+ } from '../_shared/types';
20
+
21
+ /**
22
+ * `mappings` keys are CSV column names — user data, not API fields — so the
23
+ * case transformers must leave them alone.
24
+ */
25
+ const doNotConvertKeys = [
26
+ 'mappings',
27
+ ];
28
+
29
+ const fieldsToSend = [
30
+ 'description',
31
+ 'name',
32
+ 'parameters',
33
+ 'source',
34
+ 'sourceType',
35
+ ];
36
+
37
+ const getImportTemplatesList = async (params: ApiParams) => {
38
+ const { page, size, search, sort, fields, id } = applyTransform(params, [
39
+ merge(getDefaultGetParams()),
40
+ starToSearch('search'),
41
+ ]);
42
+
43
+ try {
44
+ const response = await getImportTemplateService().searchImportTemplate({
45
+ page,
46
+ size,
47
+ // the generated param is `q`; `search` is what the datalist store sends
48
+ q: search,
49
+ sort,
50
+ fields,
51
+ id,
52
+ });
53
+ const { items, next } = applyTransform(response.data, [
54
+ snakeToCamel(doNotConvertKeys),
55
+ merge(getDefaultGetListResponse()),
56
+ ]);
57
+ return {
58
+ items,
59
+ next,
60
+ };
61
+ } catch (err) {
62
+ throw applyTransform(err, [
63
+ notify,
64
+ ]);
65
+ }
66
+ };
67
+
68
+ const getImportTemplate = async ({ itemId: id }: GetItemParams) => {
69
+ try {
70
+ const response = await getImportTemplateService().readImportTemplate(
71
+ Number(id),
72
+ );
73
+ return applyTransform(response.data, [
74
+ snakeToCamel(doNotConvertKeys),
75
+ ]);
76
+ } catch (err) {
77
+ throw applyTransform(err, [
78
+ notify,
79
+ ]);
80
+ }
81
+ };
82
+
83
+ const addImportTemplate = async ({ itemInstance }: AddItemParams) => {
84
+ const item = applyTransform(itemInstance, [
85
+ sanitize(fieldsToSend),
86
+ camelToSnake(doNotConvertKeys),
87
+ ]);
88
+ try {
89
+ const response =
90
+ await getImportTemplateService().createImportTemplate(item);
91
+ return applyTransform(response.data, [
92
+ snakeToCamel(doNotConvertKeys),
93
+ ]);
94
+ } catch (err) {
95
+ throw applyTransform(err, [
96
+ notify,
97
+ ]);
98
+ }
99
+ };
100
+
101
+ /*
102
+ * The webitel-sdk copy of this client called `updateImportTemplate` for both
103
+ * `patch` and `update`; kept as-is so the request is unchanged.
104
+ */
105
+ const patchImportTemplate = async ({ changes, id }: PatchItemParams) => {
106
+ const body = applyTransform(changes, [
107
+ sanitize(fieldsToSend),
108
+ camelToSnake(doNotConvertKeys),
109
+ ]);
110
+ try {
111
+ const response = await getImportTemplateService().updateImportTemplate(
112
+ Number(id),
113
+ body,
114
+ );
115
+ return applyTransform(response.data, [
116
+ snakeToCamel(doNotConvertKeys),
117
+ ]);
118
+ } catch (err) {
119
+ throw applyTransform(err, [
120
+ notify,
121
+ ]);
122
+ }
123
+ };
124
+
125
+ const updateImportTemplate = async ({
126
+ itemInstance,
127
+ itemId: id,
128
+ }: UpdateItemParams) => {
129
+ const item = applyTransform(itemInstance, [
130
+ sanitize(fieldsToSend),
131
+ camelToSnake(doNotConvertKeys),
132
+ ]);
133
+ try {
134
+ const response = await getImportTemplateService().updateImportTemplate(
135
+ Number(id),
136
+ item,
137
+ );
138
+ return applyTransform(response.data, [
139
+ snakeToCamel(doNotConvertKeys),
140
+ ]);
141
+ } catch (err) {
142
+ throw applyTransform(err, [
143
+ notify,
144
+ ]);
145
+ }
146
+ };
147
+
148
+ const deleteImportTemplate = async ({ id }: DeleteItemParams) => {
149
+ try {
150
+ const response = await getImportTemplateService().deleteImportTemplate(
151
+ Number(id),
152
+ );
153
+ return applyTransform(response.data, []);
154
+ } catch (err) {
155
+ throw applyTransform(err, [
156
+ notify,
157
+ ]);
158
+ }
159
+ };
160
+
161
+ const getImportTemplatesLookup = (
162
+ params: Parameters<typeof getImportTemplatesList>[0],
163
+ ) =>
164
+ getImportTemplatesList({
165
+ ...params,
166
+ fields: params.fields || [
167
+ 'id',
168
+ 'name',
169
+ ],
170
+ });
171
+
172
+ export const ImportTemplatesAPI = {
173
+ getList: getImportTemplatesList,
174
+ get: getImportTemplate,
175
+ add: addImportTemplate,
176
+ patch: patchImportTemplate,
177
+ update: updateImportTemplate,
178
+ delete: deleteImportTemplate,
179
+ getLookup: getImportTemplatesLookup,
180
+ };
@@ -1,10 +1,16 @@
1
1
  export * from './_shared/generatePermissionsApi';
2
+ export * from './activeCalls/activeCalls';
3
+ export * from './agentPauseCauses/agentPauseCauses';
4
+ export * from './agentSkills/agentSkills';
2
5
  export * from './agents/agentAbsence';
3
6
  export * from './agents/agentChats';
4
7
  export * from './agents/agents';
5
8
  export * from './auditForms/auditForms';
9
+ export * from './auditForms/auditRates';
10
+ export * from './backendProfiles/backendProfiles';
6
11
  export * from './buckets/buckets';
7
12
  export * from './calendars/calendars';
13
+ export * from './callHistory/callAnnotations';
8
14
  export * from './callHistory/callHistory';
9
15
  export * from './caseCloseReasonGroups/caseCloseReasonGroups';
10
16
  export * from './caseCloseReasons/caseCloseReasons';
@@ -24,25 +30,38 @@ export * from './changelogs/changelogs';
24
30
  export * from './chatDialogs/chatDialogs';
25
31
  export * from './chatGateways/chatGateways';
26
32
  export * from './chatMessagesHistory/chatMessagesHistory';
33
+ export * from './chatplans/chatplans';
34
+ export * from './cognitiveProfiles/cognitiveProfiles';
27
35
  export * from './communications/communications';
28
36
  export * from './configurations/configurations';
29
37
  export * from './contactCases/contactCases';
30
38
  export * from './contactGroups/contactGroups';
39
+ export * from './dialplans/dialplans';
31
40
  export * from './dynamicConditions/dynamicConditions';
32
41
  export * from './dynamicGroups/dynamicGroups';
42
+ export * from './emailProfiles/emailProfiles';
33
43
  export * from './emails/emails';
34
44
  export * from './fileServices/fileServices';
35
45
  export * from './flows/flow';
46
+ export * from './fts/fts';
36
47
  export * from './gateways/gateways';
37
48
  export * from './history/transcript/callTranscript';
38
49
  export * from './imClients/imClients';
50
+ export * from './importTemplates/importTemplates';
39
51
  export * from './labels/labels';
52
+ export * from './lists/blacklistNumbers';
40
53
  export * from './lists/blacklists';
54
+ export * from './logs/logs';
41
55
  export * from './media/media';
42
56
  export * from './messageService/messageService';
43
57
  export * from './oauthApps/oauthApps';
44
58
  export * from './object/object';
45
59
  export * from './onlineSkills/onlineSkills';
60
+ export * from './outboundResourceGroups/outboundResourceGroups';
61
+ export * from './outboundResourceGroups/resourcesInGroup';
62
+ export * from './outboundResources/outboundResources';
63
+ export * from './outboundResources/resourceDisplays';
64
+ export * from './pauseTemplates/pauseTemplates';
46
65
  export * from './pdfServices/pdfServices';
47
66
  export * from './phones/phones';
48
67
  export * from './queues/queueAgents';
@@ -56,15 +75,26 @@ export * from './queues/queueState';
56
75
  export * from './queues/queues';
57
76
  export * from './quickReplies/quickReplies';
58
77
  export * from './regions/regions';
78
+ export * from './schemaVariables/schemaVariables';
79
+ export * from './shiftTemplates/shiftTemplates';
80
+ export * from './skills/skillAgents';
59
81
  // export * from './roles/roles'; fixme: ApplicationAccess import
60
82
  export * from './skills/skills';
61
83
  export * from './slaConditions/slaConditions';
62
84
  export * from './slas/slas';
85
+ export * from './storagePolicies/storagePolicies';
86
+ export * from './teamHooks/teamHooks';
63
87
  export * from './teams/teams';
88
+ export * from './teamTriggers/agentTriggers';
89
+ export * from './teamTriggers/teamFlows';
64
90
  export * from './timeline/timeline';
91
+ export * from './triggers/triggerJobs';
92
+ export * from './triggers/triggers';
65
93
  export * from './userSettings/userSettings';
66
94
  export * from './users/users';
67
95
  export * from './variables/variables';
96
+ export * from './workingConditions/workingConditions';
97
+ export * from './workspaceWidgets/workspaceWidgets';
68
98
  export * from './wtTypes/adjunctTypeRecords/adjunctTypeRecords';
69
99
  export * from './wtTypes/adjunctTypes/adjunctTypes';
70
100
  export * from './wtTypes/sysTypes/sysTypes';
@@ -0,0 +1,155 @@
1
+ import { getListService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ notify,
8
+ sanitize,
9
+ snakeToCamel,
10
+ starToSearch,
11
+ } from '../../transformers';
12
+ import type {
13
+ ApiParams,
14
+ NestedAddItemParams,
15
+ NestedDeleteItemParams,
16
+ NestedGetItemParams,
17
+ NestedUpdateItemParams,
18
+ } from '../_shared/types';
19
+
20
+ /** Numbers inside one blacklist. `parentId` is the list. */
21
+ const fieldsToSend = [
22
+ 'listId',
23
+ 'description',
24
+ 'number',
25
+ 'expireAt',
26
+ ];
27
+
28
+ const getBlacklistNumbersList = async (params: ApiParams) => {
29
+ const { parentId, page, size, search, sort, fields, id } = applyTransform(
30
+ params,
31
+ [
32
+ merge(getDefaultGetParams()),
33
+ starToSearch('search'),
34
+ ],
35
+ );
36
+
37
+ try {
38
+ const response = await getListService().searchListCommunication(
39
+ String(parentId),
40
+ {
41
+ page,
42
+ size,
43
+ // the generated param is `q`; `search` is what the datalist store sends
44
+ q: search,
45
+ sort,
46
+ fields,
47
+ id,
48
+ },
49
+ );
50
+ const { items, next } = applyTransform(response.data, [
51
+ snakeToCamel(),
52
+ merge(getDefaultGetListResponse()),
53
+ ]);
54
+ return {
55
+ items,
56
+ next,
57
+ };
58
+ } catch (err) {
59
+ throw applyTransform(err, [
60
+ notify,
61
+ ]);
62
+ }
63
+ };
64
+
65
+ const getBlacklistNumber = async ({
66
+ parentId,
67
+ itemId: id,
68
+ }: NestedGetItemParams) => {
69
+ try {
70
+ const response = await getListService().readListCommunication(
71
+ String(parentId),
72
+ String(id),
73
+ );
74
+ return applyTransform(response.data, [
75
+ snakeToCamel(),
76
+ ]);
77
+ } catch (err) {
78
+ throw applyTransform(err, [
79
+ notify,
80
+ ]);
81
+ }
82
+ };
83
+
84
+ const addBlacklistNumber = async ({
85
+ parentId,
86
+ itemInstance,
87
+ }: NestedAddItemParams) => {
88
+ const item = applyTransform(itemInstance, [
89
+ sanitize(fieldsToSend),
90
+ camelToSnake(),
91
+ ]);
92
+ try {
93
+ const response = await getListService().createListCommunication(
94
+ String(parentId),
95
+ item,
96
+ );
97
+ return applyTransform(response.data, [
98
+ snakeToCamel(),
99
+ ]);
100
+ } catch (err) {
101
+ throw applyTransform(err, [
102
+ notify,
103
+ ]);
104
+ }
105
+ };
106
+
107
+ const updateBlacklistNumber = async ({
108
+ parentId,
109
+ itemInstance,
110
+ itemId: id,
111
+ }: NestedUpdateItemParams) => {
112
+ const item = applyTransform(itemInstance, [
113
+ sanitize(fieldsToSend),
114
+ camelToSnake(),
115
+ ]);
116
+ try {
117
+ const response = await getListService().updateListCommunication(
118
+ String(parentId),
119
+ String(id),
120
+ item,
121
+ );
122
+ return applyTransform(response.data, [
123
+ snakeToCamel(),
124
+ ]);
125
+ } catch (err) {
126
+ throw applyTransform(err, [
127
+ notify,
128
+ ]);
129
+ }
130
+ };
131
+
132
+ const deleteBlacklistNumber = async ({
133
+ parentId,
134
+ id,
135
+ }: NestedDeleteItemParams) => {
136
+ try {
137
+ const response = await getListService().deleteListCommunication(
138
+ String(parentId),
139
+ String(id),
140
+ );
141
+ return applyTransform(response.data, []);
142
+ } catch (err) {
143
+ throw applyTransform(err, [
144
+ notify,
145
+ ]);
146
+ }
147
+ };
148
+
149
+ export const BlacklistNumbersAPI = {
150
+ getList: getBlacklistNumbersList,
151
+ get: getBlacklistNumber,
152
+ add: addBlacklistNumber,
153
+ update: updateBlacklistNumber,
154
+ delete: deleteBlacklistNumber,
155
+ };
@@ -1,10 +1,5 @@
1
- import { ListServiceApiFactory } from 'webitel-sdk';
2
- import {
3
- getDefaultGetListResponse,
4
- getDefaultGetParams,
5
- getDefaultInstance,
6
- getDefaultOpenAPIConfig,
7
- } from '../../defaults';
1
+ import { getListService } from '../../../gen-wire';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
8
3
  import {
9
4
  applyTransform,
10
5
  camelToSnake,
@@ -23,32 +18,32 @@ import type {
23
18
  UpdateItemParams,
24
19
  } from '../_shared/types';
25
20
 
26
- const instance = getDefaultInstance();
27
- const configuration = getDefaultOpenAPIConfig();
28
-
29
- const listService = ListServiceApiFactory(configuration, '', instance);
30
-
31
21
  const getBlacklistList = async (params: ApiParams) => {
32
22
  const defaultObject = {
33
23
  name: '',
34
24
  count: 0,
35
25
  };
36
26
 
37
- const { page, size, search, sort, fields, id } = applyTransform(params, [
27
+ const requestParams = applyTransform(params, [
38
28
  merge(getDefaultGetParams()),
39
29
  starToSearch('search'),
40
30
  camelToSnake(),
31
+ (params) => ({
32
+ ...params,
33
+ q: params.search,
34
+ }),
35
+ sanitize([
36
+ 'page',
37
+ 'size',
38
+ 'q',
39
+ 'sort',
40
+ 'fields',
41
+ 'id',
42
+ ]),
41
43
  ]);
42
44
 
43
45
  try {
44
- const response = await listService.searchList(
45
- page,
46
- size,
47
- search,
48
- sort,
49
- fields,
50
- id,
51
- );
46
+ const response = await getListService().searchList(requestParams);
52
47
  const { items, next } = applyTransform(response.data, [
53
48
  snakeToCamel(),
54
49
  merge(getDefaultGetListResponse()),
@@ -68,7 +63,7 @@ const getBlacklistList = async (params: ApiParams) => {
68
63
 
69
64
  const getBlacklist = async ({ itemId: id }: GetItemParams) => {
70
65
  try {
71
- const response = await listService.readList(String(id));
66
+ const response = await getListService().readList(String(id));
72
67
  return applyTransform(response.data, [
73
68
  snakeToCamel(),
74
69
  ]);
@@ -90,7 +85,7 @@ const addBlacklist = async ({ itemInstance }: AddItemParams) => {
90
85
  camelToSnake(),
91
86
  ]);
92
87
  try {
93
- const response = await listService.createList(item);
88
+ const response = await getListService().createList(item);
94
89
  return applyTransform(response.data, [
95
90
  snakeToCamel(),
96
91
  ]);
@@ -110,7 +105,7 @@ const updateBlacklist = async ({
110
105
  camelToSnake(),
111
106
  ]);
112
107
  try {
113
- const response = await listService.updateList(String(id), item);
108
+ const response = await getListService().updateList(String(id), item);
114
109
  return applyTransform(response.data, [
115
110
  snakeToCamel(),
116
111
  ]);
@@ -123,7 +118,7 @@ const updateBlacklist = async ({
123
118
 
124
119
  const deleteBlacklist = async ({ id }: DeleteItemParams) => {
125
120
  try {
126
- const response = await listService.deleteList(String(id));
121
+ const response = await getListService().deleteList(String(id));
127
122
  return applyTransform(response.data, []);
128
123
  } catch (err) {
129
124
  throw applyTransform(err, [