@webitel/api-services 0.0.56 → 0.0.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "make-all": "npm run gen:api && npm version patch && (npm run build:types || true) && (npm run format:all || true) && npm run publish-lib",
@@ -177,7 +177,7 @@ const getScreenRecordingsByAgent = async (params: any) => {
177
177
  size,
178
178
  q: q || params.search,
179
179
  sort,
180
- fields: ['id', ...fields],
180
+ fields: ['id', 'view_name', 'mime_type', ...fields],
181
181
  id,
182
182
  'uploaded_at.from': uploadedAtFrom,
183
183
  'uploaded_at.to': uploadedAtTo,
@@ -24,6 +24,7 @@ export * from './lists/blacklists';
24
24
  export * from './media/media';
25
25
  export * from './object/object';
26
26
  export * from './pdfServices/pdfServices';
27
+ export * from './phones/phones';
27
28
  export * from './queues/queues';
28
29
  export * from './quickReplies/quickReplies';
29
30
  // export * from './roles/roles'; fixme: ApplicationAccess import
@@ -0,0 +1,148 @@
1
+ import { getPhones } from '@webitel/api-services/gen';
2
+ import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
3
+ import {
4
+ applyTransform,
5
+ camelToSnake,
6
+ merge,
7
+ notify,
8
+ snakeToCamel,
9
+ starToSearch,
10
+ } from '../../transformers';
11
+
12
+ const getPhonesList = async ({ contactId, options, ...params }) => {
13
+ const listParams = applyTransform(params, [
14
+ merge(getDefaultGetParams()),
15
+ starToSearch('search'),
16
+ ]);
17
+ try {
18
+ const response = await getPhones().listPhones(
19
+ contactId,
20
+ listParams,
21
+ options,
22
+ );
23
+ const { items, next } = applyTransform(response.data, [
24
+ snakeToCamel(),
25
+ merge(getDefaultGetListResponse()),
26
+ ]);
27
+ return { items, next };
28
+ } catch (err) {
29
+ throw applyTransform(err, [notify]);
30
+ }
31
+ };
32
+
33
+ const getPhone = async ({ contactId, etag, params, options }) => {
34
+ try {
35
+ const response = await getPhones().locatePhone(
36
+ contactId,
37
+ etag,
38
+ params,
39
+ options,
40
+ );
41
+ return applyTransform(response.data, [snakeToCamel()]);
42
+ } catch (err) {
43
+ throw applyTransform(err, [notify]);
44
+ }
45
+ };
46
+
47
+ const mergePhones = async ({ contactId, phones, params, options }) => {
48
+ const body = applyTransform(phones, [camelToSnake()]);
49
+ try {
50
+ const response = await getPhones().mergePhones(
51
+ contactId,
52
+ body,
53
+ params,
54
+ options,
55
+ );
56
+ return applyTransform(response.data, [snakeToCamel()]);
57
+ } catch (err) {
58
+ throw applyTransform(err, [notify]);
59
+ }
60
+ };
61
+
62
+ const resetPhones = async ({ contactId, phones, params, options }) => {
63
+ const body = applyTransform(phones, [camelToSnake()]);
64
+ try {
65
+ const response = await getPhones().resetPhones(
66
+ contactId,
67
+ body,
68
+ params,
69
+ options,
70
+ );
71
+ return applyTransform(response.data, [snakeToCamel()]);
72
+ } catch (err) {
73
+ throw applyTransform(err, [notify]);
74
+ }
75
+ };
76
+
77
+ const updatePhone = async ({ contactId, etag, data, params, options }) => {
78
+ const body = applyTransform(data, [camelToSnake()]);
79
+ try {
80
+ const response = await getPhones().updatePhone(
81
+ contactId,
82
+ etag,
83
+ body,
84
+ params,
85
+ options,
86
+ );
87
+ return applyTransform(response.data, [snakeToCamel()]);
88
+ } catch (err) {
89
+ throw applyTransform(err, [notify]);
90
+ }
91
+ };
92
+
93
+ const patchPhone = async ({ contactId, etag, changes, params, options }) => {
94
+ const body = applyTransform(changes, [camelToSnake()]);
95
+ try {
96
+ const response = await getPhones().updatePhone2(
97
+ contactId,
98
+ etag,
99
+ body,
100
+ params,
101
+ options,
102
+ );
103
+ return applyTransform(response.data, [snakeToCamel()]);
104
+ } catch (err) {
105
+ throw applyTransform(err, [notify]);
106
+ }
107
+ };
108
+
109
+ const deletePhone = async ({ contactId, etag, params, options }) => {
110
+ try {
111
+ const response = await getPhones().deletePhone(
112
+ contactId,
113
+ etag,
114
+ params,
115
+ options,
116
+ );
117
+ return applyTransform(response.data, [snakeToCamel()]);
118
+ } catch (err) {
119
+ throw applyTransform(err, [notify]);
120
+ }
121
+ };
122
+
123
+ const deletePhones = async ({ contactId, params, options }) => {
124
+ try {
125
+ const response = await getPhones().deletePhones(contactId, params, options);
126
+ return applyTransform(response.data, [snakeToCamel()]);
127
+ } catch (err) {
128
+ throw applyTransform(err, [notify]);
129
+ }
130
+ };
131
+
132
+ const getPhonesLookup = (params) =>
133
+ getPhonesList({
134
+ ...params,
135
+ fields: params?.fields || ['etag', 'number', 'priority'],
136
+ });
137
+
138
+ export const PhonesAPI = {
139
+ getList: getPhonesList,
140
+ getLookup: getPhonesLookup,
141
+ merge: mergePhones,
142
+ reset: resetPhones,
143
+ deleteMany: deletePhones,
144
+ get: getPhone,
145
+ update: updatePhone,
146
+ patch: patchPhone,
147
+ delete: deletePhone,
148
+ };
@@ -32,3 +32,4 @@ export * from './wtTypes/adjunctTypes/adjunctTypes';
32
32
  export * from './wtTypes/sysTypes/sysTypes';
33
33
  export * from './wtTypes/typeExtensions/typeExtensions';
34
34
  export * from './сontacts';
35
+ export * from './phones/phones';
@@ -0,0 +1,57 @@
1
+ export declare const PhonesAPI: {
2
+ getList: ({ contactId, options, ...params }: {
3
+ [x: string]: any;
4
+ contactId: any;
5
+ options: any;
6
+ }) => Promise<{
7
+ items: any;
8
+ next: any;
9
+ }>;
10
+ getLookup: (params: any) => Promise<{
11
+ items: any;
12
+ next: any;
13
+ }>;
14
+ merge: ({ contactId, phones, params, options }: {
15
+ contactId: any;
16
+ phones: any;
17
+ params: any;
18
+ options: any;
19
+ }) => Promise<any>;
20
+ reset: ({ contactId, phones, params, options }: {
21
+ contactId: any;
22
+ phones: any;
23
+ params: any;
24
+ options: any;
25
+ }) => Promise<any>;
26
+ deleteMany: ({ contactId, params, options }: {
27
+ contactId: any;
28
+ params: any;
29
+ options: any;
30
+ }) => Promise<any>;
31
+ get: ({ contactId, etag, params, options }: {
32
+ contactId: any;
33
+ etag: any;
34
+ params: any;
35
+ options: any;
36
+ }) => Promise<any>;
37
+ update: ({ contactId, etag, data, params, options }: {
38
+ contactId: any;
39
+ etag: any;
40
+ data: any;
41
+ params: any;
42
+ options: any;
43
+ }) => Promise<any>;
44
+ patch: ({ contactId, etag, changes, params, options }: {
45
+ contactId: any;
46
+ etag: any;
47
+ changes: any;
48
+ params: any;
49
+ options: any;
50
+ }) => Promise<any>;
51
+ delete: ({ contactId, etag, params, options }: {
52
+ contactId: any;
53
+ etag: any;
54
+ params: any;
55
+ options: any;
56
+ }) => Promise<any>;
57
+ };