@webitel/api-services 0.0.103 → 0.0.104
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,7 +1,9 @@
|
|
|
1
1
|
import { getMessages } from '@webitel/api-services/gen';
|
|
2
|
+
import { getDefaultGetListResponse, getDefaultGetParams } from '../../defaults';
|
|
2
3
|
import {
|
|
3
4
|
applyTransform,
|
|
4
5
|
camelToSnake,
|
|
6
|
+
merge,
|
|
5
7
|
notify,
|
|
6
8
|
snakeToCamel,
|
|
7
9
|
} from '../../transformers';
|
|
@@ -17,6 +19,28 @@ const patchMessagesService = async (changes) => {
|
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
|
|
22
|
+
const getChatHistory = async ({ chatId, ...params }) => {
|
|
23
|
+
const listParams = applyTransform(params, [
|
|
24
|
+
merge(getDefaultGetParams()),
|
|
25
|
+
camelToSnake(),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const response = await getMessages().catalogGetHistory(
|
|
30
|
+
chatId,
|
|
31
|
+
listParams,
|
|
32
|
+
);
|
|
33
|
+
const { messages, peers } = applyTransform(response.data, [
|
|
34
|
+
snakeToCamel(),
|
|
35
|
+
merge(getDefaultGetListResponse()),
|
|
36
|
+
]);
|
|
37
|
+
return { messages, peers };
|
|
38
|
+
} catch (err) {
|
|
39
|
+
throw applyTransform(err, [notify]);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
20
43
|
export const MessagesServiceAPI = {
|
|
21
44
|
patch: patchMessagesService,
|
|
45
|
+
getChatHistory,
|
|
22
46
|
};
|