Merge pull request #421 from gsiou/master

API functionality: get all lists, get list by id
This commit is contained in:
Tomas Bures 2018-05-21 06:03:46 -07:00 committed by GitHub
commit b74c4d9438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 0 deletions

View file

@ -348,6 +348,37 @@ router.get('/subscriptions/:listId', (req, res) => {
});
});
router.get('/lists', (req, res) => {
lists.quicklist((err, lists) => {
if (err) {
res.status(500);
return res.json({
error: err.message || err,
data: []
});
}
res.status(200);
res.json({
data: lists
});
});
});
router.get('/list/:id', (req, res) => {
lists.get(req.params.id, (err, list) => {
if (err) {
res.status(500);
return res.json({
error: err.message || err,
});
}
res.status(200);
res.json({
data: list
});
});
});
router.get('/lists/:email', (req, res) => {
lists.getListsWithEmail(req.params.email, (err, lists) => {
if (err) {

View file

@ -296,3 +296,41 @@
</p>
<pre>curl -XGET '{{serviceUrl}}api/lists/test@example.com?access_token={{accessToken}} </pre>
<h3>GET /api/lists {{#translate}}Get all lists{{/translate}}</h3>
<p>
{{#translate}}Retrieve every list. {{/translate}}
</p>
<p>
<strong>GET</strong> {{#translate}}arguments{{/translate}}
</p>
<ul>
<li><strong>access_token</strong> {{#translate}}your personal access token{{/translate}}
</ul>
<p>
<strong>{{#translate}}Example{{/translate}}</strong>
</p>
<pre>curl -XGET '{{serviceUrl}}api/lists?access_token={{accessToken}}'</pre>
<h3>GET /api/list/:id {{#translate}}Get list by id{{/translate}}</h3>
<p>
{{#translate}}Retrieve the list with :id {{/translate}}
</p>
<p>
<strong>GET</strong> {{#translate}}arguments{{/translate}}
</p>
<ul>
<li><strong>access_token</strong> {{#translate}}your personal access token{{/translate}}
</ul>
<p>
<strong>{{#translate}}Example{{/translate}}</strong>
</p>
<pre>curl -XGET '{{serviceUrl}}api/list/1?access_token={{accessToken}}'</pre>