@in.pulse-crm/sdk 2.12.4 → 2.12.6

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.
@@ -14,14 +14,29 @@ export interface WppContactWithCustomer {
14
14
  id: number;
15
15
  name: string;
16
16
  phone: string;
17
- customerId?: number;
18
- avatarUrl?: string;
17
+ customerId: number | null;
18
+ avatarUrl: string | null;
19
19
  instance: string;
20
20
  isBlocked: boolean;
21
21
  isOnlyAdmin: boolean;
22
+ isDeleted: boolean;
23
+ createdAt: Date;
24
+ updatedAt: Date | null;
25
+ conversationExpiration: string | null;
22
26
  customer: Customer | null;
23
27
  chatingWith: string | null;
24
- lastOutOfHoursReplySentAt?: Date | null;
28
+ lastOutOfHoursReplySentAt: Date | null;
29
+ }
30
+ export interface PaginatedContactsResponse {
31
+ data: WppContactWithCustomer[];
32
+ pagination: {
33
+ page: number;
34
+ perPage: number;
35
+ total: number;
36
+ totalPages: number;
37
+ hasNext: boolean;
38
+ hasPrev: boolean;
39
+ };
25
40
  }
26
41
  export interface WppMessage {
27
42
  id: number;
@@ -1,7 +1,7 @@
1
1
  import ApiClient from "./api-client";
2
2
  import { RequestFilters } from "./types";
3
3
  import { DataResponse, MessageResponse } from "./types/response.types";
4
- import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppContactWithCustomer, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
4
+ import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CreateScheduleDTO, ForwardMessagesData, PaginatedContactsResponse, PaginatedNotificationsResponse, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
5
5
  interface FetchMessagesFilters {
6
6
  minDate: string;
7
7
  maxDate: string;
@@ -32,7 +32,7 @@ export default class WhatsappClient extends ApiClient {
32
32
  hasCustomer?: boolean;
33
33
  page?: number;
34
34
  perPage?: number;
35
- }): Promise<WppContactWithCustomer[]>;
35
+ }): Promise<PaginatedContactsResponse>;
36
36
  getContacts(): Promise<WppContact[]>;
37
37
  createContact(name: string, phone: string, customerId?: number): Promise<WppContact>;
38
38
  forwardMessages(data: ForwardMessagesData): Promise<void>;
@@ -86,28 +86,28 @@ class WhatsappClient extends api_client_1.default {
86
86
  if (filters) {
87
87
  const params = new URLSearchParams();
88
88
  if (filters.name)
89
- params.append('name', filters.name);
89
+ params.append("name", filters.name);
90
90
  if (filters.phone)
91
- params.append('phone', filters.phone);
91
+ params.append("phone", filters.phone);
92
92
  if (filters.customerId !== undefined)
93
- params.append('customerId', String(filters.customerId));
93
+ params.append("customerId", String(filters.customerId));
94
94
  if (filters.customerErp)
95
- params.append('customerErp', filters.customerErp);
95
+ params.append("customerErp", filters.customerErp);
96
96
  if (filters.customerCnpj)
97
- params.append('customerCnpj', filters.customerCnpj);
97
+ params.append("customerCnpj", filters.customerCnpj);
98
98
  if (filters.customerName)
99
- params.append('customerName', filters.customerName);
99
+ params.append("customerName", filters.customerName);
100
100
  if (filters.hasCustomer !== undefined)
101
- params.append('hasCustomer', String(filters.hasCustomer));
101
+ params.append("hasCustomer", String(filters.hasCustomer));
102
102
  if (filters.page !== undefined)
103
- params.append('page', String(filters.page));
103
+ params.append("page", String(filters.page));
104
104
  if (filters.perPage !== undefined)
105
- params.append('perPage', String(filters.perPage));
105
+ params.append("perPage", String(filters.perPage));
106
106
  const queryString = params.toString();
107
107
  if (queryString)
108
108
  url += `?${queryString}`;
109
109
  }
110
- const { data: res } = await this.ax.get(url);
110
+ const res = await this.ax.get(url);
111
111
  return res.data;
112
112
  }
