-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcrm.ts
More file actions
244 lines (212 loc) · 4.98 KB
/
crm.ts
File metadata and controls
244 lines (212 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import { wrapper, wrapperMethod } from "./decorators.ts";
export type RDDeal = {
id: string;
name?: string;
recurrence_price?: number;
one_time_price?: number;
total_price?: number;
expected_close_date?: string;
rating?: number;
status?: "won" | "lost" | "ongoing" | "paused";
closed_at?: string;
pipeline_id?: string;
stage_id?: string;
owner_id?: string;
source_id?: string;
campaign_id?: string;
lost_reason_id?: string;
organization_id?: string;
contact_ids?: string[];
custom_fields?: Record<string, string>;
created_at?: string;
updated_at?: string;
};
export type RDContact = {
id: string;
name?: string;
job_title?: string;
phones?: Array<{ phone: string }>;
emails?: Array<{ email: string }>;
birthday?: string;
organization_id?: string;
custom_fields?: Record<string, string>;
created_at?: string;
updated_at?: string;
_deal_ia?: RDDeal | null;
};
export type RDTeam = {
id: string;
name?: string;
users?: Array<{ id: string; email?: string; name?: string }>;
};
export type CVSituacao = {
id?: number;
nome?: string;
};
export type CVCorretor = {
id?: number;
idcorretor?: number;
nome?: string;
email?: string;
};
export type CVEmpreendimento = {
id?: number;
nome?: string;
};
export type CVEmpreendimentoDetalhe = {
idempreendimento?: string;
idempreendimento_int?: string;
referencia_externa?: string;
nome?: string;
};
export type CVInteracao = {
id?: number;
descricao?: string;
data_cad?: string;
};
export type CVLead = {
idlead: number;
situacao?: CVSituacao;
empreendimento?: Array<CVEmpreendimento | string>;
interacao?: CVInteracao[];
corretor?: CVCorretor;
nome?: string;
email?: string;
telefone?: string;
tags?: string[];
};
export class RDStationCRM {
@wrapperMethod
api_request(_p: {
path: string;
method: string;
data?: Record<string, any> | null;
query_params?: Record<string, any>;
}): Promise<any> {
return Promise.resolve();
}
@wrapperMethod
find_contact(_p: {
id_user: string;
}): Promise<RDContact | null> {
return Promise.resolve(null);
}
@wrapperMethod
create_contact(_p: {
id_user: string;
}): Promise<RDContact> {
return Promise.resolve({} as RDContact);
}
@wrapperMethod
find_ai_deal(_p: {
contact_id: string;
}): Promise<RDDeal | null> {
return Promise.resolve(null);
}
@wrapperMethod
create_ai_deal(_p: {
id_user: string;
contact_id: string;
owner_id: string;
pipeline_id?: string;
stage_id?: string;
}): Promise<RDDeal> {
return Promise.resolve({} as RDDeal);
}
@wrapperMethod
save_deal(_p: {
id_contato: string;
id_deal: string | null;
data: Record<string, any>;
}): Promise<RDDeal | null> {
return Promise.resolve(null);
}
@wrapperMethod
get_pipeline_by_name(_p: {
name: string;
}): Promise<{ id: string; name: string } | null> {
return Promise.resolve(null);
}
@wrapperMethod
get_stages_by_pipeline_id(_p: {
pipeline_id: string;
}): Promise<Array<{ id: string; name: string; order?: number }>> {
return Promise.resolve([]);
}
@wrapperMethod
get_user_by_email(_p: {
email: string;
}): Promise<{ id: string; email: string; name?: string } | null> {
return Promise.resolve(null);
}
@wrapperMethod
get_custom_field_by_name(_p: {
name: string;
entity?: string;
}): Promise<{ id: string; name: string; slug?: string } | null> {
return Promise.resolve(null);
}
@wrapperMethod
list_teams(): Promise<RDTeam[]> {
return Promise.resolve([]);
}
}
export class CVCRM {
@wrapperMethod
api_request(_p: {
path: string;
method: string;
data?: Record<string, any> | null;
query_params?: Record<string, any>;
}): Promise<any> {
return Promise.resolve();
}
@wrapperMethod
get_lead_by_id(_p: { idlead: string }): Promise<CVLead | null> {
return Promise.resolve(null);
}
@wrapperMethod
consultar_lead(
_p: { id_usuario: string },
): Promise<[Record<string, string> | null, CVLead | null]> {
return Promise.resolve([null, null]);
}
@wrapperMethod
get_corretor_by_id(_p: { id_corretor: string }): Promise<CVCorretor | null> {
return Promise.resolve(null);
}
@wrapperMethod
get_empreendimento_by_id(
_p: { id_empreendimento: string },
): Promise<CVEmpreendimentoDetalhe | null> {
return Promise.resolve(null);
}
@wrapperMethod
list_situacoes(): Promise<CVSituacao[]> {
return Promise.resolve([]);
}
}
@wrapper
export class EmailCRM {}
@wrapper
export class BitrixCRM {}
@wrapper
export class PiperunCRM {}
@wrapper
export class WebhookCRM {}
export class CRM {
cvcrm: CVCRM;
email: EmailCRM;
bitrix: BitrixCRM;
piperun: PiperunCRM;
webhook: WebhookCRM;
rdstation: RDStationCRM;
constructor() {
this.cvcrm = new CVCRM();
this.email = new EmailCRM();
this.bitrix = new BitrixCRM();
this.piperun = new PiperunCRM();
this.webhook = new WebhookCRM();
this.rdstation = new RDStationCRM();
}
}