Skip to content

Commit 7750673

Browse files
committed
- Initial commit
1 parent 2c35208 commit 7750673

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

node-nozbe-next-actions.coffee

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
rc = require 'node-restclient'
2+
_ = require('underscore')._
3+
4+
username = '[email protected]'
5+
password = 'supersecretpassword'
6+
7+
class Nozbe
8+
login: (cb)->
9+
rc.get "https://webapp.nozbe.com/api/login/email-#{username}/password-#{password}",(res)->
10+
try
11+
ret = JSON.parse res
12+
catch err
13+
return cb? "Failed login: #{err}\n"
14+
if ret.key
15+
@key = ret.key
16+
return cb? null,ret.key
17+
else
18+
return cb? "Failed login\n"
19+
20+
getNextActions: (key,cb)->
21+
url = "https://webapp.nozbe.com/api/actions/what-next/key-#{key}"
22+
rc.get "https://webapp.nozbe.com/api/actions/what-next/key-#{key}",(res)->
23+
try
24+
ret = JSON.parse res
25+
catch err
26+
return cb? "Failed to get next actions: #{err}\n"
27+
return cb? null,ret
28+
29+
n = new Nozbe
30+
n.login (err,key)->
31+
if err?
32+
return console.log err
33+
n.getNextActions key,(err,actions)->
34+
if err?
35+
return console.log err
36+
_.each actions,(a)->
37+
if not a.done
38+
console.log a.name
39+
return
40+

0 commit comments

Comments
 (0)