@in.pulse-crm/sdk 1.1.0 → 1.2.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/dist/file.d.ts +0 -2
- package/dist/index.js +17 -7
- package/dist/response.d.ts +3 -0
- package/package.json +2 -2
- package/src/reports.ts +59 -0
- package/src/response.ts +4 -0
package/dist/file.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
package/dist/response.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@in.pulse-crm/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "SDKs for abstraction of api consumption of in.pulse-crm application",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@in.pulse-crm/utils": "^1.0.0",
|
|
27
|
-
"axios": "^1.8.
|
|
27
|
+
"axios": "^1.8.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.13.10",
|
package/src/reports.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { DataResponse, MessageResponse } from "./response";
|
|
3
|
+
|
|
4
|
+
export interface ChatReport {
|
|
5
|
+
id: number;
|
|
6
|
+
userId: string;
|
|
7
|
+
fileId: number;
|
|
8
|
+
instance: string;
|
|
9
|
+
format: string;
|
|
10
|
+
startDate: string;
|
|
11
|
+
endDate: string;
|
|
12
|
+
exportDate: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GenerateChatReportOptions {
|
|
16
|
+
instance: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
format: ChatReportFileFormat;
|
|
19
|
+
startDate: string;
|
|
20
|
+
endDate: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum ChatReportFileFormat {
|
|
24
|
+
TXT = "txt",
|
|
25
|
+
CSV = "csv",
|
|
26
|
+
PDF = "pdf",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default class ReportsSDK {
|
|
30
|
+
constructor(private readonly httpClient: AxiosInstance) {}
|
|
31
|
+
|
|
32
|
+
public async getChatsReports(instanceName: string) {
|
|
33
|
+
const url = `/${instanceName}/reports/chats`;
|
|
34
|
+
const response =
|
|
35
|
+
await this.httpClient.get<DataResponse<Array<ChatReport>>>(url);
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public async generateChatReport({
|
|
41
|
+
instance,
|
|
42
|
+
...body
|
|
43
|
+
}: GenerateChatReportOptions) {
|
|
44
|
+
const url = `/${instance}/reports/chats`;
|
|
45
|
+
const response = await this.httpClient.post<DataResponse<ChatReport>>(
|
|
46
|
+
url,
|
|
47
|
+
body,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public async deleteReport(instanceName: string, reportId: number) {
|
|
54
|
+
const url = `/${instanceName}/reports/chats/${reportId}`;
|
|
55
|
+
const response = await this.httpClient.delete<MessageResponse>(url);
|
|
56
|
+
|
|
57
|
+
return response.data;
|
|
58
|
+
}
|
|
59
|
+
}
|