wunderlist-api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -9
- data/lib/wunderlist/api.rb +1 -2
- data/lib/wunderlist/note.rb +16 -6
- data/lib/wunderlist/task.rb +21 -16
- data/lib/wunderlist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0e09c6b046a20429837db1b03ba46148d4fadfb
|
4
|
+
data.tar.gz: 3c60354c7d22ff9c05e23d6378d42e7cf639e927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 988e3091a85eb60631ce1a78fa499b6766ac3c943dda7c7ff0e399708e7d9a307bb9fede62ebf118b1b44e81adedba5d48ab396a37f63df3ff708f1f6a853192
|
7
|
+
data.tar.gz: d732fc1c2fadd0502ee722662a29a3d5c97aaee673c1709f1c90f74f39e60f097831302b78efa8e167043bc329eebe0d6029e05cd4c37590294b23ee4420887e
|
data/README.md
CHANGED
@@ -25,20 +25,22 @@ wl = Wunderlist::API.new({
|
|
25
25
|
:client_id => <your client id>
|
26
26
|
})
|
27
27
|
|
28
|
+
|
28
29
|
# You can create Task
|
29
|
-
wl.
|
30
|
+
task = wl.new_task(LIST_NAME, {'title' => 'Hello World', 'completed' => true, 'due_date' => '2015-03-25' })
|
31
|
+
task.save
|
30
32
|
|
31
|
-
# You can get Wunderlist::Task Object
|
32
|
-
task = wl.tasks([LIST_NAME])[0]
|
33
|
-
=> #<Wunderlist::Task:0x00000000000>
|
34
33
|
|
35
|
-
# You can
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
34
|
+
# You can get Wunderlist::Task Object Wrapped by Array
|
35
|
+
tasks = wl.tasks([LIST_NAME1, LIST_NAME2])
|
36
|
+
=> [#<Wunderlist::Task:0x00000000000>, #<Wunderlist::Task:0x11111111111>, ...]
|
37
|
+
|
40
38
|
|
39
|
+
# You can create and update note.
|
40
|
+
note = task.note
|
41
41
|
=> #<Wunderlist::Note:0x00000000000>
|
42
|
+
note.content = "Hello World"
|
43
|
+
note.save
|
42
44
|
|
43
45
|
```
|
44
46
|
|
@@ -49,4 +51,6 @@ end
|
|
49
51
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
52
|
4. Push to the branch (`git push origin my-new-feature`)
|
51
53
|
5. Create new Pull Request
|
54
|
+
|
52
55
|
# wunderlist-api
|
56
|
+
|
data/lib/wunderlist/api.rb
CHANGED
@@ -43,13 +43,12 @@ module Wunderlist
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def new_task(list_name, attrs = {})
|
47
47
|
list_name = [list_name]
|
48
48
|
list_id = get_list_ids(list_name)[0]
|
49
49
|
attrs['list_id'] = list_id
|
50
50
|
attrs['api'] = self
|
51
51
|
@task = Wunderlist::Task.new(attrs)
|
52
|
-
@task.save
|
53
52
|
end
|
54
53
|
|
55
54
|
def request(method, url, options = {})
|
data/lib/wunderlist/note.rb
CHANGED
@@ -6,8 +6,7 @@ module Wunderlist
|
|
6
6
|
|
7
7
|
include Wunderlist::Helper
|
8
8
|
|
9
|
-
attr_accessor :content, :api
|
10
|
-
attr_reader :id, :task_id, :created_at, :updated_at, :revision
|
9
|
+
attr_accessor :id, :content, :api, :task_id, :created_at, :updated_at, :revision
|
11
10
|
|
12
11
|
def initialize(options = {})
|
13
12
|
@api = options['api']
|
@@ -20,15 +19,26 @@ module Wunderlist
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def update
|
22
|
+
self.api.request :put, "api/v1/notes/#{self.id}", self.to_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def save
|
23
26
|
if self.id.nil?
|
24
|
-
self.
|
27
|
+
res = self.api.request :post, "api/v1/notes", self.to_hash
|
25
28
|
else
|
26
|
-
|
29
|
+
res = self.update
|
27
30
|
end
|
31
|
+
self.set_attrs(res)
|
28
32
|
end
|
29
33
|
|
30
|
-
def
|
31
|
-
|
34
|
+
def set_attrs(res)
|
35
|
+
self.api = res['api']
|
36
|
+
self.id = res['id']
|
37
|
+
self.task_id = res['task_id']
|
38
|
+
self.content = res['content']
|
39
|
+
self.created_at = res['created_at']
|
40
|
+
self.updated_at = res['updated_at']
|
41
|
+
self.revision = res['revision']
|
32
42
|
end
|
33
43
|
|
34
44
|
end
|
data/lib/wunderlist/task.rb
CHANGED
@@ -7,8 +7,7 @@ module Wunderlist
|
|
7
7
|
|
8
8
|
include Wunderlist::Helper
|
9
9
|
|
10
|
-
attr_accessor :api, :title, :assignee_id, :completed, :recurrence_type, :recurrence_count, :due_date, :starred
|
11
|
-
attr_reader :id, :list_id
|
10
|
+
attr_accessor :api, :title, :assignee_id, :completed, :revision, :recurrence_type, :recurrence_count, :due_date, :starred, :id, :list_id, :created_at
|
12
11
|
|
13
12
|
def initialize(options = {})
|
14
13
|
@api = options['api']
|
@@ -24,7 +23,8 @@ module Wunderlist
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def save
|
27
|
-
self.api.request :post, 'api/v1/tasks', self.to_hash
|
26
|
+
res = self.api.request :post, 'api/v1/tasks', self.to_hash
|
27
|
+
self.set_attrs(res)
|
28
28
|
end
|
29
29
|
|
30
30
|
def task_comments
|
@@ -41,24 +41,29 @@ module Wunderlist
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def note
|
45
45
|
res = self.api.request :get, 'api/v1/notes', {:task_id => self.id}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
note = Wunderlist::Note.new(note)
|
50
|
-
note.api = self.api
|
51
|
-
notes << note
|
52
|
-
end
|
53
|
-
|
54
|
-
if notes.empty?
|
46
|
+
if !res[0].nil?
|
47
|
+
note = Wunderlist::Note.new(res[0])
|
48
|
+
else
|
55
49
|
note = Wunderlist::Note.new('task_id' => self.id)
|
56
|
-
note.api = self.api
|
57
|
-
notes << note
|
58
50
|
end
|
59
51
|
|
60
|
-
|
52
|
+
note.api = self.api
|
53
|
+
note.task_id = self.id
|
54
|
+
|
55
|
+
note
|
56
|
+
|
57
|
+
end
|
61
58
|
|
59
|
+
def set_attrs(res)
|
60
|
+
self.id = res['id']
|
61
|
+
self.title = res['title']
|
62
|
+
self.created_at = res['created_at']
|
63
|
+
self.completed = res['completed']
|
64
|
+
self.list_id = res['list_id']
|
65
|
+
self.starred = res['starred']
|
66
|
+
self.revision = res['revision']
|
62
67
|
end
|
63
68
|
|
64
69
|
end
|
data/lib/wunderlist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wunderlist-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shun3475
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|