-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipedrive.js
More file actions
62 lines (57 loc) · 1.58 KB
/
pipedrive.js
File metadata and controls
62 lines (57 loc) · 1.58 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
import axios from axios;
export default class PipeDrive {
constructor() {
company_domain="squadrun-fd1c9c";
api_token = "eea94c078a344955a482a7dc14316fd2a20ade71";
}
searchPersonByName(name = "") {
return new Promise((resolve, reject) => {
const url = 'https://' + this.company_domain + '.pipedrive.com/v1/' + "persons/" +"find?term="+name+"&start=0&api_token="+this.api_token;
axios
.get(url)
.then(response => {
return resolve(response);
})
.catch(err => {
return reject(err);
});
});
}
updatePersonById(id = "",person={}) {
return new Promise((resolve, reject) => {
const url = 'https://' + this.company_domain +'.pipedrive.com/v1/' + "persons/" + `${id}`+'?api_token='+this.api_token;
const data = {person:person};
axios
.put(url,data)
.then(response => {
return resolve(response);
})
.catch(err => {
return reject(err);
});
});
}
addNote(content = "") {
return new Promise((resolve, reject) => {
const url = 'https://' + this.company_domain+ '.pipedrive.com/v1/'+"notes?api_token="+this.api_token;
const data = { content: content };
axios
.post(url, data)
.then(response => {
return resolve(response);
})
.catch(err => {
return reject(err);
});
});
}
webHook1(person={})
{
const person = person;
if(person.update_time === person.add_time){
person.flag="Created";
}else{
person.flag="Updated";
}
}
}