@in.pulse-crm/sdk 2.4.12 → 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,5 +1,5 @@
1
1
  import ApiClient from "./api-client";
2
- import { InternalChat, InternalChatsAndMessages } from "./types/internal.types";
2
+ import { InternalChat, InternalChatsAndMessages, InternalContactWithUser } from "./types/internal.types";
3
3
  export default class InternalChatClient extends ApiClient {
4
4
  getChatsBySession(messages?: boolean, contact?: boolean): Promise<InternalChatsAndMessages>;
5
5
  getChatsForUser(userId: number, instance: string): Promise<InternalChat[]>;
@@ -7,5 +7,6 @@ export default class InternalChatClient extends ApiClient {
7
7
  sendMessageToChat(chatId: number, userId: number, content: string): Promise<any>;
8
8
  createGroup(name: string, participantIds: number[], userId: number): Promise<InternalChat>;
9
9
  updateGroupMembers(groupId: number, add: number[], remove: number[]): Promise<any>;
10
+ getContactsWithUser(): Promise<InternalContactWithUser[]>;
10
11
  setAuth(token: string): void;
11
12
  }
@@ -34,6 +34,11 @@ class InternalChatClient extends api_client_1.default {
34
34
  const { data: res } = await this.httpClient.put(`/api/internal/chats/group/${groupId}/members`, { add, remove });
35
35
  return res.data;
36
36
  }
37
+ async getContactsWithUser() {
38
+ const url = `/api/internal/contacts`;
39
+ const { data: res } = await this.httpClient.get(url);
40
+ return res.data;
41
+ }
37
42
  setAuth(token) {
38
43
  this.httpClient.defaults.headers.common["Authorization"] =
39
44
  `Bearer ${token}`;
@@ -1,4 +1,4 @@
1
- import { Customer } from "./customers.types";
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 InternalContactWithCustomer {
56
+ export interface InternalContactWithUser {
57
57
  id: number;
58
58
  name: string;
59
59
  phone: string;
60
- customerId?: number;
60
+ userId?: number;
61
61
  instance: string;
62
62
  isBlocked: boolean;
63
63
  isOnlyAdmin: boolean;
64
- customer: Customer | null;
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
- customer: Customer | null;
89
+ user: User | null;
90
90
  };
91
91
  export type InternalChatsAndMessages = {
92
92
  chats: InternalChatWithDetails[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.4.12",
3
+ "version": "2.4.13",
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",
@@ -1,6 +1,6 @@
1
1
  import ApiClient from "./api-client";
2
2
  import { DataResponse } from "./types/response.types";
3
- import { InternalChat, InternalChatsAndMessages } from "./types/internal.types";
3
+ import { InternalChat, InternalChatsAndMessages, InternalContactWithUser } from "./types/internal.types";
4
4
 
5
5
  type GetChatsResponse = DataResponse<InternalChatsAndMessages>;
6
6
 
@@ -49,9 +49,19 @@ type GetChatsResponse = DataResponse<InternalChatsAndMessages>;
49
49
  );
50
50
  return res.data;
51
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
+ );
52
59
 
53
- public setAuth(token: string) {
54
- this.httpClient.defaults.headers.common["Authorization"] =
55
- `Bearer ${token}`;
56
- }
60
+ return res.data;
61
+ }
62
+
63
+ public setAuth(token: string) {
64
+ this.httpClient.defaults.headers.common["Authorization"] =
65
+ `Bearer ${token}`;
66
+ }
57
67
  }
@@ -1,4 +1,4 @@
1
- import { Customer } from "./customers.types";
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 InternalContactWithCustomer {
62
+ export interface InternalContactWithUser {
63
63
  id: number;
64
64
  name: string;
65
65
  phone: string;
66
- customerId?: number;
66
+ userId?: number;
67
67
  instance: string;
68
68
  isBlocked: boolean;
69
69
  isOnlyAdmin: boolean;
70
- customer: Customer | null;
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
- customer: Customer | null;
107
+ user: User | null;
108
108
  };
109
109
  export type InternalChatsAndMessages = {
110
110
  chats: InternalChatWithDetails[];