@in.pulse-crm/sdk 2.0.7 → 2.0.9
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/.prettierrc +4 -4
- package/dist/customers.client.d.ts +3 -2
- package/dist/customers.client.js +3 -2
- package/dist/files.client.d.ts +0 -2
- package/dist/types/customers.types.d.ts +6 -6
- package/dist/types/files.types.d.ts +0 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/request.types.d.ts +5 -0
- package/dist/types/request.types.js +2 -0
- package/package.json +1 -1
- package/src/customers.client.ts +64 -53
- package/src/types/customers.types.ts +74 -65
- package/src/types/index.ts +1 -1
- package/src/types/request.types.ts +5 -0
- package/tsconfig.json +16 -16
package/.prettierrc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"tabWidth": 4,
|
|
3
|
-
"useTabs": true
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"useTabs": true
|
|
4
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import {
|
|
2
|
+
import { RequestFilters } from "./types";
|
|
3
|
+
import { CreateCustomerDTO, Customer, UpdateCustomerDTO } from "./types/customers.types";
|
|
3
4
|
declare class CustomersClient extends ApiClient {
|
|
4
5
|
/**
|
|
5
6
|
* Cria um novo cliente.
|
|
@@ -27,7 +28,7 @@ declare class CustomersClient extends ApiClient {
|
|
|
27
28
|
* @todo Implementar tipagem para os filtros.
|
|
28
29
|
* @returns Uma Promise que resolve para uma lista de clientes.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
getCustomers(filters?: RequestFilters<Customer>): Promise<any>;
|
|
31
32
|
/**
|
|
32
33
|
* Define o token de autenticação para as requisições.
|
|
33
34
|
* @param token - O token de autenticação a ser definido.
|
package/dist/customers.client.js
CHANGED
|
@@ -40,7 +40,7 @@ class CustomersClient extends api_client_1.default {
|
|
|
40
40
|
* @todo Implementar tipagem para os filtros.
|
|
41
41
|
* @returns Uma Promise que resolve para uma lista de clientes.
|
|
42
42
|
*/
|
|
43
|
-
async
|
|
43
|
+
async getCustomers(filters) {
|
|
44
44
|
let baseUrl = `/api/customers`;
|
|
45
45
|
const params = new URLSearchParams(filters);
|
|
46
46
|
if (params.toString()) {
|
|
@@ -54,7 +54,8 @@ class CustomersClient extends api_client_1.default {
|
|
|
54
54
|
* @param token - O token de autenticação a ser definido.
|
|
55
55
|
*/
|
|
56
56
|
setAuth(token) {
|
|
57
|
-
this.httpClient.defaults.headers.common["Authorization"] =
|
|
57
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
58
|
+
`Bearer ${token}`;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
exports.default = CustomersClient;
|
package/dist/files.client.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export interface Customer {
|
|
|
2
2
|
CODIGO: number;
|
|
3
3
|
RAZAO: string;
|
|
4
4
|
FANTASIA: string;
|
|
5
|
-
PESSOA:
|
|
6
|
-
ATIVO:
|
|
5
|
+
PESSOA: "FIS" | "JUR" | null;
|
|
6
|
+
ATIVO: "SIM" | "NAO" | null;
|
|
7
7
|
CPF_CNPJ: string;
|
|
8
8
|
IE_RG: string;
|
|
9
9
|
GRUPO: number;
|
|
@@ -35,7 +35,7 @@ export interface Customer {
|
|
|
35
35
|
OPERADOR: number;
|
|
36
36
|
COD_MIDIA: number;
|
|
37
37
|
COD_ERP: string;
|
|
38
|
-
BLOCK_COMPRAS:
|
|
38
|
+
BLOCK_COMPRAS: "SIM" | "NAO" | null;
|
|
39
39
|
COD_UNIDADE: number;
|
|
40
40
|
SALDO_DISPONIVEL: number;
|
|
41
41
|
SALDO_LIMITE: number;
|
|
@@ -47,7 +47,7 @@ export interface Customer {
|
|
|
47
47
|
COD_CAMPANHA: number;
|
|
48
48
|
COD_RESULTADO: number;
|
|
49
49
|
CONTATO_MAIL: string;
|
|
50
|
-
ATUALIZADOR:
|
|
50
|
+
ATUALIZADOR: "CADASTRO" | "ATUALIZAÇÃO" | null;
|
|
51
51
|
OPERADOR_LOGIN: string;
|
|
52
52
|
OBS_FONE1: string;
|
|
53
53
|
OBS_FONE2: string;
|
|
@@ -58,8 +58,8 @@ export interface Customer {
|
|
|
58
58
|
VENCIMENTO_LIMITE_CREDITO: Date;
|
|
59
59
|
PERIODO_RECOMPRA: number;
|
|
60
60
|
DT_ULTIMO_ORCAMENTO_VENDA: Date;
|
|
61
|
-
POSSUI_ORCAMENTO:
|
|
62
|
-
POSSUI_VENDA:
|
|
61
|
+
POSSUI_ORCAMENTO: "S" | "N" | null;
|
|
62
|
+
POSSUI_VENDA: "S" | "N" | null;
|
|
63
63
|
CODIGOPRINCIPAL: number;
|
|
64
64
|
SETOR: number;
|
|
65
65
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./auth.types";
|
|
|
2
2
|
export * from "./customers.types";
|
|
3
3
|
export * from "./files.types";
|
|
4
4
|
export * from "./reports.types";
|
|
5
|
+
export * from "./request.types";
|
|
5
6
|
export * from "./response.types";
|
|
6
7
|
export * from "./socket-events.types";
|
|
7
8
|
export * from "./socket-rooms.types";
|
package/dist/types/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./auth.types"), exports);
|
|
|
18
18
|
__exportStar(require("./customers.types"), exports);
|
|
19
19
|
__exportStar(require("./files.types"), exports);
|
|
20
20
|
__exportStar(require("./reports.types"), exports);
|
|
21
|
+
__exportStar(require("./request.types"), exports);
|
|
21
22
|
__exportStar(require("./response.types"), exports);
|
|
22
23
|
__exportStar(require("./socket-events.types"), exports);
|
|
23
24
|
__exportStar(require("./socket-rooms.types"), exports);
|
package/package.json
CHANGED
package/src/customers.client.ts
CHANGED
|
@@ -1,66 +1,77 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import {
|
|
2
|
+
import { RequestFilters } from "./types";
|
|
3
|
+
import {
|
|
4
|
+
CreateCustomerDTO,
|
|
5
|
+
Customer,
|
|
6
|
+
UpdateCustomerDTO,
|
|
7
|
+
} from "./types/customers.types";
|
|
3
8
|
|
|
4
9
|
class CustomersClient extends ApiClient {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Cria um novo cliente.
|
|
12
|
+
* @param data - Os dados do cliente a serem criados.
|
|
13
|
+
* @returns Uma Promise que resolve para o cliente criado.
|
|
14
|
+
*/
|
|
15
|
+
public async createCustomer(data: CreateCustomerDTO) {
|
|
16
|
+
const response = await this.httpClient.post(`/api/customers`, data);
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Obtém um cliente pelo ID.
|
|
23
|
+
* @param customerId - O ID do cliente a ser obtido.
|
|
24
|
+
* @returns Uma Promise que resolve para o cliente obtido.
|
|
25
|
+
*/
|
|
26
|
+
public async getCustomerById(customerId: number) {
|
|
27
|
+
const response = await this.httpClient.get(
|
|
28
|
+
`/api/customers/${customerId}`,
|
|
29
|
+
);
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Atualiza um cliente existente.
|
|
35
|
+
* @param customerId - O ID do cliente a ser atualizado.
|
|
36
|
+
* @param data - Os dados atualizados do cliente.
|
|
37
|
+
* @returns Uma Promise que resolve para o cliente atualizado.
|
|
38
|
+
*/
|
|
39
|
+
public async updateCustomer(customerId: number, data: UpdateCustomerDTO) {
|
|
40
|
+
const response = await this.httpClient.patch(
|
|
41
|
+
`/api/customers/${customerId}`,
|
|
42
|
+
data,
|
|
43
|
+
);
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Obtém todos os clientes.
|
|
49
|
+
*
|
|
50
|
+
* @param filters - Filtros opcionais para a busca de clientes.
|
|
51
|
+
* @todo Implementar tipagem para os filtros.
|
|
52
|
+
* @returns Uma Promise que resolve para uma lista de clientes.
|
|
53
|
+
*/
|
|
54
|
+
public async getCustomers(filters?: RequestFilters<Customer>) {
|
|
55
|
+
let baseUrl = `/api/customers`;
|
|
56
|
+
const params = new URLSearchParams(filters);
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
if (params.toString()) {
|
|
59
|
+
baseUrl += `?${params.toString()}`;
|
|
60
|
+
}
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
const response = await this.httpClient.get(`/api/customers`);
|
|
53
63
|
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
return response.data;
|
|
65
|
+
}
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Define o token de autenticação para as requisições.
|
|
69
|
+
* @param token - O token de autenticação a ser definido.
|
|
70
|
+
*/
|
|
71
|
+
public setAuth(token: string) {
|
|
72
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
73
|
+
`Bearer ${token}`;
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
export default CustomersClient;
|
|
77
|
+
export default CustomersClient;
|
|
@@ -1,68 +1,77 @@
|
|
|
1
1
|
export interface Customer {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
CODIGO: number;
|
|
3
|
+
RAZAO: string;
|
|
4
|
+
FANTASIA: string;
|
|
5
|
+
PESSOA: "FIS" | "JUR" | null;
|
|
6
|
+
ATIVO: "SIM" | "NAO" | null;
|
|
7
|
+
CPF_CNPJ: string;
|
|
8
|
+
IE_RG: string;
|
|
9
|
+
GRUPO: number;
|
|
10
|
+
END_RUA: string;
|
|
11
|
+
CIDADE: string;
|
|
12
|
+
BAIRRO: string;
|
|
13
|
+
ESTADO: string;
|
|
14
|
+
CEP: string;
|
|
15
|
+
COMPLEMENTO: string;
|
|
16
|
+
AREA1: number;
|
|
17
|
+
AREA2: number;
|
|
18
|
+
AREA3: number;
|
|
19
|
+
AREAFAX: number;
|
|
20
|
+
FONE1: string;
|
|
21
|
+
FONE2: string;
|
|
22
|
+
FONE3: string;
|
|
23
|
+
FAX: string;
|
|
24
|
+
DESC_FONE1: string;
|
|
25
|
+
DESC_FONE2: string;
|
|
26
|
+
DESC_FONE3: string;
|
|
27
|
+
DESCFAX: string;
|
|
28
|
+
EMAIL: string;
|
|
29
|
+
WEBSITE: string;
|
|
30
|
+
DATACAD: Date;
|
|
31
|
+
STATUS_CAD: string;
|
|
32
|
+
OBS_ADMIN: string;
|
|
33
|
+
OBS_OPERADOR: string;
|
|
34
|
+
ORIGEM: number;
|
|
35
|
+
OPERADOR: number;
|
|
36
|
+
COD_MIDIA: number;
|
|
37
|
+
COD_ERP: string;
|
|
38
|
+
BLOCK_COMPRAS: "SIM" | "NAO" | null;
|
|
39
|
+
COD_UNIDADE: number;
|
|
40
|
+
SALDO_DISPONIVEL: number;
|
|
41
|
+
SALDO_LIMITE: number;
|
|
42
|
+
POTENCIAL: number;
|
|
43
|
+
DATA_ULT_COMPRA: Date;
|
|
44
|
+
SEGMENTO: number;
|
|
45
|
+
ULTI_RESULTADO: Date;
|
|
46
|
+
DT_AGENDAMENTO: Date;
|
|
47
|
+
COD_CAMPANHA: number;
|
|
48
|
+
COD_RESULTADO: number;
|
|
49
|
+
CONTATO_MAIL: string;
|
|
50
|
+
ATUALIZADOR: "CADASTRO" | "ATUALIZAÇÃO" | null;
|
|
51
|
+
OPERADOR_LOGIN: string;
|
|
52
|
+
OBS_FONE1: string;
|
|
53
|
+
OBS_FONE2: string;
|
|
54
|
+
OBS_FONE3: string;
|
|
55
|
+
NR_FUNCIONARIOS: number;
|
|
56
|
+
EMAIL2: string;
|
|
57
|
+
OBS_CLIENTES: string;
|
|
58
|
+
VENCIMENTO_LIMITE_CREDITO: Date;
|
|
59
|
+
PERIODO_RECOMPRA: number;
|
|
60
|
+
DT_ULTIMO_ORCAMENTO_VENDA: Date;
|
|
61
|
+
POSSUI_ORCAMENTO: "S" | "N" | null;
|
|
62
|
+
POSSUI_VENDA: "S" | "N" | null;
|
|
63
|
+
CODIGOPRINCIPAL: number;
|
|
64
|
+
SETOR: number;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export type CreateCustomerDTO = Pick<
|
|
68
|
-
|
|
67
|
+
export type CreateCustomerDTO = Pick<
|
|
68
|
+
Customer,
|
|
69
|
+
| "RAZAO"
|
|
70
|
+
| "FANTASIA"
|
|
71
|
+
| "CPF_CNPJ"
|
|
72
|
+
| "PESSOA"
|
|
73
|
+
| "CIDADE"
|
|
74
|
+
| "ESTADO"
|
|
75
|
+
| "COD_ERP"
|
|
76
|
+
>;
|
|
77
|
+
export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
|
package/src/types/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ export * from "./auth.types";
|
|
|
2
2
|
export * from "./customers.types";
|
|
3
3
|
export * from "./files.types";
|
|
4
4
|
export * from "./reports.types";
|
|
5
|
+
export * from "./request.types";
|
|
5
6
|
export * from "./response.types";
|
|
6
7
|
export * from "./socket-events.types";
|
|
7
8
|
export * from "./socket-rooms.types";
|
|
8
9
|
export * from "./user.types";
|
|
9
|
-
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
-
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
-
"noUnusedLocals": false,
|
|
10
|
-
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
-
"declaration": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src/index.ts",
|
|
15
|
-
"src/**/*.{ts}"
|
|
16
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
6
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
7
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
8
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
9
|
+
"noUnusedLocals": false,
|
|
10
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src/index.ts",
|
|
15
|
+
"src/**/*.{ts}"
|
|
16
|
+
]
|
|
17
17
|
}
|