113
113
  async getContacts() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@in.pulse-crm/sdk",
3
- "version": "2.12.4",
3
+ "version": "2.12.6",
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",
@@ -16,14 +16,30 @@ export interface WppContactWithCustomer {
16
16
  id: number;
17
17
  name: string;
18
18
  phone: string;
19
- customerId?: number;
20
- avatarUrl?: string;
19
+ customerId: number | null;
20
+ avatarUrl: string | null;
21
21
  instance: string;
22
22
  isBlocked: boolean;
23
23
  isOnlyAdmin: boolean;
24
+ isDeleted: boolean;
25
+ createdAt: Date;
26
+ updatedAt: Date | null;
27
+ conversationExpiration: string | null;
24
28
  customer: Customer | null;
25
29
  chatingWith: string | null;
26
- lastOutOfHoursReplySentAt?: Date | null;
30
+ lastOutOfHoursReplySentAt: Date | null;
31
+ }
32
+
33
+ export interface PaginatedContactsResponse {
34
+ data: WppContactWithCustomer[];
35
+ pagination: {
36
+ page: number;
37
+ perPage: number;
38
+ total: number;
39
+ totalPages: number;
40
+ hasNext: boolean;
41
+ hasPrev: boolean;
42
+ };
27
43
  }
28
44
 
29
45
  export interface WppMessage {
@@ -7,12 +7,12 @@ import {
7
7
  AutomaticResponseRuleDTO,
8
8
  CreateScheduleDTO,
9
9
  ForwardMessagesData,
10
+ PaginatedContactsResponse,
10
11
  PaginatedNotificationsResponse,
11
12
  SendMessageData,
12
13
  WppChatsAndMessages,
13
14
  WppChatWithDetailsAndMessages,
14
15
  WppContact,
15
- WppContactWithCustomer,
16
16
  WppMessage,
17
17
  WppSchedule,
18
18
  WppWallet,
@@ -165,20 +165,28 @@ export default class WhatsappClient extends ApiClient {
165
165
  let url = `/api/whatsapp/contacts/customer`;
166
166
  if (filters) {
167
167
  const params = new URLSearchParams();
168
- if (filters.name) params.append('name', filters.name);
169
- if (filters.phone) params.append('phone', filters.phone);
170
- if (filters.customerId !== undefined) params.append('customerId', String(filters.customerId));
171
- if (filters.customerErp) params.append('customerErp', filters.customerErp);
172
- if (filters.customerCnpj) params.append('customerCnpj', filters.customerCnpj);
173
- if (filters.customerName) params.append('customerName', filters.customerName);
174
- if (filters.hasCustomer !== undefined) params.append('hasCustomer', String(filters.hasCustomer));
175
- if (filters.page !== undefined) params.append('page', String(filters.page));
176
- if (filters.perPage !== undefined) params.append('perPage', String(filters.perPage));
168
+ if (filters.name) params.append("name", filters.name);
169
+ if (filters.phone) params.append("phone", filters.phone);
170
+ if (filters.customerId !== undefined)
171
+ params.append("customerId", String(filters.customerId));
172
+ if (filters.customerErp)
173
+ params.append("customerErp", filters.customerErp);
174
+ if (filters.customerCnpj)
175
+ params.append("customerCnpj", filters.customerCnpj);
176
+ if (filters.customerName)
177
+ params.append("customerName", filters.customerName);
178
+ if (filters.hasCustomer !== undefined)
179
+ params.append("hasCustomer", String(filters.hasCustomer));
180
+ if (filters.page !== undefined)
181
+ params.append("page", String(filters.page));
182
+ if (filters.perPage !== undefined)
183
+ params.append("perPage", String(filters.perPage));
177
184
  const queryString = params.toString();
178
185
  if (queryString) url += `?${queryString}`;
179
186
  }
180
- const { data: res } =
181
- await this.ax.get<DataResponse<WppContactWithCustomer[]>>(url);
187
+
188
+ const res = await this.ax.get<PaginatedContactsResponse>(url);
189
+
182
190
  return res.data;
183
191
  }
184
192