@in.pulse-crm/sdk 2.8.11 → 2.9.1

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,5 @@
1
- import { AxiosInstance, AxiosError } from 'axios';
2
- import { ErrorResponse } from './types/response.types';
1
+ import { AxiosInstance, AxiosError } from "axios";
2
+ import { ErrorResponse } from "./types/response.types";
3
3
  export default class ApiClient {
4
4
  readonly ax: AxiosInstance;
5
5
  private baseUrl;
@@ -13,7 +13,7 @@ class ApiClient {
13
13
  baseURL: `${this.baseUrl}`,
14
14
  timeout: 60000,
15
15
  headers: {
16
- 'Content-Type': 'application/json',
16
+ "Content-Type": "application/json",
17
17
  },
18
18
  });
19
19
  this.initializeResponseInterceptor();
@@ -23,7 +23,7 @@ class ApiClient {
23
23
  }
24
24
  handleError = (error) => {
25
25
  const errorMessage = error.response?.data?.message || error.message;
26
- return Promise.reject(new Error(errorMessage));
26
+ return Promise.reject(new Error(errorMessage, { cause: error }));
27
27
  };
28
28
  }
29
29
  exports.default = ApiClient;
@@ -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,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.
@@ -9,7 +9,7 @@ export default class WhatsappClient extends ApiClient {
9
9
  markContactMessagesAsRead(contactId: number): Promise<WppMessage[]>;
10
10
  sendMessage(to: string, data: SendMessageData): Promise<WppMessage>;
11
11
  finishChatById(id: number, resultId: number): Promise<void>;
12
- startChatByContactId(contactId: number): Promise<WppChatWithDetailsAndMessages>;
12
+ startChatByContactId(contactId: number, template?: any): Promise<WppChatWithDetailsAndMessages>;
13
13
  getResults(): Promise<{
14
14
  id: number;
15
15
  name: string;
@@ -59,9 +59,9 @@ class WhatsappClient extends api_client_1.default {
59
59
  const body = { resultId };
60
60
  await this.ax.post(url, body);
61
61
  }
62
- async startChatByContactId(contactId) {
62
+ async startChatByContactId(contactId, template) {
63
63
  const url = `/api/whatsapp/chats`;
64
- const body = { contactId };
64
+ const body = { contactId, template };
65
65
  const { data: res } = await this.ax.post(url, body);
66
66
  return res.data;
67
67
  }
@@ -132,7 +132,6 @@ class WhatsappClient extends api_client_1.default {
132
132
  const { data: res } = await this.ax.patch(url);
133
133
  return res.data;
134
134
  }
135
- ;
136
135
  /**
137
136
  * Obtém os detalhes de um agendamento.
138
137
  * @param filters - keys de WppSchedule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.8.11",
3
+ "version": "2.9.1",
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",
package/src/api-client.ts CHANGED
@@ -1,33 +1,32 @@
1
- import axios, { AxiosInstance, AxiosError } from 'axios';
2
- import { ErrorResponse } from './types/response.types';
1
+ import axios, { AxiosInstance, AxiosError } from "axios";
2
+ import { ErrorResponse } from "./types/response.types";
3
3
 
4
4
  export default class ApiClient {
5
- public readonly ax: AxiosInstance;
6
- private baseUrl: string;
5
+ public readonly ax: AxiosInstance;
6
+ private baseUrl: string;
7
7
 
8
- constructor(baseUrl: string) {
9
- this.baseUrl = baseUrl;
8
+ constructor(baseUrl: string) {
9
+ this.baseUrl = baseUrl;
10
10
 
11
- this.ax = axios.create({
12
- baseURL: `${this.baseUrl}`,
13
- timeout: 60000,
14
- headers: {
15
- 'Content-Type': 'application/json',
16
- },
17
- });
11
+ this.ax = axios.create({
12
+ baseURL: `${this.baseUrl}`,
13
+ timeout: 60000,
14
+ headers: {
15
+ "Content-Type": "application/json",
16
+ },
17
+ });
18
18
 
19
- this.initializeResponseInterceptor();
20
- }
19
+ this.initializeResponseInterceptor();
20
+ }
21
21
 
22
- private initializeResponseInterceptor() {
23
- this.ax.interceptors.response.use(
24
- null,
25
- this.handleError
26
- );
27
- }
22
+ private initializeResponseInterceptor() {
23
+ this.ax.interceptors.response.use(null, this.handleError);
24
+ }
28
25
 
29
- protected handleError = (error: AxiosError<ErrorResponse>): Promise<never> => {
30
- const errorMessage = error.response?.data?.message || error.message;
31
- return Promise.reject(new Error(errorMessage));
32
- };
33
- }
26
+ protected handleError = (
27
+ error: AxiosError<ErrorResponse>,
28
+ ): Promise<never> => {
29
+ const errorMessage = error.response?.data?.message || error.message;
30
+ return Promise.reject(new Error(errorMessage, { cause: error }));
31
+ };
32
+ }
@@ -107,9 +107,9 @@ export default class WhatsappClient extends ApiClient {
107
107
  await this.ax.post<MessageResponse>(url, body);
108
108
  }
109
109
 
110
- public async startChatByContactId(contactId: number) {
110
+ public async startChatByContactId(contactId: number, template?: any) {
111
111
  const url = `/api/whatsapp/chats`;
112
- const body = { contactId };
112
+ const body = { contactId, template };
113
113
 
114
114
  const { data: res } = await this.ax.post<
115
115
  DataResponse<WppChatWithDetailsAndMessages>
@@ -216,19 +216,17 @@ export default class WhatsappClient extends ApiClient {
216
216
  }
217
217
  public async getNotifications() {
218
218
  const url = `/api/whatsapp/notifications`;
219
- const { data: res } =
220
- await this.ax.get<DataResponse<any>>(url);
219
+ const { data: res } = await this.ax.get<DataResponse<any>>(url);
221
220
 
222
221
  return res.data;
223
222
  }
224
223
 
225
- public async markAllAsReadNotification () {
226
- const url = `/api/whatsapp/notifications/mark-all-read`;
227
- const { data: res } =
228
- await this.ax.patch<DataResponse<any>>(url);
224
+ public async markAllAsReadNotification() {
225
+ const url = `/api/whatsapp/notifications/mark-all-read`;
226
+ const { data: res } = await this.ax.patch<DataResponse<any>>(url);
229
227
 
230
228
  return res.data;
231
- };
229
+ }
232
230
 
233
231
  /**
234
232
  * Obtém os detalhes de um agendamento.
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
  }