@in.pulse-crm/sdk 2.14.7 → 2.15.0
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/ai.client.d.ts +33 -0
- package/dist/ai.client.js +120 -0
- package/dist/customers.client.d.ts +16 -2
- package/dist/customers.client.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/types/ai.types.d.ts +318 -0
- package/dist/types/ai.types.js +2 -0
- package/dist/types/customers.types.d.ts +186 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/response.types.d.ts +8 -0
- package/dist/types/socket-events.types.d.ts +15 -2
- package/dist/types/socket-events.types.js +1 -0
- package/dist/types/whatsapp.types.d.ts +169 -0
- package/dist/whatsapp.client.d.ts +7 -1
- package/dist/whatsapp.client.js +49 -0
- package/package.json +4 -2
- package/src/ai.client.ts +285 -0
- package/src/customers.client.ts +70 -1
- package/src/index.ts +1 -0
- package/src/types/ai.types.ts +378 -0
- package/src/types/customers.types.ts +180 -0
- package/src/types/index.ts +1 -0
- package/src/types/response.types.ts +9 -0
- package/src/types/socket-events.types.ts +22 -0
- package/src/types/whatsapp.types.ts +219 -0
- package/src/whatsapp.client.ts +79 -0
|
@@ -75,3 +75,189 @@ export interface CreateCustomerDTO {
|
|
|
75
75
|
SETOR?: number | null;
|
|
76
76
|
}
|
|
77
77
|
export type UpdateCustomerDTO = Partial<CreateCustomerDTO>;
|
|
78
|
+
export interface CustomerLookupOption {
|
|
79
|
+
CODIGO: number;
|
|
80
|
+
NOME: string | null;
|
|
81
|
+
}
|
|
82
|
+
export interface CustomerContactDetail {
|
|
83
|
+
CODIGO: string;
|
|
84
|
+
NOME: string;
|
|
85
|
+
CARGO: number | null;
|
|
86
|
+
EMAIL: string | null;
|
|
87
|
+
AREA_DIRETO: string | null;
|
|
88
|
+
AREA_CEL: string | null;
|
|
89
|
+
AREA_RESI: string | null;
|
|
90
|
+
FONE_DIRETO: string | null;
|
|
91
|
+
CELULAR: string | null;
|
|
92
|
+
FONE_RESIDENCIAL: string | null;
|
|
93
|
+
ANIVERSARIO: string | null;
|
|
94
|
+
TIME_FUTEBOL: string | null;
|
|
95
|
+
SEXO: "M" | "F" | null;
|
|
96
|
+
FILHOS: number;
|
|
97
|
+
CLIENTE: number | null;
|
|
98
|
+
TRATAMENTO: string | null;
|
|
99
|
+
}
|
|
100
|
+
export interface CustomerPurchaseItemDetail {
|
|
101
|
+
purchaseCode: number;
|
|
102
|
+
productCode: string | null;
|
|
103
|
+
description: string | null;
|
|
104
|
+
quantity: number | null;
|
|
105
|
+
unit: string | null;
|
|
106
|
+
unitValue: number | null;
|
|
107
|
+
discount: number | null;
|
|
108
|
+
}
|
|
109
|
+
export interface CustomerPurchaseDetail {
|
|
110
|
+
CODIGO: number;
|
|
111
|
+
CLIENTE: number;
|
|
112
|
+
DATA: string;
|
|
113
|
+
VALOR: number;
|
|
114
|
+
DESCRICAO: string | null;
|
|
115
|
+
FORMA_PGTO: string | null;
|
|
116
|
+
OPERADOR: number | null;
|
|
117
|
+
FATURADO: "S" | "N" | null;
|
|
118
|
+
TIPO: string | null;
|
|
119
|
+
SITUACAO: "F" | "C" | null;
|
|
120
|
+
CLIENTEATIVO: number | null;
|
|
121
|
+
items: CustomerPurchaseItemDetail[];
|
|
122
|
+
}
|
|
123
|
+
export interface CustomerScheduleDetail {
|
|
124
|
+
CODIGO: number;
|
|
125
|
+
CLIENTE: number;
|
|
126
|
+
CAMPANHA: number;
|
|
127
|
+
DT_RESULTADO: string;
|
|
128
|
+
DT_AGENDAMENTO: string;
|
|
129
|
+
RESULTADO: number;
|
|
130
|
+
CONCLUIDO: "SIM" | "NAO" | null;
|
|
131
|
+
FONE1: string;
|
|
132
|
+
FONE2: string;
|
|
133
|
+
FONE3: string;
|
|
134
|
+
ORDEM: number;
|
|
135
|
+
OPERADOR: number;
|
|
136
|
+
OPERADOR_LIGACAO: number;
|
|
137
|
+
DATA_HORA_LIG: string;
|
|
138
|
+
DATA_HORA_FIM: string;
|
|
139
|
+
TELEFONE_LIGADO: string;
|
|
140
|
+
AGENDA: number;
|
|
141
|
+
DESC_FONE1: string | null;
|
|
142
|
+
DESC_FONE2: string | null;
|
|
143
|
+
DESC_FONE3: string | null;
|
|
144
|
+
FIDELIZA: "S" | "N" | null;
|
|
145
|
+
MANUAL: "S" | "N" | null;
|
|
146
|
+
}
|
|
147
|
+
export interface CustomerTelephonySchedule extends CustomerScheduleDetail {
|
|
148
|
+
CAMPANHA_NOME: string | null;
|
|
149
|
+
OPERADOR_NOME: string | null;
|
|
150
|
+
OPERADOR_LIGACAO_NOME: string | null;
|
|
151
|
+
CLIENTE_RAZAO: string | null;
|
|
152
|
+
CLIENTE_FANTASIA: string | null;
|
|
153
|
+
}
|
|
154
|
+
export interface FinishTelephonyScheduleDTO {
|
|
155
|
+
resultId: number;
|
|
156
|
+
scheduleDate?: string;
|
|
157
|
+
startedAt?: string;
|
|
158
|
+
finishedAt?: string;
|
|
159
|
+
dialedPhone?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface CustomerCallHistoryDetail {
|
|
162
|
+
CODIGO: number;
|
|
163
|
+
OPERADOR: number;
|
|
164
|
+
CLIENTE: number;
|
|
165
|
+
RESULTADO: number;
|
|
166
|
+
EXCEDEU: "SIM" | "NAO" | null;
|
|
167
|
+
TEMPO_EXCEDIDO: string;
|
|
168
|
+
FONE_RECEPTIVO: string;
|
|
169
|
+
LIGACAO_RECEBIDA: string;
|
|
170
|
+
LIGACAO_FINALIZADA: string;
|
|
171
|
+
TIPO_ACAO: string;
|
|
172
|
+
OBS: string | null;
|
|
173
|
+
}
|
|
174
|
+
export interface CustomerFullDetail {
|
|
175
|
+
customer: Customer;
|
|
176
|
+
campaign: {
|
|
177
|
+
fullName: string | null;
|
|
178
|
+
firstName: string | null;
|
|
179
|
+
};
|
|
180
|
+
wallet: {
|
|
181
|
+
fullName: string | null;
|
|
182
|
+
firstName: string | null;
|
|
183
|
+
};
|
|
184
|
+
address: {
|
|
185
|
+
END_RUA: string | null;
|
|
186
|
+
CIDADE: string | null;
|
|
187
|
+
BAIRRO: string | null;
|
|
188
|
+
ESTADO: string | null;
|
|
189
|
+
CEP: string | null;
|
|
190
|
+
COMPLEMENTO: string | null;
|
|
191
|
+
};
|
|
192
|
+
origin: {
|
|
193
|
+
group: {
|
|
194
|
+
code: number | null;
|
|
195
|
+
description: string | null;
|
|
196
|
+
};
|
|
197
|
+
origin: {
|
|
198
|
+
code: number | null;
|
|
199
|
+
description: string | null;
|
|
200
|
+
};
|
|
201
|
+
media: {
|
|
202
|
+
code: number | null;
|
|
203
|
+
name: string | null;
|
|
204
|
+
};
|
|
205
|
+
operator: {
|
|
206
|
+
code: number | null;
|
|
207
|
+
name: string | null;
|
|
208
|
+
};
|
|
209
|
+
segment: {
|
|
210
|
+
code: number | null;
|
|
211
|
+
name: string | null;
|
|
212
|
+
};
|
|
213
|
+
emails: {
|
|
214
|
+
EMAIL: string | null;
|
|
215
|
+
EMAIL2: string | null;
|
|
216
|
+
CONTATO_MAIL: string | null;
|
|
217
|
+
};
|
|
218
|
+
WEBSITE: string | null;
|
|
219
|
+
NR_FUNCIONARIOS: number | null;
|
|
220
|
+
customName: string | null;
|
|
221
|
+
};
|
|
222
|
+
contacts: CustomerContactDetail[];
|
|
223
|
+
observations: {
|
|
224
|
+
OBS_ADMIN: string | null;
|
|
225
|
+
OBS_OPERADOR: string | null;
|
|
226
|
+
};
|
|
227
|
+
callHistory: CustomerCallHistoryDetail[];
|
|
228
|
+
phones: {
|
|
229
|
+
AREA1: number | null;
|
|
230
|
+
FONE1: string | null;
|
|
231
|
+
DESC_FONE1: string | null;
|
|
232
|
+
AREA2: number | null;
|
|
233
|
+
FONE2: string | null;
|
|
234
|
+
DESC_FONE2: string | null;
|
|
235
|
+
AREA3: number | null;
|
|
236
|
+
FONE3: string | null;
|
|
237
|
+
DESC_FONE3: string | null;
|
|
238
|
+
AREAFAX: number | null;
|
|
239
|
+
FAX: string | null;
|
|
240
|
+
DESCFAX: string | null;
|
|
241
|
+
campaignPhones: Array<{
|
|
242
|
+
area: number | null;
|
|
243
|
+
phone: string | null;
|
|
244
|
+
description: string | null;
|
|
245
|
+
}>;
|
|
246
|
+
};
|
|
247
|
+
purchases: CustomerPurchaseDetail[];
|
|
248
|
+
schedules: CustomerScheduleDetail[];
|
|
249
|
+
metadata: {
|
|
250
|
+
editableTabs: {
|
|
251
|
+
main: boolean;
|
|
252
|
+
address: boolean;
|
|
253
|
+
contacts: boolean;
|
|
254
|
+
observations: boolean;
|
|
255
|
+
phones: boolean;
|
|
256
|
+
};
|
|
257
|
+
purchaseItems: {
|
|
258
|
+
mapped: boolean;
|
|
259
|
+
tableName: string | null;
|
|
260
|
+
};
|
|
261
|
+
customNameFieldMapped: boolean;
|
|
262
|
+
};
|
|
263
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai.types"), exports);
|
|
17
18
|
__exportStar(require("./auth.types"), exports);
|
|
18
19
|
__exportStar(require("./customers.types"), exports);
|
|
19
20
|
__exportStar(require("./files.types"), exports);
|
|
@@ -17,6 +17,14 @@ export interface PaginatedResponse<T> {
|
|
|
17
17
|
totalRows: number;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
export interface FlexiblePaginatedResponse<T> {
|
|
21
|
+
message: string;
|
|
22
|
+
data: Array<T>;
|
|
23
|
+
page: {
|
|
24
|
+
current: number;
|
|
25
|
+
totalRows: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
20
28
|
export interface QueryResponse<T> {
|
|
21
29
|
result: T;
|
|
22
30
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SocketServerAdminRoom, SocketServerChatRoom, SocketServerInternalChatRoom, SocketServerReportsRoom, SocketServerRoom } from "./socket-rooms.types";
|
|
1
|
+
import { SocketServerAdminRoom, SocketServerChatRoom, SocketServerInternalChatRoom, SocketServerReportsRoom, SocketServerRoom, SocketServerUserRoom } from "./socket-rooms.types";
|
|
2
2
|
import { MessageResponse } from "./response.types";
|
|
3
3
|
import { WppMessage, WppMessageStatus } from "./whatsapp.types";
|
|
4
4
|
import { InternalChat, InternalChatMember, InternalMessage } from "./internal.types";
|
|
@@ -20,7 +20,8 @@ export declare enum SocketEventType {
|
|
|
20
20
|
InternalMessage = "internal_message",
|
|
21
21
|
InternalMessageEdit = "internal_message_edit",
|
|
22
22
|
InternalMessageDelete = "internal_message_delete",
|
|
23
|
-
InternalMessageStatus = "internal_message_status"
|
|
23
|
+
InternalMessageStatus = "internal_message_status",
|
|
24
|
+
TelephonyCallReceived = "telephony_call_received"
|
|
24
25
|
}
|
|
25
26
|
export interface EmitSocketEventFn {
|
|
26
27
|
(type: SocketEventType.WwebjsQr, room: SocketServerAdminRoom, data: WWEBJSQrEventData): Promise<MessageResponse>;
|
|
@@ -41,6 +42,7 @@ export interface EmitSocketEventFn {
|
|
|
41
42
|
(type: SocketEventType.InternalMessageStatus, room: SocketServerInternalChatRoom, data: InternalMessageStatusEventData): Promise<MessageResponse>;
|
|
42
43
|
(type: SocketEventType.InternalChatStarted, room: SocketServerRoom, data: InternalChatStartedEventData): Promise<MessageResponse>;
|
|
43
44
|
(type: SocketEventType.InternalChatFinished, room: SocketServerRoom, data: InternalChatFinishedEventData): Promise<MessageResponse>;
|
|
45
|
+
(type: SocketEventType.TelephonyCallReceived, room: SocketServerUserRoom, data: TelephonyCallReceivedEventData): Promise<MessageResponse>;
|
|
44
46
|
}
|
|
45
47
|
export interface ListenSocketEventFn {
|
|
46
48
|
(type: SocketEventType.WwebjsQr, callback: (data: WWEBJSQrEventData) => void): void;
|
|
@@ -61,6 +63,7 @@ export interface ListenSocketEventFn {
|
|
|
61
63
|
(type: SocketEventType.InternalMessageStatus, callback: (data: InternalMessageStatusEventData) => void): void;
|
|
62
64
|
(type: SocketEventType.WppMessageEdit, callback: (data: WppMessageEditEventData) => void): void;
|
|
63
65
|
(type: SocketEventType.WppMessageDelete, callback: (data: WppMessageDeleteEventData) => void): void;
|
|
66
|
+
(type: SocketEventType.TelephonyCallReceived, callback: (data: TelephonyCallReceivedEventData) => void): void;
|
|
64
67
|
}
|
|
65
68
|
export interface UnlistenSocketEventFn {
|
|
66
69
|
(type: SocketEventType): void;
|
|
@@ -157,3 +160,13 @@ export type ReportStatusEventData = {
|
|
|
157
160
|
isFailed: false;
|
|
158
161
|
progress: number;
|
|
159
162
|
});
|
|
163
|
+
export interface TelephonyCallReceivedEventData {
|
|
164
|
+
uniqueid: string;
|
|
165
|
+
callerNumber: string;
|
|
166
|
+
callerName: string | null;
|
|
167
|
+
ramal: string;
|
|
168
|
+
operatorId: number | null;
|
|
169
|
+
instance: string;
|
|
170
|
+
receivedAt: string;
|
|
171
|
+
receptiveCallId: number | null;
|
|
172
|
+
}
|
|
@@ -21,4 +21,5 @@ var SocketEventType;
|
|
|
21
21
|
SocketEventType["InternalMessageEdit"] = "internal_message_edit";
|
|
22
22
|
SocketEventType["InternalMessageDelete"] = "internal_message_delete";
|
|
23
23
|
SocketEventType["InternalMessageStatus"] = "internal_message_status";
|
|
24
|
+
SocketEventType["TelephonyCallReceived"] = "telephony_call_received";
|
|
24
25
|
})(SocketEventType || (exports.SocketEventType = SocketEventType = {}));
|
|
@@ -44,6 +44,102 @@ export interface PaginatedContactsResponse {
|
|
|
44
44
|
hasPrev: boolean;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
export type CustomerInteractionLevel = "sem_interacao" | "pouca_interacao" | "interacao_media" | "interacao_alta";
|
|
48
|
+
export type CustomerPurchaseLevel = "sem_compras" | "poucas_compras" | "compras_medias" | "muitas_compras";
|
|
49
|
+
export type CustomerAgeLevel = "sem_data_cadastro" | "cliente_novo" | "ate_6_meses" | "ate_12_meses" | "mais_de_12_meses";
|
|
50
|
+
export type CustomerPurchaseInterestLevel = "nao_analisado" | "baixo_interesse" | "interesse_moderado" | "alto_interesse" | "pronto_para_compra";
|
|
51
|
+
export interface CustomerProfileManualOverrides {
|
|
52
|
+
profileLevel: CustomerProfileSummaryLevel | null;
|
|
53
|
+
purchaseInterestLevel: CustomerPurchaseInterestLevel | null;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
updatedByUserId: number;
|
|
56
|
+
updatedByName: string;
|
|
57
|
+
}
|
|
58
|
+
export interface UpdateCustomerProfileManualOverridesInput {
|
|
59
|
+
profileLevel?: CustomerProfileSummaryLevel | null;
|
|
60
|
+
purchaseInterestLevel?: CustomerPurchaseInterestLevel | null;
|
|
61
|
+
}
|
|
62
|
+
export interface CustomerPurchaseInterestPayload {
|
|
63
|
+
level: CustomerPurchaseInterestLevel;
|
|
64
|
+
label: string;
|
|
65
|
+
color: string;
|
|
66
|
+
reasons: string[];
|
|
67
|
+
source: "placeholder_rules" | "manual_override";
|
|
68
|
+
}
|
|
69
|
+
export type CustomerProfileSummaryLevel = "potencial_de_compra" | "consolidado" | "precisa_mais_interacao" | "em_observacao";
|
|
70
|
+
export interface CustomerInteractionTagMetrics {
|
|
71
|
+
windowDays: number;
|
|
72
|
+
contactCount: number;
|
|
73
|
+
chatCount90d: number;
|
|
74
|
+
messageCount90d: number;
|
|
75
|
+
recentActiveDays90d: number;
|
|
76
|
+
lastInteractionAt: string | null;
|
|
77
|
+
allTimeMessageCount: number;
|
|
78
|
+
allTimeChatCount: number;
|
|
79
|
+
activeContactCount: number;
|
|
80
|
+
reasons: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface CustomerPurchaseTagMetrics {
|
|
83
|
+
windowMonths: number;
|
|
84
|
+
allTimePurchaseCount: number;
|
|
85
|
+
purchaseCount12m: number;
|
|
86
|
+
totalPurchaseValue12m: number;
|
|
87
|
+
lastPurchaseAt: string | null;
|
|
88
|
+
daysSinceLastPurchase: number | null;
|
|
89
|
+
reasons: string[];
|
|
90
|
+
}
|
|
91
|
+
export interface CustomerAgeTagMetrics {
|
|
92
|
+
newCustomerWindowDays: number;
|
|
93
|
+
registeredAt: string | null;
|
|
94
|
+
customerAgeDays: number | null;
|
|
95
|
+
customerAgeMonths: number | null;
|
|
96
|
+
reasons: string[];
|
|
97
|
+
}
|
|
98
|
+
export type CustomerProfileTagMetadata = CustomerInteractionTagMetrics | CustomerPurchaseTagMetrics | CustomerAgeTagMetrics;
|
|
99
|
+
export interface CustomerProfileTagPayload<TMetadata = CustomerProfileTagMetadata> {
|
|
100
|
+
id: number;
|
|
101
|
+
instance: string;
|
|
102
|
+
customerId: number;
|
|
103
|
+
tagType: string;
|
|
104
|
+
tagValue: string;
|
|
105
|
+
label: string;
|
|
106
|
+
color: string;
|
|
107
|
+
calculatedAt: string;
|
|
108
|
+
metadata: TMetadata | null;
|
|
109
|
+
}
|
|
110
|
+
export interface CustomerProfileSummaryPayload {
|
|
111
|
+
instance: string;
|
|
112
|
+
customerId: number;
|
|
113
|
+
profileLevel: CustomerProfileSummaryLevel;
|
|
114
|
+
label: string;
|
|
115
|
+
color: string;
|
|
116
|
+
profileSource: "automatic" | "manual_override";
|
|
117
|
+
reasons: string[];
|
|
118
|
+
purchaseInterest: CustomerPurchaseInterestPayload;
|
|
119
|
+
manualOverrides: CustomerProfileManualOverrides | null;
|
|
120
|
+
tags: {
|
|
121
|
+
interaction: CustomerProfileTagPayload<CustomerInteractionTagMetrics>;
|
|
122
|
+
purchase: CustomerProfileTagPayload<CustomerPurchaseTagMetrics>;
|
|
123
|
+
age: CustomerProfileTagPayload<CustomerAgeTagMetrics>;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface CustomerProfileSummaryFilters {
|
|
127
|
+
profileLevel?: CustomerProfileSummaryLevel;
|
|
128
|
+
interactionLevel?: CustomerInteractionLevel;
|
|
129
|
+
purchaseLevel?: CustomerPurchaseLevel;
|
|
130
|
+
ageLevel?: CustomerAgeLevel;
|
|
131
|
+
purchaseInterestLevel?: CustomerPurchaseInterestLevel;
|
|
132
|
+
state?: string;
|
|
133
|
+
city?: string;
|
|
134
|
+
activeCustomer?: "SIM" | "NAO";
|
|
135
|
+
searchTerm?: string;
|
|
136
|
+
segmentIds?: number[];
|
|
137
|
+
campaignIds?: number[];
|
|
138
|
+
operatorIds?: number[];
|
|
139
|
+
}
|
|
140
|
+
export interface CustomerProfileSummaryBatchRequest {
|
|
141
|
+
customerIds: number[];
|
|
142
|
+
}
|
|
47
143
|
export interface WppMessage {
|
|
48
144
|
id: number;
|
|
49
145
|
instance: string;
|
|
@@ -69,6 +165,7 @@ export interface WppMessage {
|
|
|
69
165
|
wwebjsIdStanza: string | null;
|
|
70
166
|
sentAt: Date;
|
|
71
167
|
userId: number | null;
|
|
168
|
+
agentId: number | null;
|
|
72
169
|
billingCategory: string | null;
|
|
73
170
|
clientId: number | null;
|
|
74
171
|
}
|
|
@@ -91,6 +188,7 @@ export interface WppChat {
|
|
|
91
188
|
userName?: string;
|
|
92
189
|
walletId?: number;
|
|
93
190
|
botId?: number;
|
|
191
|
+
agentId?: number | null;
|
|
94
192
|
resultId?: number;
|
|
95
193
|
sectorId?: number;
|
|
96
194
|
type: WppChatType;
|
|
@@ -174,6 +272,77 @@ export interface CreateScheduleDTO {
|
|
|
174
272
|
scheduledFor: number;
|
|
175
273
|
sectorId: number;
|
|
176
274
|
}
|
|
275
|
+
export type UnifiedScheduleChannel = "WHATSAPP" | "TELEFONIA";
|
|
276
|
+
export type UnifiedScheduleRepurchaseStatus = "green" | "yellow" | "red" | "neutral";
|
|
277
|
+
export interface UnifiedScheduleRepurchaseMetrics {
|
|
278
|
+
averageRepurchaseDays: number | null;
|
|
279
|
+
daysSinceLastPurchase: number | null;
|
|
280
|
+
nextRepurchaseDate: string | null;
|
|
281
|
+
proximityRatio: number | null;
|
|
282
|
+
semaphoreStatus: UnifiedScheduleRepurchaseStatus;
|
|
283
|
+
overdueDays: number | null;
|
|
284
|
+
}
|
|
285
|
+
export interface UnifiedScheduleCampaignFilterOption {
|
|
286
|
+
id: string;
|
|
287
|
+
label: string;
|
|
288
|
+
}
|
|
289
|
+
export interface UnifiedScheduleFilterMetadata {
|
|
290
|
+
customerCampaigns: UnifiedScheduleCampaignFilterOption[];
|
|
291
|
+
}
|
|
292
|
+
export interface UnifiedSchedulePagination {
|
|
293
|
+
current: number;
|
|
294
|
+
perPage: number;
|
|
295
|
+
totalRows: number;
|
|
296
|
+
totalPages: number;
|
|
297
|
+
hasNext: boolean;
|
|
298
|
+
hasPrev: boolean;
|
|
299
|
+
}
|
|
300
|
+
export interface UnifiedScheduleFilters extends CustomerProfileSummaryFilters {
|
|
301
|
+
page?: string;
|
|
302
|
+
perPage?: string;
|
|
303
|
+
channels?: string;
|
|
304
|
+
customerCampaignIds?: string;
|
|
305
|
+
repurchaseStatuses?: string;
|
|
306
|
+
userId?: string;
|
|
307
|
+
sectorId?: string;
|
|
308
|
+
}
|
|
309
|
+
export interface UnifiedSchedule {
|
|
310
|
+
id: string;
|
|
311
|
+
channel: UnifiedScheduleChannel;
|
|
312
|
+
scheduleId: number;
|
|
313
|
+
scheduleAt: string;
|
|
314
|
+
scheduledBy: number | null;
|
|
315
|
+
scheduledFor: number | null;
|
|
316
|
+
description: string | null;
|
|
317
|
+
contactName: string | null;
|
|
318
|
+
contactPhone: string | null;
|
|
319
|
+
customerId: number | null;
|
|
320
|
+
customerName: string | null;
|
|
321
|
+
customerFantasyName: string | null;
|
|
322
|
+
customerCampaignId: number | null;
|
|
323
|
+
customerCampaignName: string | null;
|
|
324
|
+
customerOriginId: number | null;
|
|
325
|
+
customerOriginDescription: string | null;
|
|
326
|
+
telephonyCampaignId: number | null;
|
|
327
|
+
telephonyCampaignName: string | null;
|
|
328
|
+
profileSummary: CustomerProfileSummaryPayload | null;
|
|
329
|
+
repurchase: UnifiedScheduleRepurchaseMetrics | null;
|
|
330
|
+
meta: {
|
|
331
|
+
wppContactId?: number;
|
|
332
|
+
wppChatId?: number | null;
|
|
333
|
+
telephonyRecordId?: number;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
export interface UnifiedSchedulesResponse {
|
|
337
|
+
message: string;
|
|
338
|
+
data: UnifiedSchedule[];
|
|
339
|
+
page: {
|
|
340
|
+
current: number;
|
|
341
|
+
totalRows: number;
|
|
342
|
+
};
|
|
343
|
+
pagination: UnifiedSchedulePagination;
|
|
344
|
+
filters: UnifiedScheduleFilterMetadata;
|
|
345
|
+
}
|
|
177
346
|
export interface WppSchedule {
|
|
178
347
|
id: number;
|
|
179
348
|
instance: string;
|
|
@@ -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, PaginatedContactsResponse, PaginatedNotificationsResponse, SendFileMessageData, SendMessageData, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, WppWallet } from "./types/whatsapp.types";
|
|
4
|
+
import { AppNotification, AutomaticResponseRule, AutomaticResponseRuleDTO, CustomerProfileManualOverrides, CustomerProfileSummaryBatchRequest, CustomerProfileSummaryFilters, CustomerProfileSummaryPayload, CreateScheduleDTO, ForwardMessagesData, PaginatedContactsResponse, PaginatedNotificationsResponse, SendFileMessageData, SendMessageData, UnifiedScheduleFilters, UnifiedSchedulesResponse, WppChatsAndMessages, WppChatWithDetailsAndMessages, WppContact, WppMessage, WppSchedule, UpdateCustomerProfileManualOverridesInput, WppWallet } from "./types/whatsapp.types";
|
|
5
5
|
interface FetchMessagesFilters {
|
|
6
6
|
minDate: string;
|
|
7
7
|
maxDate: string;
|
|
@@ -22,6 +22,11 @@ export default class WhatsappClient extends ApiClient {
|
|
|
22
22
|
name: string;
|
|
23
23
|
}[]>;
|
|
24
24
|
getCustomerContacts(customerId: number): Promise<WppContact[]>;
|
|
25
|
+
getCustomerProfileSummary(customerId: number): Promise<CustomerProfileSummaryPayload>;
|
|
26
|
+
getCustomerProfileManualOverrides(customerId: number): Promise<CustomerProfileManualOverrides | null>;
|
|
27
|
+
updateCustomerProfileManualOverrides(customerId: number, data: UpdateCustomerProfileManualOverridesInput): Promise<CustomerProfileSummaryPayload>;
|
|
28
|
+
getCustomerProfileSummaries(data: CustomerProfileSummaryBatchRequest): Promise<CustomerProfileSummaryPayload[]>;
|
|
29
|
+
findCustomerIdsByProfileFilters(filters: CustomerProfileSummaryFilters): Promise<number[]>;
|
|
25
30
|
getContactsWithCustomer(filters?: {
|
|
26
31
|
name?: string;
|
|
27
32
|
phone?: string;
|
|
@@ -69,6 +74,7 @@ export default class WhatsappClient extends ApiClient {
|
|
|
69
74
|
* @returns Uma Promise que resolve para um array de objetos wppSchedule.
|
|
70
75
|
*/
|
|
71
76
|
getSchedules(userId?: string, sectorId?: string, filters?: RequestFilters<WppSchedule>): Promise<any>;
|
|
77
|
+
getUnifiedSchedules(filters?: UnifiedScheduleFilters): Promise<UnifiedSchedulesResponse>;
|
|
72
78
|
/**
|
|
73
79
|
* Cria um novo agendamento.
|
|
74
80
|
* @param scheduleData - Os dados do agendamento, keys de wppSchedule.
|
package/dist/whatsapp.client.js
CHANGED
|
@@ -79,6 +79,41 @@ class WhatsappClient extends api_client_1.default {
|
|
|
79
79
|
const { data: res } = await this.ax.get(url);
|
|
80
80
|
return res.data;
|
|
81
81
|
}
|
|
82
|
+
async getCustomerProfileSummary(customerId) {
|
|
83
|
+
const { data: res } = await this.ax.get(`/api/whatsapp/customers/${customerId}/profile-tags/summary`);
|
|
84
|
+
return res.data;
|
|
85
|
+
}
|
|
86
|
+
async getCustomerProfileManualOverrides(customerId) {
|
|
87
|
+
const { data: res } = await this.ax.get(`/api/whatsapp/customers/${customerId}/profile-tags/manual-overrides`);
|
|
88
|
+
return res.data;
|
|
89
|
+
}
|
|
90
|
+
async updateCustomerProfileManualOverrides(customerId, data) {
|
|
91
|
+
const { data: res } = await this.ax.put(`/api/whatsapp/customers/${customerId}/profile-tags/manual-overrides`, data);
|
|
92
|
+
return res.data;
|
|
93
|
+
}
|
|
94
|
+
async getCustomerProfileSummaries(data) {
|
|
95
|
+
const { data: res } = await this.ax.post(`/api/whatsapp/customers/profile-tags/summary/batch`, data);
|
|
96
|
+
return res.data;
|
|
97
|
+
}
|
|
98
|
+
async findCustomerIdsByProfileFilters(filters) {
|
|
99
|
+
const params = new URLSearchParams();
|
|
100
|
+
if (filters.profileLevel)
|
|
101
|
+
params.append("profileLevel", filters.profileLevel);
|
|
102
|
+
if (filters.interactionLevel)
|
|
103
|
+
params.append("interactionLevel", filters.interactionLevel);
|
|
104
|
+
if (filters.purchaseLevel)
|
|
105
|
+
params.append("purchaseLevel", filters.purchaseLevel);
|
|
106
|
+
if (filters.ageLevel)
|
|
107
|
+
params.append("ageLevel", filters.ageLevel);
|
|
108
|
+
if (filters.purchaseInterestLevel)
|
|
109
|
+
params.append("purchaseInterestLevel", filters.purchaseInterestLevel);
|
|
110
|
+
const queryString = params.toString();
|
|
111
|
+
const url = queryString
|
|
112
|
+
? `/api/whatsapp/customers/profile-tags/customer-ids?${queryString}`
|
|
113
|
+
: `/api/whatsapp/customers/profile-tags/customer-ids`;
|
|
114
|
+
const { data: res } = await this.ax.get(url);
|
|
115
|
+
return res.data;
|
|
116
|
+
}
|
|
82
117
|
async getContactsWithCustomer(filters) {
|
|
83
118
|
let url = `/api/whatsapp/contacts/customer`;
|
|
84
119
|
if (filters) {
|
|
@@ -235,6 +270,20 @@ class WhatsappClient extends api_client_1.default {
|
|
|
235
270
|
const response = await this.ax.get(baseUrl);
|
|
236
271
|
return response.data;
|
|
237
272
|
}
|
|
273
|
+
async getUnifiedSchedules(filters) {
|
|
274
|
+
let baseUrl = `/api/whatsapp/schedules/unified`;
|
|
275
|
+
const params = new URLSearchParams(Object.entries(filters ?? {}).reduce((acc, [key, value]) => {
|
|
276
|
+
if (value !== undefined && value !== null) {
|
|
277
|
+
acc[key] = String(value);
|
|
278
|
+
}
|
|
279
|
+
return acc;
|
|
280
|
+
}, {}));
|
|
281
|
+
if (params.toString()) {
|
|
282
|
+
baseUrl += `?${params.toString()}`;
|
|
283
|
+
}
|
|
284
|
+
const response = await this.ax.get(baseUrl);
|
|
285
|
+
return response.data;
|
|
286
|
+
}
|
|
238
287
|
/**
|
|
239
288
|
* Cria um novo agendamento.
|
|
240
289
|
* @param scheduleData - Os dados do agendamento, keys de wppSchedule.
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@in.pulse-crm/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
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",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"scripts": {
|