@in.pulse-crm/sdk 2.5.5 → 2.5.13

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,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import ApiClient from "./api-client";
2
4
  import { File, UploadFileOptions } from "./types/files.types";
3
5
  declare class FilesClient extends ApiClient {
@@ -1,5 +1,5 @@
1
1
  import ApiClient from "./api-client";
2
- import { InternalChat, InternalMessage, InternalSendMessageData } from "./types/internal.types";
2
+ import { InternalChat, InternalGroup, InternalMessage, InternalSendMessageData } from "./types/internal.types";
3
3
  export default class InternalChatClient extends ApiClient {
4
4
  createInternalChat(participants: number[], isGroup?: boolean, groupName?: string): Promise<InternalChat>;
5
5
  getInternalChatsBySession(token?: string | null): Promise<{
@@ -8,15 +8,11 @@ export default class InternalChatClient extends ApiClient {
8
8
  })[];
9
9
  messages: InternalMessage[];
10
10
  }>;
11
- sendMessageToChat(data: InternalSendMessageData): Promise<void>;
12
- updateGroupMembers(groupId: number, { name, participants }: {
11
+ getInternalGroups(): Promise<InternalGroup[]>;
12
+ sendMessageToInternalChat(data: InternalSendMessageData): Promise<void>;
13
+ updateInternalGroup(groupId: number, { name, participants }: {
13
14
  name: string;
14
15
  participants: number[];
15
- }): Promise<any>;
16
- startChatByContactId(contactId: number): Promise<{
17
- chat: InternalChat & {
18
- messages: InternalMessage[];
19
- };
20
- }>;
16
+ }): Promise<InternalGroup>;
21
17
  setAuth(token: string): void;
22
18
  }
@@ -21,7 +21,12 @@ class InternalChatClient extends api_client_1.default {
21
21
  });
22
22
  return res.data;
23
23
  }
24
- async sendMessageToChat(data) {
24
+ async getInternalGroups() {
25
+ const url = `/api/internal/groups`;
26
+ const { data: res } = await this.httpClient.get(url);
27
+ return res.data;
28
+ }
29
+ async sendMessageToInternalChat(data) {
25
30
  const url = `/api/internal/chats/${data.chatId}/messages`;
26
31
  const formData = new form_data_1.default();
27
32
  formData.append("chatId", data.chatId.toString());
@@ -37,14 +42,11 @@ class InternalChatClient extends api_client_1.default {
37
42
  },
38
43
  });
39
44
  }
