@in.pulse-crm/sdk 1.4.0 → 1.5.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/auth.d.ts +2 -8
- package/dist/auth.js +3 -21
- package/dist/instance.d.ts +2 -2
- package/dist/instance.js +3 -3
- package/dist/report.d.ts +3 -4
- package/dist/report.js +6 -6
- package/package.json +1 -1
- package/src/auth.ts +4 -24
- package/src/instance.ts +3 -3
- package/src/report.ts +6 -11
package/dist/auth.d.ts
CHANGED
|
@@ -41,24 +41,18 @@ export default class AuthSDK {
|
|
|
41
41
|
constructor(httpClient: AxiosInstance);
|
|
42
42
|
/**
|
|
43
43
|
* Realiza o login do usuário.
|
|
44
|
-
* @param {string}
|
|
44
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
45
45
|
* @param {string} username Nome de usuário.
|
|
46
46
|
* @param {string} password Senha do usuário.
|
|
47
47
|
* @returns {Promise<DataResponse<LoginData>>} Dados de login.
|
|
48
48
|
*/
|
|
49
|
-
login(
|
|
49
|
+
login(instance: string, username: string, password: string): Promise<DataResponse<LoginData>>;
|
|
50
50
|
/**
|
|
51
51
|
* Busca os dados da sessão.
|
|
52
52
|
* @param {string} authToken Token de autenticação.
|
|
53
53
|
* @returns {Promise<DataResponse<AuthTypes.SessionData>>} Dados da sessão.
|
|
54
54
|
*/
|
|
55
55
|
fetchSessionData(authToken: string): Promise<DataResponse<SessionData>>;
|
|
56
|
-
/**
|
|
57
|
-
* Busca os dados do usuário da sessão.
|
|
58
|
-
* @param {string} authToken Token de autenticação.
|
|
59
|
-
* @returns {Promise<DataResponse<AuthTypes.User>>} Dados do usuário.
|
|
60
|
-
*/
|
|
61
|
-
fetchSessionUser(authToken: string): Promise<DataResponse<User>>;
|
|
62
56
|
/**
|
|
63
57
|
* Verifica se o usuário está autenticado.
|
|
64
58
|
* @param {string} instanceName Nome da instância do Inpulse.
|
package/dist/auth.js
CHANGED
|
@@ -15,13 +15,13 @@ class AuthSDK {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Realiza o login do usuário.
|
|
18
|
-
* @param {string}
|
|
18
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
19
19
|
* @param {string} username Nome de usuário.
|
|
20
20
|
* @param {string} password Senha do usuário.
|
|
21
21
|
* @returns {Promise<DataResponse<LoginData>>} Dados de login.
|
|
22
22
|
*/
|
|
23
|
-
async login(
|
|
24
|
-
const response = await this.httpClient.post(
|
|
23
|
+
async login(instance, username, password) {
|
|
24
|
+
const response = await this.httpClient.post(`/login`, { LOGIN: username, SENHA: password, instance });
|
|
25
25
|
return response.data;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -42,24 +42,6 @@ class AuthSDK {
|
|
|
42
42
|
});
|
|
43
43
|
return response.data;
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Busca os dados do usuário da sessão.
|
|
47
|
-
* @param {string} authToken Token de autenticação.
|
|
48
|
-
* @returns {Promise<DataResponse<AuthTypes.User>>} Dados do usuário.
|
|
49
|
-
*/
|
|
50
|
-
async fetchSessionUser(authToken) {
|
|
51
|
-
const response = await this.httpClient
|
|
52
|
-
.get(`/auth/user`, {
|
|
53
|
-
headers: {
|
|
54
|
-
authorization: authToken,
|
|
55
|
-
},
|
|
56
|
-
})
|
|
57
|
-
.catch((error) => {
|
|
58
|
-
const message = (0, utils_1.sanitizeErrorMessage)(error);
|
|
59
|
-
throw new Error("Failed to fetch session user! " + message);
|
|
60
|
-
});
|
|
61
|
-
return response.data;
|
|
62
|
-
}
|
|
63
45
|
/**
|
|
64
46
|
* Verifica se o usuário está autenticado.
|
|
65
47
|
* @param {string} instanceName Nome da instância do Inpulse.
|
package/dist/instance.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ declare class InstanceSDK {
|
|
|
11
11
|
constructor(httpClient: AxiosInstance);
|
|
12
12
|
/**
|
|
13
13
|
* Executa uma consulta na instância especificada.
|
|
14
|
-
* @param {string}
|
|
14
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
15
15
|
* @param {string} query Consulta a ser executada.
|
|
16
16
|
* @param {any[]} parameters Parâmetros da consulta.
|
|
17
17
|
* @returns {Promise<T>} Resultado da consulta.
|
|
18
18
|
*/
|
|
19
|
-
executeQuery<T>(
|
|
19
|
+
executeQuery<T>(instance: string, query: string, parameters: any[]): Promise<T>;
|
|
20
20
|
}
|
|
21
21
|
export default InstanceSDK;
|
package/dist/instance.js
CHANGED
|
@@ -14,14 +14,14 @@ class InstanceSDK {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Executa uma consulta na instância especificada.
|
|
17
|
-
* @param {string}
|
|
17
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
18
18
|
* @param {string} query Consulta a ser executada.
|
|
19
19
|
* @param {any[]} parameters Parâmetros da consulta.
|
|
20
20
|
* @returns {Promise<T>} Resultado da consulta.
|
|
21
21
|
*/
|
|
22
|
-
async executeQuery(
|
|
22
|
+
async executeQuery(instance, query, parameters) {
|
|
23
23
|
const response = await this.httpClient
|
|
24
|
-
.post(`/${
|
|
24
|
+
.post(`/${instance}/query`, { query, parameters })
|
|
25
25
|
.catch((error) => {
|
|
26
26
|
if (error.response?.data?.message) {
|
|
27
27
|
throw new Error(error.response.data.message);
|
package/dist/report.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export interface ChatsReport {
|
|
|
17
17
|
status: ChatsReportStatus;
|
|
18
18
|
}
|
|
19
19
|
export interface GenerateChatsReportOptions {
|
|
20
|
-
instance: string;
|
|
21
20
|
userId: string;
|
|
22
21
|
format: ChatsReportFormat;
|
|
23
22
|
startDate: string;
|
|
@@ -26,8 +25,8 @@ export interface GenerateChatsReportOptions {
|
|
|
26
25
|
export default class ReportSDK {
|
|
27
26
|
private readonly httpClient;
|
|
28
27
|
constructor(httpClient: AxiosInstance);
|
|
29
|
-
getChatsReports(
|
|
30
|
-
generateChatsReport(
|
|
31
|
-
deleteChatsReport(
|
|
28
|
+
getChatsReports(): Promise<DataResponse<ChatsReport[]>>;
|
|
29
|
+
generateChatsReport(body: GenerateChatsReportOptions): Promise<DataResponse<ChatsReport>>;
|
|
30
|
+
deleteChatsReport(chatsReportId: number): Promise<MessageResponse>;
|
|
32
31
|
setAuth(token: string): void;
|
|
33
32
|
}
|
package/dist/report.js
CHANGED
|
@@ -5,18 +5,18 @@ class ReportSDK {
|
|
|
5
5
|
constructor(httpClient) {
|
|
6
6
|
this.httpClient = httpClient;
|
|
7
7
|
}
|
|
8
|
-
async getChatsReports(
|
|
9
|
-
const url =
|
|
8
|
+
async getChatsReports() {
|
|
9
|
+
const url = `/reports/chats`;
|
|
10
10
|
const response = await this.httpClient.get(url);
|
|
11
11
|
return response.data;
|
|
12
12
|
}
|
|
13
|
-
async generateChatsReport(
|
|
14
|
-
const url =
|
|
13
|
+
async generateChatsReport(body) {
|
|
14
|
+
const url = `/reports/chats`;
|
|
15
15
|
const response = await this.httpClient.post(url, body);
|
|
16
16
|
return response.data;
|
|
17
17
|
}
|
|
18
|
-
async deleteChatsReport(
|
|
19
|
-
const url =
|
|
18
|
+
async deleteChatsReport(chatsReportId) {
|
|
19
|
+
const url = `/reports/chats/${chatsReportId}`;
|
|
20
20
|
const response = await this.httpClient.delete(url);
|
|
21
21
|
return response.data;
|
|
22
22
|
}
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -48,15 +48,15 @@ export default class AuthSDK {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Realiza o login do usuário.
|
|
51
|
-
* @param {string}
|
|
51
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
52
52
|
* @param {string} username Nome de usuário.
|
|
53
53
|
* @param {string} password Senha do usuário.
|
|
54
54
|
* @returns {Promise<DataResponse<LoginData>>} Dados de login.
|
|
55
55
|
*/
|
|
56
|
-
public async login(
|
|
56
|
+
public async login(instance: string, username: string, password: string): Promise<DataResponse<LoginData>> {
|
|
57
57
|
const response = await this.httpClient.post<DataResponse<LoginData>>(
|
|
58
|
-
|
|
59
|
-
{ LOGIN: username, SENHA: password },
|
|
58
|
+
`/login`,
|
|
59
|
+
{ LOGIN: username, SENHA: password, instance },
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
return response.data;
|
|
@@ -82,26 +82,6 @@ export default class AuthSDK {
|
|
|
82
82
|
return response.data;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
/**
|
|
86
|
-
* Busca os dados do usuário da sessão.
|
|
87
|
-
* @param {string} authToken Token de autenticação.
|
|
88
|
-
* @returns {Promise<DataResponse<AuthTypes.User>>} Dados do usuário.
|
|
89
|
-
*/
|
|
90
|
-
public async fetchSessionUser(authToken: string): Promise<DataResponse<User>> {
|
|
91
|
-
const response = await this.httpClient
|
|
92
|
-
.get<DataResponse<User>>(`/auth/user`, {
|
|
93
|
-
headers: {
|
|
94
|
-
authorization: authToken,
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
.catch((error) => {
|
|
98
|
-
const message = sanitizeErrorMessage(error);
|
|
99
|
-
throw new Error("Failed to fetch session user! " + message);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return response.data;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
85
|
/**
|
|
106
86
|
* Verifica se o usuário está autenticado.
|
|
107
87
|
* @param {string} instanceName Nome da instância do Inpulse.
|
package/src/instance.ts
CHANGED
|
@@ -13,18 +13,18 @@ class InstanceSDK {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Executa uma consulta na instância especificada.
|
|
16
|
-
* @param {string}
|
|
16
|
+
* @param {string} instance Nome da instância do Inpulse.
|
|
17
17
|
* @param {string} query Consulta a ser executada.
|
|
18
18
|
* @param {any[]} parameters Parâmetros da consulta.
|
|
19
19
|
* @returns {Promise<T>} Resultado da consulta.
|
|
20
20
|
*/
|
|
21
21
|
public async executeQuery<T>(
|
|
22
|
-
|
|
22
|
+
instance: string,
|
|
23
23
|
query: string,
|
|
24
24
|
parameters: any[],
|
|
25
25
|
): Promise<T> {
|
|
26
26
|
const response = await this.httpClient
|
|
27
|
-
.post<QueryResponse<T>>(`/${
|
|
27
|
+
.post<QueryResponse<T>>(`/${instance}/query`, { query, parameters })
|
|
28
28
|
.catch((error) => {
|
|
29
29
|
if (error.response?.data?.message) {
|
|
30
30
|
throw new Error(error.response.data.message);
|
package/src/report.ts
CHANGED
|
@@ -20,30 +20,25 @@ export interface ChatsReport {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface GenerateChatsReportOptions {
|
|
23
|
-
instance: string;
|
|
24
23
|
userId: string;
|
|
25
24
|
format: ChatsReportFormat;
|
|
26
25
|
startDate: string;
|
|
27
26
|
endDate: string;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
29
|
export default class ReportSDK {
|
|
32
30
|
constructor(private readonly httpClient: AxiosInstance) { }
|
|
33
31
|
|
|
34
|
-
public async getChatsReports(
|
|
35
|
-
const url =
|
|
32
|
+
public async getChatsReports() {
|
|
33
|
+
const url = `/reports/chats`;
|
|
36
34
|
const response =
|
|
37
35
|
await this.httpClient.get<DataResponse<Array<ChatsReport>>>(url);
|
|
38
36
|
|
|
39
37
|
return response.data;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
public async generateChatsReport({
|
|
43
|
-
|
|
44
|
-
...body
|
|
45
|
-
}: GenerateChatsReportOptions) {
|
|
46
|
-
const url = `/${instance}/reports/chats`;
|
|
40
|
+
public async generateChatsReport(body: GenerateChatsReportOptions) {
|
|
41
|
+
const url = `/reports/chats`;
|
|
47
42
|
const response = await this.httpClient.post<DataResponse<ChatsReport>>(
|
|
48
43
|
url,
|
|
49
44
|
body,
|
|
@@ -52,8 +47,8 @@ export default class ReportSDK {
|
|
|
52
47
|
return response.data;
|
|
53
48
|
}
|
|
54
49
|
|
|
55
|
-
public async deleteChatsReport(
|
|
56
|
-
const url =
|
|
50
|
+
public async deleteChatsReport(chatsReportId: number) {
|
|
51
|
+
const url = `/reports/chats/${chatsReportId}`;
|
|
57
52
|
const response = await this.httpClient.delete<MessageResponse>(url);
|
|
58
53
|
|
|
59
54
|
return response.data;
|