todoist_client 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +9 -0
- data/lib/todoist_client/api_client.rb +27 -0
- data/lib/todoist_client/base.rb +15 -0
- data/lib/todoist_client/errors.rb +4 -0
- data/lib/todoist_client/item.rb +107 -0
- data/lib/todoist_client/project.rb +93 -0
- data/lib/todoist_client/version.rb +3 -0
- data/lib/todoist_client.rb +9 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/todoist_client/.keep +0 -0
- data/todoist_client.gemspec +25 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: daaf0e3c2b23ff8f526a58e0c4bcaba96d7c8ab0
|
4
|
+
data.tar.gz: 7801782fffd4985061175702c616c43dcad303e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4b7df3adb7bf4ba4ca3c7f96585a9376796086c5aac866d27aa3432dd043fdd772a8267f2a70a531b0ff3b6128d69d7677b4b4f7c73c909f5418dd59783a61b
|
7
|
+
data.tar.gz: bc0641e163de0eb16f1b761143b4817df1cccceb2a3b219734d3a4bbd3e948658c42eef88b1edf4d29f8f8797dc42c887234d3f35f89f42c26640059c121a222
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 i2bskn
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# TodoistClient
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'todoist_client'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install todoist_client
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/todoist_client/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module TodoistClient
|
2
|
+
module ApiClient
|
3
|
+
BASE_URI = "https://api.todoist.com"
|
4
|
+
|
5
|
+
def self.included(klass)
|
6
|
+
klass.extend ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def request(method, endpoint, params = nil)
|
11
|
+
p "#{BASE_URI}#{endpoint}"
|
12
|
+
p query_string(params)
|
13
|
+
JSON.load RestClient.send(method, "#{BASE_URI}#{endpoint}", query_string(params))
|
14
|
+
end
|
15
|
+
|
16
|
+
def query_string(params = nil)
|
17
|
+
raise NoApiToken, "API Token not find" unless TodoistClient.api_token
|
18
|
+
params ||= {}
|
19
|
+
{
|
20
|
+
params: {
|
21
|
+
token: TodoistClient.api_token
|
22
|
+
}.merge(params)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module TodoistClient
|
2
|
+
class Item
|
3
|
+
include ApiClient
|
4
|
+
|
5
|
+
VALID_PARAMS = [
|
6
|
+
:due_date,
|
7
|
+
:user_id,
|
8
|
+
:collapsed,
|
9
|
+
:in_history,
|
10
|
+
:priority,
|
11
|
+
:item_order,
|
12
|
+
:content,
|
13
|
+
:indent,
|
14
|
+
:project_id,
|
15
|
+
:id,
|
16
|
+
:checked,
|
17
|
+
:date_string
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
attr_accessor *VALID_PARAMS
|
21
|
+
|
22
|
+
module Paths
|
23
|
+
UNCOMPLETED = [:get, "/API/getUncompletedItems"]
|
24
|
+
COMPLETED = [:get, "/API/getCompletedItems"]
|
25
|
+
FIND = [:get, "/API/getItemsById"]
|
26
|
+
ADD = [:get, "/API/addItem"]
|
27
|
+
UPDATE = [:get, "/API/updateItem"]
|
28
|
+
DELETE = [:get, "/API/deleteItems"]
|
29
|
+
COMPLETE = [:get, "/API/completeItems"]
|
30
|
+
UNCOMPLETE = [:get, "/API/uncompleteItems"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(params = nil)
|
34
|
+
set_params(params) if params
|
35
|
+
end
|
36
|
+
|
37
|
+
def save
|
38
|
+
if id
|
39
|
+
json = self.class.request *Paths::UPDATE, {
|
40
|
+
id: id,
|
41
|
+
content: content
|
42
|
+
}
|
43
|
+
else
|
44
|
+
json = self.class.request *Paths::ADD, {
|
45
|
+
content: content,
|
46
|
+
project_id: project_id
|
47
|
+
}
|
48
|
+
end
|
49
|
+
set_params(json)
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete
|
53
|
+
self.class.request *Paths::DELETE, {ids: JSON.generate([id])} if id
|
54
|
+
end
|
55
|
+
|
56
|
+
def complete
|
57
|
+
self.class.request *Paths::COMPLETE, {ids: JSON.generate([id])} if id
|
58
|
+
end
|
59
|
+
|
60
|
+
def uncomplete
|
61
|
+
self.class.request *Paths::UNCOMPLETE, {ids: JSON.generate([id])} if id
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_params(params)
|
65
|
+
params.each do |k,v|
|
66
|
+
self.send "#{k}=", v if self.respond_to? "#{k}="
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class << self
|
71
|
+
def uncompleted(project_id)
|
72
|
+
request(*Paths::UNCOMPLETED, {project_id: project_id}).map { |item|
|
73
|
+
self.new(item)
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def completed(project_id)
|
78
|
+
request(*Paths::COMPLETED, {project_id: project_id}).map { |item|
|
79
|
+
self.new(item)
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def find(ids)
|
84
|
+
request(*Paths::FIND, {ids: json_ids(ids)}).map { |item|
|
85
|
+
self.new(item)
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
def delete_all(ids)
|
90
|
+
request *Paths::DELETE, {ids: json_ids(ids)}
|
91
|
+
end
|
92
|
+
|
93
|
+
def complete_all(ids)
|
94
|
+
request *Paths::COMPLETE, {ids: json_ids(ids)}
|
95
|
+
end
|
96
|
+
|
97
|
+
def uncomplete_all(ids)
|
98
|
+
request *Paths::UNCOMPLETE, {ids: json_ids(ids)}
|
99
|
+
end
|
100
|
+
|
101
|
+
def json_ids(ids)
|
102
|
+
ids = [ids] unless ids.is_a?(Array)
|
103
|
+
JSON.generate(ids)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module TodoistClient
|
2
|
+
class Project
|
3
|
+
include ApiClient
|
4
|
+
|
5
|
+
VALID_PARAMS = [
|
6
|
+
:user_id,
|
7
|
+
:name,
|
8
|
+
:color,
|
9
|
+
:collapsed,
|
10
|
+
:item_order,
|
11
|
+
:cache_count,
|
12
|
+
:indent,
|
13
|
+
:id,
|
14
|
+
:last_updated
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
attr_accessor *VALID_PARAMS
|
18
|
+
|
19
|
+
module Paths
|
20
|
+
ALL = [:get, "/API/getProjects"]
|
21
|
+
FIND = [:get, "/API/getProject"]
|
22
|
+
ADD = [:get, "/API/addProject"]
|
23
|
+
UPDATE = [:get, "/API/updateProject"]
|
24
|
+
DELETE = [:get, "/API/deleteProject"]
|
25
|
+
# ARCHIVE = [:get, "/API/archiveProject"]
|
26
|
+
# UNARCHIVE = [:get, "/API/unarchiveProject"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(params = nil)
|
30
|
+
set_params(params) if params
|
31
|
+
end
|
32
|
+
|
33
|
+
def save
|
34
|
+
if id
|
35
|
+
json = self.class.request *Paths::UPDATE, {
|
36
|
+
project_id: id,
|
37
|
+
name: name,
|
38
|
+
color: color,
|
39
|
+
indent: indent,
|
40
|
+
order: item_order
|
41
|
+
}
|
42
|
+
else
|
43
|
+
json = self.class.request *Paths::ADD, {
|
44
|
+
name: name,
|
45
|
+
color: color,
|
46
|
+
indent: indent,
|
47
|
+
order: item_order
|
48
|
+
}
|
49
|
+
end
|
50
|
+
set_params(json)
|
51
|
+
end
|
52
|
+
|
53
|
+
def delete
|
54
|
+
self.class.request *Paths::DELETE, {project_id: id} if id
|
55
|
+
end
|
56
|
+
|
57
|
+
# def archive
|
58
|
+
# self.class.request *Paths::ARCHIVE, {project_id: id} if id
|
59
|
+
# end
|
60
|
+
|
61
|
+
# def unarchive
|
62
|
+
# self.class.request *Paths::UNARCHIVE, {project_id: id} if id
|
63
|
+
# end
|
64
|
+
|
65
|
+
def uncompleted_items
|
66
|
+
Item.uncompleted(id) if id
|
67
|
+
end
|
68
|
+
|
69
|
+
def completed_items
|
70
|
+
Item.completed(id) if id
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_params(params)
|
74
|
+
params.each do |k,v|
|
75
|
+
self.send "#{k}=", v if self.respond_to? "#{k}="
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class << self
|
80
|
+
def all
|
81
|
+
request(*Paths::ALL).map {|project| self.new(project)}
|
82
|
+
end
|
83
|
+
|
84
|
+
def find(id)
|
85
|
+
self.new(request(*Paths::FIND, {project_id: id}))
|
86
|
+
end
|
87
|
+
|
88
|
+
def create(name)
|
89
|
+
self.new(name).save
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'todoist_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "todoist_client"
|
8
|
+
spec.version = TodoistClient::VERSION
|
9
|
+
spec.authors = ["i2bskn"]
|
10
|
+
spec.email = ["i2bskn@gmail.com"]
|
11
|
+
spec.summary = %q{Todoist API client}
|
12
|
+
spec.description = %q{Todoist API client}
|
13
|
+
spec.homepage = "https://github.com/i2bskn/todoist_client"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_dependency "rest_client"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: todoist_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- i2bskn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rest_client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Todoist API client
|
70
|
+
email:
|
71
|
+
- i2bskn@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/todoist_client.rb
|
82
|
+
- lib/todoist_client/api_client.rb
|
83
|
+
- lib/todoist_client/base.rb
|
84
|
+
- lib/todoist_client/errors.rb
|
85
|
+
- lib/todoist_client/item.rb
|
86
|
+
- lib/todoist_client/project.rb
|
87
|
+
- lib/todoist_client/version.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/todoist_client/.keep
|
90
|
+
- todoist_client.gemspec
|
91
|
+
homepage: https://github.com/i2bskn/todoist_client
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Todoist API client
|
115
|
+
test_files:
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/todoist_client/.keep
|