@in.pulse-crm/sdk 2.3.3 → 2.3.5

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.
@@ -9,6 +9,14 @@ declare class FilesClient extends ApiClient {
9
9
  * @returns {Promise<Buffer>} Um buffer contendo os dados do arquivo.
10
10
  */
11
11
  fetchFile(id: number): Promise<Buffer>;
12
+ /**
13
+ * Fetches the metadata of a file by its ID.
14
+ *
15
+ * @param id - The unique identifier of the file.
16
+ * @returns A promise that resolves to the file metadata.
17
+ * @throws Will throw an error if the HTTP request fails.
18
+ */
19
+ fetchFileMetadata(id: number): Promise<File>;
12
20
  /**
13
21
  * Obtém a URL de download de um arquivo.
14
22
  * @param {number} id - ID do arquivo.
@@ -17,6 +17,17 @@ class FilesClient extends api_client_1.default {
17
17
  const buffer = Buffer.from(response.data, "binary");
18
18
  return buffer;
19
19
  }
20
+ /**
21
+ * Fetches the metadata of a file by its ID.
22
+ *
23
+ * @param id - The unique identifier of the file.
24
+ * @returns A promise that resolves to the file metadata.
25
+ * @throws Will throw an error if the HTTP request fails.
26
+ */
27
+ async fetchFileMetadata(id) {
28
+ const { data: res } = await this.httpClient.get(`/api/files/${id}/metadata`);
29
+ return res.data;
30
+ }
20
31
  /**
21
32
  * Obtém a URL de download de um arquivo.
22
33
  * @param {number} id - ID do arquivo.
@@ -29,7 +29,7 @@ class WhatsappClient extends api_client_1.default {
29
29
  async markContactMessagesAsRead(contactId) {
30
30
  const url = "/api/whatsapp/messages/mark-as-read";
31
31
  const body = { contactId };
32
- const { data: res } = await this.httpClient.post(url, body);
32
+ const { data: res } = await this.httpClient.patch(url, body);
33
33
  return res.data;
34
34
  }
35
35
  setAuth(token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
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",
@@ -17,6 +17,21 @@ class FilesClient extends ApiClient {
17
17
  return buffer;
18
18
  }
19
19
 
20
+ /**
21
+ * Fetches the metadata of a file by its ID.
22
+ *
23
+ * @param id - The unique identifier of the file.
24
+ * @returns A promise that resolves to the file metadata.
25
+ * @throws Will throw an error if the HTTP request fails.
26
+ */
27
+ public async fetchFileMetadata(id: number): Promise<File> {
28
+ const { data: res } = await this.httpClient.get<DataResponse<File>>(
29
+ `/api/files/${id}/metadata`,
30
+ );
31
+
32
+ return res.data;
33
+ }
34
+
20
35
  /**
21
36
  * Obtém a URL de download de um arquivo.
22
37
  * @param {number} id - ID do arquivo.
@@ -35,7 +50,11 @@ class FilesClient extends ApiClient {
35
50
  const form = new FormData();
36
51
  form.append("instance", props.instance);
37
52
  form.append("dirType", props.dirType);
38
- form.append("file", new Blob([props.buffer], { type: props.mimeType }), props.fileName);
53
+ form.append(
54
+ "file",
55
+ new Blob([props.buffer], { type: props.mimeType }),
56
+ props.fileName,
57
+ );
39
58
 
40
59
  const response = await this.httpClient.post<DataResponse<File>>(
41
60
  "/api/files",
@@ -57,7 +57,7 @@ export default class WhatsappClient extends ApiClient {
57
57
  const url = "/api/whatsapp/messages/mark-as-read";
58
58
  const body = { contactId };
59
59
  const { data: res } =
60
- await this.httpClient.post<MarkChatAsReadResponse>(url, body);
60
+ await this.httpClient.patch<MarkChatAsReadResponse>(url, body);
61
61
 
62
62
  return res.data;
63
63
  }