Skip to content

Commit

Permalink
Add search contact by field
Browse files Browse the repository at this point in the history
  • Loading branch information
jihanzhang committed Jun 11, 2019
1 parent 995d679 commit 1547d15
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
14 changes: 14 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ app.get("/getLeads", function(req, res) {
});
});

app.get("/getByPhone", function(req, res) {
ZCRMRestClient.initialize().then(function() {
let input = {};
input.module = "Leads";
let params = {};
params.phone = req.query.phone;
params.page = 0;
params.per_page = 100;
input.params = params;

getbyModule.search(input, res);
});
});

app.listen(3000, () => {
console.log("listening on port 3000");
});
Expand Down
9 changes: 9 additions & 0 deletions getModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@ module.exports = {
let result = wrap.wrapresult(input.module, data);
res.set("Content-Type", "text/html");
res.send(result);
},

search: function(input, res) {
ZCRMRestClient.API.MODULES.search(input).then(function(response) {
let data = JSON.parse(response.body).data;
let result = wrap.wrapresult(input.module, data);
res.set("Content-Type", "text/html");
res.send(result);
});
}
};
17 changes: 14 additions & 3 deletions wrapresult.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
module.exports = {
wrapresult: function(header, data) {
let result = `<html><body><center><b>${header}</b></center><br/>
<table style="width:100%">
let result = `<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<div class="container">
<div class="jumbotron">
<h1><center>${header}</center></h1>
</div>
<table class="table table-dark">
<tr>
<th>Name</th>
<th>Gender</th>
Expand All @@ -20,7 +27,11 @@ module.exports = {
<td align="left"> ${Description}</td>
<tr />`;
}
result += "</tr></tabel></body></html>";
result += `</tr>
</tabel>
</div>
</body>
</html>`;
return result;
}
};

0 comments on commit 1547d15

Please sign in to comment.