40
- async updateGroupMembers(groupId, { name, participants }) {
41
- const { data: res } = await this.httpClient.put(`/api/internal/chats/group/${groupId}/members`, { name, participants });
42
- return res.data;
43
- }
44
- async startChatByContactId(contactId) {
45
- const url = `/api/internal/chats`;
46
- const body = { contactId };
47
- const { data: res } = await this.httpClient.post(url, body);
45
+ async updateInternalGroup(groupId, { name, participants }) {
46
+ const { data: res } = await this.httpClient.put(`/api/internal/groups/${groupId}`, {
47
+ name,
48
+ participants,
49
+ });
48
50
  return res.data;
49
51
  }
50
52
  setAuth(token) {
@@ -63,5 +63,5 @@ export interface Customer {
63
63
  CODIGOPRINCIPAL: number;
64
64
  SETOR: number;
65
65
  }
66
- export type CreateCustomerDTO = Pick<Customer, "RAZAO" | "FANTASIA" | "CPF_CNPJ" | "PESSOA" | "CIDADE" | "ATIVO" | "COD_ERP">;
66
+ export type CreateCustomerDTO = Pick<Customer, "RAZAO" | "CPF_CNPJ">;
67
67
  export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  export interface UploadFileOptions {
2
4
  /**
3
5
  * Nome da instância onde o arquivo está armazenado.
@@ -27,6 +27,25 @@ export interface InternalChat {
27
27
  groupName: string | null;
28
28
  groupDescription: string | null;
29
29
  }
30
+ export interface InternalGroup {
31
+ id: number;
32
+ instance: string;
33
+ creatorId: number | null;
34
+ sectorId: number | null;
35
+ isFinished: true;
36
+ startedAt: Date;
37
+ finishedAt: Date | null;
38
+ finishedBy: number | null;
39
+ isGroup: boolean;
40
+ groupName: string | null;
41
+ groupDescription: string | null;
42
+ participants: {
43
+ userId: number;
44
+ joinedAt: Date;
45
+ lastReadAt: Date | null;
46
+ internalChatId: number;
47
+ }[];
48
+ }
30
49
  export interface InternalChatMember {
31
50
  internalchatId: number;
32
51
  internalcontactId: number;
@@ -7,7 +7,7 @@ const api_client_1 = __importDefault(require("./api-client"));
7
7
  class WalletsClient extends api_client_1.default {
8
8
  async createWallet(instance, name) {
9
9
  try {
10
- const response = await this.httpClient.post(`/api/wallets`, { data: { instance, name } });
10
+ const response = await this.httpClient.post(`/api/wallets`, { instance, name });
11
11
  return response.data.data;
12
12
  }
13
13
  catch (error) {
@@ -23,6 +23,6 @@ export default class WhatsappClient extends ApiClient {
23
23
  name: string;
24
24
  }[]>;
25
25
  setAuth(token: string): void;
26
- getChatsMonitor(token?: string | null): Promise<MonitorChat[]>;
26
+ getChatsMonitor(): Promise<MonitorChat[]>;
27
27
  transferAttendance(id: number, userId: number): Promise<void>;
28
28
  }
@@ -105,14 +105,9 @@ class WhatsappClient extends api_client_1.default {
105
105
  this.httpClient.defaults.headers.common["Authorization"] =
106
106
  `Bearer ${token}`;
107
107
  }
108
- async getChatsMonitor(token = null) {
109
- const headers = token
110
- ? { Authorization: `Bearer ${token}` }
111
- : undefined;
108
+ async getChatsMonitor() {
112
109
  const url = `/api/whatsapp/session/monitor`;
113
- const { data: res } = await this.httpClient.get(url, {
114
- headers,
115
- });
110
+ const { data: res } = await this.httpClient.get(url);
116
111
  return res.data;
117
112
  }
118
113
  async transferAttendance(id, userId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.5.5",
3
+ "version": "2.5.13",
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",
@@ -2,6 +2,7 @@ import ApiClient from "./api-client";
2
2
  import { DataResponse } from "./types/response.types";
3
3
  import {
4
4
  InternalChat,
5
+ InternalGroup,
5
6
  InternalMessage,
6
7
  InternalSendMessageData,
7
8
  } from "./types/internal.types";
@@ -29,6 +30,7 @@ export default class InternalChatClient extends ApiClient {
29
30
 
30
31
  return res.data;
31
32
  }
33
+
32
34
  public async getInternalChatsBySession(token: string | null = null) {
33
35
  const url = `/api/internal/session/chats`;
34
36
 
@@ -43,7 +45,15 @@ export default class InternalChatClient extends ApiClient {
43
45
  return res.data;
44
46
  }
45
47
 
46
- public async sendMessageToChat(data: InternalSendMessageData) {
48
+ public async getInternalGroups() {
49
+ const url = `/api/internal/groups`;
50
+ const { data: res } =
51
+ await this.httpClient.get<DataResponse<InternalGroup[]>>(url);
52
+
53
+ return res.data;
54
+ }
55
+
56
+ public async sendMessageToInternalChat(data: InternalSendMessageData) {
47
57
  const url = `/api/internal/chats/${data.chatId}/messages`;
48
58
  const formData = new FormData();
49
59
 
@@ -66,26 +76,16 @@ export default class InternalChatClient extends ApiClient {
66
76
  );
67
77
  }
68
78
 
69
- public async updateGroupMembers(
79
+ public async updateInternalGroup(
70
80
  groupId: number,
71
81
  { name, participants }: { name: string; participants: number[] },
72
82
  ) {
73
- const { data: res } = await this.httpClient.put<DataResponse<any>>(
74
- `/api/internal/chats/group/${groupId}/members`,
75
- { name, participants },
76
- );
77
- return res.data;
78
- }
79
-
80
- public async startChatByContactId(contactId: number) {
81
- const url = `/api/internal/chats`;
82
- const body = { contactId };
83
-
84
- const { data: res } = await this.httpClient.post<StartChatResponse>(
85
- url,
86
- body,
87
- );
88
-
83
+ const { data: res } = await this.httpClient.put<
84
+ DataResponse<InternalGroup>
85
+ >(`/api/internal/groups/${groupId}`, {
86
+ name,
87
+ participants,
88
+ });
89
89
  return res.data;
90
90
  }
91
91
 
@@ -67,11 +67,6 @@ export interface Customer {
67
67
  export type CreateCustomerDTO = Pick<
68
68
  Customer,
69
69
  | "RAZAO"
70
- | "FANTASIA"
71
70
  | "CPF_CNPJ"
72
- | "PESSOA"
73
- | "CIDADE"
74
- | "ATIVO"
75
- | "COD_ERP"
76
71
  >;
77
72
  export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
@@ -30,6 +30,26 @@ export interface InternalChat {
30
30
  groupDescription: string | null;
31
31
  }
32
32
 
33
+ export interface InternalGroup {
34
+ id: number;
35
+ instance: string;
36
+ creatorId: number | null;
37
+ sectorId: number | null;
38
+ isFinished: true;
39
+ startedAt: Date;
40
+ finishedAt: Date | null;
41
+ finishedBy: number | null;
42
+ isGroup: boolean;
43
+ groupName: string | null;
44
+ groupDescription: string | null;
45
+ participants: {
46
+ userId: number;
47
+ joinedAt: Date;
48
+ lastReadAt: Date | null;
49
+ internalChatId: number;
50
+ }[];
51
+ }
52
+
33
53
  export interface InternalChatMember {
34
54
  internalchatId: number;
35
55
  internalcontactId: number;
@@ -8,7 +8,7 @@ export default class WalletsClient extends ApiClient {
8
8
  try {
9
9
  const response = await this.httpClient.post<DataResponse<Wallet>>(
10
10
  `/api/wallets`,
11
- { data: { instance, name } }
11
+ { instance, name }
12
12
  );
13
13
  return response.data.data
14
14
  } catch (error) {
@@ -188,16 +188,10 @@ export default class WhatsappClient extends ApiClient {
188
188
  `Bearer ${token}`;
189
189
  }
190
190
  public async getChatsMonitor(
191
- token: string | null = null,
192
191
  ) {
193
- const headers = token
194
- ? { Authorization: `Bearer ${token}` }
195
- : undefined;
196
192
  const url = `/api/whatsapp/session/monitor`;
197
193
 
198
- const { data: res } = await this.httpClient.get<GetMonitorChatsResponse>(url, {
199
- headers,
200
- });
194
+ const { data: res } = await this.httpClient.get<GetMonitorChatsResponse>(url,);
201
195
 
202
196
  return res.data;
203
197
  }
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
  }