todoist-api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +14 -0
- data/lib/todo.rb +18 -0
- data/lib/todoist_api.rb +39 -0
- metadata +66 -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
|
+
|
data/lib/todo.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'todoist_api'
|
4
|
+
require 'configuration'
|
5
|
+
|
6
|
+
include Configuration
|
7
|
+
|
8
|
+
# work in progress
|
9
|
+
# TODO:
|
10
|
+
# * get predefined props from YAML
|
11
|
+
# * externalize email and pswd
|
12
|
+
# * query mechanism
|
13
|
+
# * use som cli project
|
14
|
+
|
15
|
+
init
|
16
|
+
todoist = TodoistApi.new load
|
17
|
+
todoist.login
|
18
|
+
todoist.add_item "ARGV[0]"
|
data/lib/todoist_api.rb
ADDED
@@ -0,0 +1,39 @@
|
|
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 config
|
10
|
+
@options = {}
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
def login
|
15
|
+
p "do login with user: #{@config["user"]}"
|
16
|
+
@options[:token] = self.class.get("/login?email=#{@config["user"]}&password=#{@config["pswd"]}")["api_token"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def projects
|
20
|
+
self.class.get("/getProjects", build_query)
|
21
|
+
end
|
22
|
+
|
23
|
+
def items project_id
|
24
|
+
self.class.get("/getUncompletedItems", build_query(:project_id => project_id)).collect do |item|
|
25
|
+
item["content"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_item content
|
30
|
+
self.class.get("/addItem?priority=1", build_query(:content => content, :project_id => @config["default_project_id"]))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def build_query options = {}
|
36
|
+
{:query => {:token => @options[:token]}.merge(options)}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: todoist-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
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 +02: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: true
|
38
|
+
homepage:
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.5
|
62
|
+
signing_key:
|
63
|
+
specification_version: 2
|
64
|
+
summary: Simple ruby interface for the Todoist http API.
|
65
|
+
test_files: []
|
66
|
+
|