-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddUnsortedForm.js
36 lines (28 loc) · 1.03 KB
/
addUnsortedForm.js
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
// const {AmoApiClient} = require('@mobilon/amotop');
const {AmoApiClient} = require('../../dist');
const {domain, accessToken, debug} = require('../_config');
const amoApiClient = new AmoApiClient(domain, accessToken, {debug});
const start = async () => {
try {
const params = {
source_uid: 'tetetet',
source_name: 'наш сайт',
metadata: {
form_id: 'form_feedback',
form_name: 'Форма обратной связи на сайте',
form_page: '/feedback',
ip: '127.0.0.1',
form_sent_at: Math.floor(new Date().getTime() / 1000),
referer: 'http://google.com',
},
};
console.log('params', params);
const data = await amoApiClient.addUnsortedForms([params]);
console.log('response', JSON.stringify(data));
const unsortedLeads = await amoApiClient.getUnsorted();
console.log('unsortedLeads', JSON.stringify(unsortedLeads, null, 2));
} catch (err) {
console.log('err', JSON.stringify(err.response.data, null, 2));
}
}
(start)();