@in.pulse-crm/sdk 2.2.4 → 2.2.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/types/whatsapp.types.d.ts +66 -9
- package/dist/types/whatsapp.types.js +24 -0
- package/dist/whatsapp.client.d.ts +24 -0
- package/dist/whatsapp.client.js +25 -0
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/types/whatsapp.types.ts +80 -22
- package/src/whatsapp.client.ts +49 -0
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { default as ReportsClient } from "./reports.client";
|
|
|
7
7
|
export { default as SocketServerClient } from "./socket-server.client";
|
|
8
8
|
export { default as SocketClient } from "./socket.client";
|
|
9
9
|
export { default as UsersClient } from "./users.client";
|
|
10
|
+
export { default as WhatsappClient } from "./whatsapp.client";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
|
|
20
|
+
exports.WhatsappClient = exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
22
|
var auth_client_1 = require("./auth.client");
|
|
23
23
|
Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return __importDefault(auth_client_1).default; } });
|
|
@@ -35,3 +35,5 @@ var socket_client_1 = require("./socket.client");
|
|
|
35
35
|
Object.defineProperty(exports, "SocketClient", { enumerable: true, get: function () { return __importDefault(socket_client_1).default; } });
|
|
36
36
|
var users_client_1 = require("./users.client");
|
|
37
37
|
Object.defineProperty(exports, "UsersClient", { enumerable: true, get: function () { return __importDefault(users_client_1).default; } });
|
|
38
|
+
var whatsapp_client_1 = require("./whatsapp.client");
|
|
39
|
+
Object.defineProperty(exports, "WhatsappClient", { enumerable: true, get: function () { return __importDefault(whatsapp_client_1).default; } });
|
|
@@ -1,17 +1,74 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface WppContact {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
phone: string;
|
|
5
|
+
customerId?: number;
|
|
6
|
+
instance: string;
|
|
7
|
+
isBlocked: boolean;
|
|
8
|
+
isOnlyAdmin: boolean;
|
|
9
|
+
}
|
|
2
10
|
export interface WppMessage {
|
|
3
|
-
|
|
4
|
-
|
|
11
|
+
id: number;
|
|
12
|
+
instance: string;
|
|
13
|
+
wwebjsId?: string;
|
|
14
|
+
wabaId?: string;
|
|
5
15
|
from: string;
|
|
6
16
|
to: string;
|
|
7
17
|
type: string;
|
|
8
|
-
quotedId
|
|
9
|
-
chatId
|
|
18
|
+
quotedId?: string;
|
|
19
|
+
chatId?: number;
|
|
20
|
+
contactId?: number;
|
|
10
21
|
body: string;
|
|
11
22
|
timestamp: string;
|
|
12
23
|
status: WppMessageStatus;
|
|
13
|
-
fileId
|
|
14
|
-
fileName
|
|
15
|
-
fileType
|
|
16
|
-
fileSize
|
|
24
|
+
fileId?: number;
|
|
25
|
+
fileName?: string;
|
|
26
|
+
fileType?: string;
|
|
27
|
+
fileSize?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WppChat {
|
|
30
|
+
id: number;
|
|
31
|
+
instance: string;
|
|
32
|
+
contactId?: number;
|
|
33
|
+
userId?: number;
|
|
34
|
+
walletId?: number;
|
|
35
|
+
botId?: number;
|
|
36
|
+
resultId?: number;
|
|
37
|
+
sectorId?: number;
|
|
38
|
+
type: WppChatType;
|
|
39
|
+
priority: WppChatPriority;
|
|
40
|
+
avatarUrl?: string;
|
|
41
|
+
isFinished: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface WppSector {
|
|
44
|
+
id: number;
|
|
45
|
+
name: string;
|
|
46
|
+
instanceName: string;
|
|
47
|
+
wppInstanceId?: number;
|
|
48
|
+
startChats: boolean;
|
|
49
|
+
receiveChats: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface WppWallet {
|
|
52
|
+
instanceName: string;
|
|
53
|
+
id: number;
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
56
|
+
export declare enum WppMessageStatus {
|
|
57
|
+
PENDING = "PENDING",
|
|
58
|
+
SENT = "SENT",
|
|
59
|
+
RECEIVED = "RECEIVED",
|
|
60
|
+
READ = "READ",
|
|
61
|
+
DOWNLOADED = "DOWNLOADED",
|
|
62
|
+
ERROR = "ERROR"
|
|
63
|
+
}
|
|
64
|
+
export declare enum WppChatType {
|
|
65
|
+
RECEPTIVE = "RECEPTIVE",
|
|
66
|
+
ACTIVE = "ACTIVE"
|
|
67
|
+
}
|
|
68
|
+
export declare enum WppChatPriority {
|
|
69
|
+
LOW = "LOW",
|
|
70
|
+
NORMAL = "NORMAL",
|
|
71
|
+
HIGH = "HIGH",
|
|
72
|
+
VERY_HIGH = "VERY_HIGH",
|
|
73
|
+
URGENCY = "URGENCY"
|
|
17
74
|
}
|
|
@@ -1,2 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WppChatPriority = exports.WppChatType = exports.WppMessageStatus = void 0;
|
|
4
|
+
// Enums
|
|
5
|
+
var WppMessageStatus;
|
|
6
|
+
(function (WppMessageStatus) {
|
|
7
|
+
WppMessageStatus["PENDING"] = "PENDING";
|
|
8
|
+
WppMessageStatus["SENT"] = "SENT";
|
|
9
|
+
WppMessageStatus["RECEIVED"] = "RECEIVED";
|
|
10
|
+
WppMessageStatus["READ"] = "READ";
|
|
11
|
+
WppMessageStatus["DOWNLOADED"] = "DOWNLOADED";
|
|
12
|
+
WppMessageStatus["ERROR"] = "ERROR";
|
|
13
|
+
})(WppMessageStatus || (exports.WppMessageStatus = WppMessageStatus = {}));
|
|
14
|
+
var WppChatType;
|
|
15
|
+
(function (WppChatType) {
|
|
16
|
+
WppChatType["RECEPTIVE"] = "RECEPTIVE";
|
|
17
|
+
WppChatType["ACTIVE"] = "ACTIVE";
|
|
18
|
+
})(WppChatType || (exports.WppChatType = WppChatType = {}));
|
|
19
|
+
var WppChatPriority;
|
|
20
|
+
(function (WppChatPriority) {
|
|
21
|
+
WppChatPriority["LOW"] = "LOW";
|
|
22
|
+
WppChatPriority["NORMAL"] = "NORMAL";
|
|
23
|
+
WppChatPriority["HIGH"] = "HIGH";
|
|
24
|
+
WppChatPriority["VERY_HIGH"] = "VERY_HIGH";
|
|
25
|
+
WppChatPriority["URGENCY"] = "URGENCY";
|
|
26
|
+
})(WppChatPriority || (exports.WppChatPriority = WppChatPriority = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import { Customer } from "./types";
|
|
3
|
+
import { DataResponse } from "./types/response.types";
|
|
4
|
+
import { WppChat, WppContact, WppMessage } from "./types/whatsapp.types";
|
|
5
|
+
type ChatWithContactAndCustomer = WppChat & {
|
|
6
|
+
customer: Customer;
|
|
7
|
+
contact: WppContact;
|
|
8
|
+
};
|
|
9
|
+
type ChatsAndMessages = {
|
|
10
|
+
chats: ChatWithContactAndCustomer[];
|
|
11
|
+
messages: WppMessage[];
|
|
12
|
+
};
|
|
13
|
+
type GetChatsResponse = DataResponse<ChatsAndMessages>;
|
|
14
|
+
type GetChatResponse = DataResponse<ChatWithContactAndCustomer & {
|
|
15
|
+
messages: WppMessage[];
|
|
16
|
+
}>;
|
|
17
|
+
type GetMessageResponse = DataResponse<WppMessage>;
|
|
18
|
+
export default class WhatsappClient extends ApiClient {
|
|
19
|
+
getChatsWithMessages(): Promise<GetChatsResponse>;
|
|
20
|
+
getChatById(id: number): Promise<GetChatResponse>;
|
|
21
|
+
getMessageById(id: string): Promise<GetMessageResponse>;
|
|
22
|
+
setAuth(token: string): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
|
+
class WhatsappClient extends api_client_1.default {
|
|
8
|
+
async getChatsWithMessages() {
|
|
9
|
+
const { data } = await this.httpClient.get("/api/whatsapp/chats");
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
async getChatById(id) {
|
|
13
|
+
const { data } = await this.httpClient.get(`/api/whatsapp/chats/${id}`);
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
async getMessageById(id) {
|
|
17
|
+
const { data } = await this.httpClient.get(`/api/whatsapp/messages/${id}`);
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
setAuth(token) {
|
|
21
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
22
|
+
`Bearer ${token}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = WhatsappClient;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { default as InstancesClient } from "./instance.client";
|
|
|
6
6
|
export { default as ReportsClient } from "./reports.client";
|
|
7
7
|
export { default as SocketServerClient } from "./socket-server.client";
|
|
8
8
|
export { default as SocketClient } from "./socket.client";
|
|
9
|
-
export { default as UsersClient } from "./users.client";
|
|
9
|
+
export { default as UsersClient } from "./users.client";
|
|
10
|
+
export { default as WhatsappClient } from "./whatsapp.client";
|
|
@@ -1,24 +1,82 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export interface WppContact {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
phone: string;
|
|
5
|
+
customerId?: number;
|
|
6
|
+
instance: string;
|
|
7
|
+
isBlocked: boolean;
|
|
8
|
+
isOnlyAdmin: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
9
11
|
export interface WppMessage {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
id: number;
|
|
13
|
+
instance: string;
|
|
14
|
+
wwebjsId?: string;
|
|
15
|
+
wabaId?: string;
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
type: string;
|
|
19
|
+
quotedId?: string;
|
|
20
|
+
chatId?: number;
|
|
21
|
+
contactId?: number;
|
|
22
|
+
body: string;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
status: WppMessageStatus;
|
|
25
|
+
fileId?: number;
|
|
26
|
+
fileName?: string;
|
|
27
|
+
fileType?: string;
|
|
28
|
+
fileSize?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface WppChat {
|
|
32
|
+
id: number;
|
|
33
|
+
instance: string;
|
|
34
|
+
contactId?: number;
|
|
35
|
+
userId?: number;
|
|
36
|
+
walletId?: number;
|
|
37
|
+
botId?: number;
|
|
38
|
+
resultId?: number;
|
|
39
|
+
sectorId?: number;
|
|
40
|
+
type: WppChatType;
|
|
41
|
+
priority: WppChatPriority;
|
|
42
|
+
avatarUrl?: string;
|
|
43
|
+
isFinished: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface WppSector {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
instanceName: string;
|
|
50
|
+
wppInstanceId?: number;
|
|
51
|
+
startChats: boolean;
|
|
52
|
+
receiveChats: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface WppWallet {
|
|
56
|
+
instanceName: string;
|
|
57
|
+
id: number;
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Enums
|
|
62
|
+
export enum WppMessageStatus {
|
|
63
|
+
PENDING = "PENDING",
|
|
64
|
+
SENT = "SENT",
|
|
65
|
+
RECEIVED = "RECEIVED",
|
|
66
|
+
READ = "READ",
|
|
67
|
+
DOWNLOADED = "DOWNLOADED",
|
|
68
|
+
ERROR = "ERROR",
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export enum WppChatType {
|
|
72
|
+
RECEPTIVE = "RECEPTIVE",
|
|
73
|
+
ACTIVE = "ACTIVE",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export enum WppChatPriority {
|
|
77
|
+
LOW = "LOW",
|
|
78
|
+
NORMAL = "NORMAL",
|
|
79
|
+
HIGH = "HIGH",
|
|
80
|
+
VERY_HIGH = "VERY_HIGH",
|
|
81
|
+
URGENCY = "URGENCY",
|
|
24
82
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import { Customer } from "./types";
|
|
3
|
+
import { DataResponse } from "./types/response.types";
|
|
4
|
+
import { WppChat, WppContact, WppMessage } from "./types/whatsapp.types";
|
|
5
|
+
|
|
6
|
+
type ChatWithContactAndCustomer = WppChat & {
|
|
7
|
+
customer: Customer;
|
|
8
|
+
contact: WppContact;
|
|
9
|
+
};
|
|
10
|
+
type ChatsAndMessages = {
|
|
11
|
+
chats: ChatWithContactAndCustomer[];
|
|
12
|
+
messages: WppMessage[];
|
|
13
|
+
};
|
|
14
|
+
type GetChatsResponse = DataResponse<ChatsAndMessages>;
|
|
15
|
+
type GetChatResponse = DataResponse<
|
|
16
|
+
ChatWithContactAndCustomer & { messages: WppMessage[] }
|
|
17
|
+
>;
|
|
18
|
+
type GetMessageResponse = DataResponse<WppMessage>;
|
|
19
|
+
|
|
20
|
+
export default class WhatsappClient extends ApiClient {
|
|
21
|
+
public async getChatsWithMessages() {
|
|
22
|
+
const { data } = await this.httpClient.get<GetChatsResponse>(
|
|
23
|
+
"/api/whatsapp/chats",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public async getChatById(id: number) {
|
|
30
|
+
const { data } = await this.httpClient.get<GetChatResponse>(
|
|
31
|
+
`/api/whatsapp/chats/${id}`,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async getMessageById(id: string) {
|
|
38
|
+
const { data } = await this.httpClient.get<GetMessageResponse>(
|
|
39
|
+
`/api/whatsapp/messages/${id}`,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public setAuth(token: string) {
|
|
46
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
47
|
+
`Bearer ${token}`;
|
|
48
|
+
}
|
|
49
|
+
}
|