@in.pulse-crm/sdk 2.7.0 → 2.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.7.0",
3
+ "version": "2.7.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",
@@ -0,0 +1,71 @@
1
+ import ApiClient from "./api-client";
2
+ import { DataResponse } from "./types/response.types";
3
+ import {
4
+ ReadyMessage,
5
+ } from "./types/ready-messages.types";
6
+ import FormData from "form-data";
7
+
8
+ export default class ReadyMessageClient extends ApiClient {
9
+ public async createReadyMessage(
10
+ File: File | null = null,
11
+ TITULO: string| null = null,
12
+ TEXTO_MENSAGEM: string| null = null,
13
+ ) {
14
+ const form = new FormData();
15
+
16
+ if (File) {
17
+ form.append("file", File);
18
+ }
19
+
20
+ form.append(
21
+ "data",
22
+ JSON.stringify({ TITULO, TEXTO_MENSAGEM }),
23
+ );
24
+
25
+ const { data: res } = await this.httpClient.post<
26
+ DataResponse<ReadyMessage>
27
+ >(`/api/ready-messages`, form, {
28
+ headers: {
29
+ "Content-Type": "multipart/form-data",
30
+ },
31
+ });
32
+
33
+ return res.data;
34
+ }
35
+
36
+ public async deleteReadyMessage(chatId: number) {
37
+ const url = `/api/ready-messages/${chatId}`;
38
+ await this.httpClient.delete<DataResponse<ReadyMessage>>(url);
39
+ }
40
+
41
+ public async getReadyMessages() {
42
+ const url = `/api/ready-messages`;
43
+ const { data: res } =
44
+ await this.httpClient.get<DataResponse<ReadyMessage[]>>(url);
45
+
46
+ return res.data;
47
+ }
48
+
49
+ public async updateReadyMessage(id:number, ReadyMessage: ReadyMessage, file: File) {
50
+ const formData = new FormData();
51
+ formData.append("file", file);
52
+ formData.append(
53
+ "data",
54
+ JSON.stringify(ReadyMessage),
55
+ );
56
+
57
+ const { data: res } = await this.httpClient.put<
58
+ DataResponse<ReadyMessage>
59
+ >(`/api/ready-messages/${id}`, formData, {
60
+ headers: {
61
+ "Content-Type": "multipart/form-data",
62
+ },
63
+ });
64
+ return res.data;
65
+ }
66
+
67
+ public setAuth(token: string) {
68
+ this.httpClient.defaults.headers.common["Authorization"] =
69
+ `Bearer ${token}`;
70
+ }
71
+ }
@@ -0,0 +1,10 @@
1
+ export interface ReadyMessage {
2
+ CODIGO: number;
3
+ APENAS_ADMIN: boolean;
4
+ TITULO: string;
5
+ TEXTO_MENSAGEM: string;
6
+ ARQUIVO_CODIGO: number;
7
+ ARQUIVO_NOME: string;
8
+ ARQUIVO_TIPO: string;
9
+ }
10
+