@in.pulse-crm/sdk 2.4.11 → 2.4.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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import { InternalChat } from "./types/internal.types";
|
|
2
|
+
import { InternalChat, InternalChatsAndMessages, InternalContactWithUser } from "./types/internal.types";
|
|
3
3
|
export default class InternalChatClient extends ApiClient {
|
|
4
|
+
getChatsBySession(messages?: boolean, contact?: boolean): Promise<InternalChatsAndMessages>;
|
|
4
5
|
getChatsForUser(userId: number, instance: string): Promise<InternalChat[]>;
|
|
5
6
|
getChatById(id: number): Promise<InternalChat>;
|
|
6
7
|
sendMessageToChat(chatId: number, userId: number, content: string): Promise<any>;
|
|
7
8
|
createGroup(name: string, participantIds: number[], userId: number): Promise<InternalChat>;
|
|
8
9
|
updateGroupMembers(groupId: number, add: number[], remove: number[]): Promise<any>;
|
|
10
|
+
getContactsWithUser(): Promise<InternalContactWithUser[]>;
|
|
9
11
|
setAuth(token: string): void;
|
|
10
12
|
}
|
package/dist/internal.client.js
CHANGED
|
@@ -5,6 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
7
|
class InternalChatClient extends api_client_1.default {
|
|
8
|
+
async getChatsBySession(messages = false, contact = false) {
|
|
9
|
+
const url = `/api/internal/session/chats?messages=${messages}&contact=${contact}`;
|
|
10
|
+
console.log(this.httpClient.defaults.headers.common["Authorization"]);
|
|
11
|
+
const { data: res } = await this.httpClient.get(url);
|
|
12
|
+
return res.data;
|
|
13
|
+
}
|
|
8
14
|
async getChatsForUser(userId, instance) {
|
|
9
15
|
const url = `/api/internal/chats?userId=${userId}&instance=${instance}`;
|
|
10
16
|
const { data: res } = await this.httpClient.get(url);
|
|
@@ -28,6 +34,11 @@ class InternalChatClient extends api_client_1.default {
|
|
|
28
34
|
const { data: res } = await this.httpClient.put(`/api/internal/chats/group/${groupId}/members`, { add, remove });
|
|
29
35
|
return res.data;
|
|
30
36
|
}
|
|
37
|
+
async getContactsWithUser() {
|
|
38
|
+
const url = `/api/internal/contacts`;
|
|
39
|
+
const { data: res } = await this.httpClient.get(url);
|
|
40
|
+
return res.data;
|
|
41
|
+
}
|
|
31
42
|
setAuth(token) {
|
|
32
43
|
this.httpClient.defaults.headers.common["Authorization"] =
|
|
33
44
|
`Bearer ${token}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { User } from "./user.types";
|
|
2
2
|
export interface InternalContact {
|
|
3
3
|
id: number;
|
|
4
4
|
name: string;
|
|
@@ -53,15 +53,15 @@ export interface InternalChatTag {
|
|
|
53
53
|
internalchatId: number;
|
|
54
54
|
tagId: number;
|
|
55
55
|
}
|
|
56
|
-
export interface
|
|
56
|
+
export interface InternalContactWithUser {
|
|
57
57
|
id: number;
|
|
58
58
|
name: string;
|
|
59
59
|
phone: string;
|
|
60
|
-
|
|
60
|
+
userId?: number;
|
|
61
61
|
instance: string;
|
|
62
62
|
isBlocked: boolean;
|
|
63
63
|
isOnlyAdmin: boolean;
|
|
64
|
-
|
|
64
|
+
user: User | null;
|
|
65
65
|
chatingWith: string | null;
|
|
66
66
|
}
|
|
67
67
|
export interface Sector {
|
|
@@ -86,7 +86,7 @@ export declare enum IntenalChatPriority {
|
|
|
86
86
|
}
|
|
87
87
|
export type InternalChatWithDetails = InternalChat & {
|
|
88
88
|
contact: InternalContact | null;
|
|
89
|
-
|
|
89
|
+
user: User | null;
|
|
90
90
|
};
|
|
91
91
|
export type InternalChatsAndMessages = {
|
|
92
92
|
chats: InternalChatWithDetails[];
|
package/package.json
CHANGED
package/src/internal.client.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
2
|
import { DataResponse } from "./types/response.types";
|
|
3
|
-
import { InternalChat } from "./types/internal.types";
|
|
3
|
+
import { InternalChat, InternalChatsAndMessages, InternalContactWithUser } from "./types/internal.types";
|
|
4
|
+
|
|
5
|
+
type GetChatsResponse = DataResponse<InternalChatsAndMessages>;
|
|
4
6
|
|
|
5
7
|
export default class InternalChatClient extends ApiClient {
|
|
8
|
+
public async getChatsBySession(
|
|
9
|
+
messages = false,
|
|
10
|
+
contact = false,
|
|
11
|
+
) {
|
|
12
|
+
const url = `/api/internal/session/chats?messages=${messages}&contact=${contact}`;
|
|
13
|
+
|
|
14
|
+
console.log(this.httpClient.defaults.headers.common["Authorization"]);
|
|
15
|
+
const { data: res } = await this.httpClient.get<GetChatsResponse>(url);
|
|
16
|
+
|
|
17
|
+
return res.data;
|
|
18
|
+
}
|
|
6
19
|
public async getChatsForUser(userId: number, instance: string) {
|
|
7
20
|
const url = `/api/internal/chats?userId=${userId}&instance=${instance}`;
|
|
8
21
|
const { data: res } = await this.httpClient.get<DataResponse<InternalChat[]>>(url);
|
|
@@ -36,9 +49,19 @@ import { InternalChat } from "./types/internal.types";
|
|
|
36
49
|
);
|
|
37
50
|
return res.data;
|
|
38
51
|
}
|
|
52
|
+
|
|
53
|
+
public async getContactsWithUser() {
|
|
54
|
+
const url = `/api/internal/contacts`;
|
|
55
|
+
const { data: res } =
|
|
56
|
+
await this.httpClient.get<DataResponse<InternalContactWithUser[]>>(
|
|
57
|
+
url,
|
|
58
|
+
);
|
|
39
59
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
return res.data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public setAuth(token: string) {
|
|
64
|
+
this.httpClient.defaults.headers.common["Authorization"] =
|
|
65
|
+
`Bearer ${token}`;
|
|
66
|
+
}
|
|
44
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { User } from "./user.types";
|
|
2
2
|
|
|
3
3
|
export interface InternalContact {
|
|
4
4
|
id: number;
|
|
@@ -59,15 +59,15 @@ export interface InternalChatTag {
|
|
|
59
59
|
tagId: number;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export interface
|
|
62
|
+
export interface InternalContactWithUser {
|
|
63
63
|
id: number;
|
|
64
64
|
name: string;
|
|
65
65
|
phone: string;
|
|
66
|
-
|
|
66
|
+
userId?: number;
|
|
67
67
|
instance: string;
|
|
68
68
|
isBlocked: boolean;
|
|
69
69
|
isOnlyAdmin: boolean;
|
|
70
|
-
|
|
70
|
+
user: User | null;
|
|
71
71
|
chatingWith: string | null;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -104,7 +104,7 @@ export enum IntenalChatPriority {
|
|
|
104
104
|
|
|
105
105
|
export type InternalChatWithDetails = InternalChat & {
|
|
106
106
|
contact: InternalContact | null;
|
|
107
|
-
|
|
107
|
+
user: User | null;
|
|
108
108
|
};
|
|
109
109
|
export type InternalChatsAndMessages = {
|
|
110
110
|
chats: InternalChatWithDetails[];
|