@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 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 { CreateCustomerDTO, UpdateCustomerDTO } from "./types/customers.types";
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
- getAllCustomers(filters: Record<string, string>): Promise<any>;
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.
@@ -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 getAllCustomers(filters) {
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"] = `Bearer ${token}`;
57
+ this.httpClient.defaults.headers.common["Authorization"] =
58
+ `Bearer ${token}`;
58
59
  }
59
60
  }
60
61
  exports.default = CustomersClient;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import ApiClient from "./api-client";
4
2
  import { File, UploadFileOptions } from "./types/files.types";
5
3
  declare class FilesClient extends ApiClient {
@@ -2,8 +2,8 @@ export interface Customer {
2
2
  CODIGO: number;
3
3
  RAZAO: string;
4
4
  FANTASIA: string;
5
- PESSOA: 'FIS' | 'JUR' | null;
6
- ATIVO: 'SIM' | 'NAO' | null;
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: 'SIM' | 'NAO' | null;
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: 'CADASTRO' | 'ATUALIZAÇÃO' | null;
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: 'S' | 'N' | null;
62
- POSSUI_VENDA: 'S' | 'N' | null;
61
+ POSSUI_ORCAMENTO: "S" | "N" | null;
62
+ POSSUI_VENDA: "S" | "N" | null;
63
63
  CODIGOPRINCIPAL: number;
64
64
  SETOR: number;
65
65
  }
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  export interface UploadFileOptions {
4
2
  /**
5
3
  * Nome da instância onde o arquivo está armazenado.
@@ -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";
@@ -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);
@@ -0,0 +1,5 @@
1
+ export type RequestFilters<T> = {
2
+ page?: string;
3
+ perPage?: string;
4
+ sortBy?: keyof T;
5
+ } & Partial<Record<keyof T, string>>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
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",
@@ -1,66 +1,77 @@
1
1
  import ApiClient from "./api-client";
2
- import { CreateCustomerDTO, UpdateCustomerDTO } from "./types/customers.types";
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
- * Cria um novo cliente.
7
- * @param data - Os dados do cliente a serem criados.
8
- * @returns Uma Promise que resolve para o cliente criado.
9
- */
10
- public async createCustomer(data: CreateCustomerDTO) {
11
- const response = await this.httpClient.post(`/api/customers`, data);
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
- return response.data;
14
- }
18
+ return response.data;
19
+ }
15
20
 
16
- /**
17
- * Obtém um cliente pelo ID.
18
- * @param customerId - O ID do cliente a ser obtido.
19
- * @returns Uma Promise que resolve para o cliente obtido.
20
- */
21
- public async getCustomerById(customerId: number) {
22
- const response = await this.httpClient.get(`/api/customers/${customerId}`);
23
- return response.data;
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
- * Atualiza um cliente existente.
28
- * @param customerId - O ID do cliente a ser atualizado.
29
- * @param data - Os dados atualizados do cliente.
30
- * @returns Uma Promise que resolve para o cliente atualizado.
31
- */
32
- public async updateCustomer(customerId: number, data: UpdateCustomerDTO) {
33
- const response = await this.httpClient.patch(`/api/customers/${customerId}`, data);
34
- return response.data;
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
- * Obtém todos os clientes.
39
- *
40
- * @param filters - Filtros opcionais para a busca de clientes.
41
- * @todo Implementar tipagem para os filtros.
42
- * @returns Uma Promise que resolve para uma lista de clientes.
43
- */
44
- public async getAllCustomers(filters: Record<string, string>) {
45
- let baseUrl = `/api/customers`;
46
- const params = new URLSearchParams(filters);
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
- if (params.toString()) {
49
- baseUrl += `?${params.toString()}`;
50
- }
58
+ if (params.toString()) {
59
+ baseUrl += `?${params.toString()}`;
60
+ }
51
61
 
52
- const response = await this.httpClient.get(`/api/customers`);
62
+ const response = await this.httpClient.get(`/api/customers`);
53
63
 
54
- return response.data;
55
- }
64
+ return response.data;
65
+ }
56
66
 
57
- /**
58
- * Define o token de autenticação para as requisições.
59
- * @param token - O token de autenticação a ser definido.
60
- */
61
- public setAuth(token: string) {
62
- this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
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
- 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;
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<Customer, "RAZAO" | "FANTASIA" | "CPF_CNPJ" | "PESSOA" | "CIDADE" | "ESTADO" | "COD_ERP">;
68
- export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
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>;
@@ -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
-
@@ -0,0 +1,5 @@
1
+ export type RequestFilters<T> = {
2
+ page?: string;
3
+ perPage?: string;
4
+ sortBy?: keyof T;
5
+ } & Partial<Record<keyof T, string>>;
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
  }