blackhacker-todoist-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +14 -0
  2. data/lib/todo.rb +20 -0
  3. data/lib/todoist_api.rb +46 -0
  4. metadata +65 -0
data/README ADDED
@@ -0,0 +1,14 @@
1
+ == todoist-api
2
+
3
+ A simple ruby API for the todoist http interface.
4
+
5
+ Inspired by this http://bit.ly/KJzzU article from rubybestpractices.com I created
6
+ a small API which you could use from the command line to have a fast way to
7
+ create a todo list without to be disturbed at your daily developer work.
8
+
9
+ Simply install the gem with:
10
+
11
+ sudo gem install blackhacker-todoist-api
12
+
13
+ and link the todo.rb into your path.
14
+
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'todoist_api'
4
+
5
+ # work in progress
6
+ # TODO:
7
+ # * get predefined props from YAML
8
+ # * externalize email and pswd
9
+ # * query mechanism
10
+ # * use som cli project
11
+
12
+ todoist = TodoistApi.new
13
+ todoist.login
14
+
15
+ # some project id
16
+ project_id = 690081
17
+ content = ARGV[0]
18
+
19
+
20
+ todoist.add_item project_id, content
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ class TodoistApi
5
+ include HTTParty
6
+ base_uri "https://todoist.com/API/"
7
+ format :json
8
+
9
+ def initialize
10
+ @options = {}
11
+ end
12
+
13
+ def login
14
+ @options[:token] = self.class.get("/login?email=EMAIL&password=PSWD")["api_token"]
15
+ end
16
+
17
+ def projects
18
+ self.class.get("/getProjects", build_query)
19
+ end
20
+
21
+ def items project_id
22
+ self.class.get("/getUncompletedItems", build_query(:project_id => project_id)).collect do |item|
23
+ item["content"]
24
+ end
25
+ end
26
+
27
+ def add_item project_id, content
28
+ self.class.get("/addItem?priority=1", build_query(:content => content, :project_id => project_id))
29
+ end
30
+
31
+ private
32
+
33
+ def build_query options = {}
34
+ {:query => {:token => @options[:token]}.merge(options)}
35
+ end
36
+
37
+
38
+ end
39
+
40
+
41
+
42
+
43
+ #p todoist.login
44
+ #p todoist.projects
45
+ #p todoist.items 690081
46
+ #p todoist.add_item 690081, "das ist ein test"
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blackhacker-todoist-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thilko Richter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.4
24
+ version:
25
+ description:
26
+ email: thilko.richter@googlemail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README
35
+ - lib/todo.rb
36
+ - lib/todoist_api.rb
37
+ has_rdoc: false
38
+ homepage:
39
+ licenses:
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 2
63
+ summary: Simple ruby interface for the Todoist http API.
64
+ test_files: []
65
+