wndrlst 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 +5 -0
- data/lib/wndrlst.rb +47 -17
- data/lib/wndrlst/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: a4952147fbba79cf96d9278ea1f706e52be86a4e
|
4
|
+
data.tar.gz: ebdddf7211d41c55f01c925a05acf2e88f74471d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af6a373c8638b5a6c3955d381381630d178d14c20877d1710bd3ea19a1d512b55a5e70bdea8e1b5c4225e1d628a418f8680c708eb5eb7e8426b4760456624356
|
7
|
+
data.tar.gz: 54d17eb487bda333a2a5b08ca089773cb0e4628189b85ab12eb3242cb9da727c7b1eef1e8a238b1d3cba9cec0c44a4d239d25ff86218553ca106b8fcc0efca2d
|
data/README.md
CHANGED
@@ -24,6 +24,11 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
TODO: Write usage instructions here
|
26
26
|
|
27
|
+
## History
|
28
|
+
|
29
|
+
v0.0.2: Add Method(list_id, task_title_by_list_name, tasks_by_list_name), rspec test add(a part).
|
30
|
+
v0.0.1: Initial version.
|
31
|
+
|
27
32
|
## Development
|
28
33
|
|
29
34
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/wndrlst.rb
CHANGED
@@ -7,6 +7,7 @@ module Wndrlst
|
|
7
7
|
class API
|
8
8
|
|
9
9
|
BASE_ENDPOINT = "https://a.wunderlist.com/api/v1"
|
10
|
+
attr_reader :params
|
10
11
|
|
11
12
|
def initialize(client_id, access_token)
|
12
13
|
@client_id = client_id
|
@@ -18,52 +19,71 @@ module Wndrlst
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def user
|
21
|
-
get(generate_url('user',
|
22
|
+
get(generate_url('user', params))
|
22
23
|
end
|
23
24
|
|
24
25
|
def lists
|
25
|
-
get(generate_url('lists',
|
26
|
+
get(generate_url('lists', params))
|
26
27
|
end
|
27
28
|
|
28
29
|
def list(id)
|
29
|
-
get(generate_url('lists',
|
30
|
+
get(generate_url('lists', params, id))
|
31
|
+
end
|
32
|
+
|
33
|
+
def list_titles
|
34
|
+
lists.collect{|list| list[:title]}
|
30
35
|
end
|
31
36
|
|
32
37
|
def tasks(list_id, completed=false)
|
33
|
-
|
34
|
-
|
38
|
+
params = @params
|
39
|
+
params['list_id'] = list_id
|
40
|
+
params['completed'] = completed
|
41
|
+
|
42
|
+
get(generate_url('tasks', params, params))
|
43
|
+
end
|
44
|
+
|
45
|
+
def task_titles(list_id, completed=false)
|
46
|
+
tasks(list_id, completed).collecct {|task| task[:title]}
|
47
|
+
end
|
35
48
|
|
36
|
-
|
49
|
+
def tasks_by_list_name(title, completed=false)
|
50
|
+
tasks(list_id(title), completed)
|
51
|
+
end
|
52
|
+
|
53
|
+
def task_title_by_list_name(title, completed=false)
|
54
|
+
tasks_by_list_name(title, completed).collect{|task| task[:title]}
|
37
55
|
end
|
38
56
|
|
39
57
|
def task(id)
|
40
|
-
get(generate_url('tasks',
|
58
|
+
get(generate_url('tasks', params, id))
|
41
59
|
end
|
42
60
|
|
43
61
|
def subtasks(task_id, completed=false)
|
44
|
-
|
45
|
-
|
62
|
+
params = @params
|
63
|
+
params['task_id'] = task_id
|
64
|
+
params['completed'] = completed
|
46
65
|
|
47
|
-
get(generate_url('subtasks',
|
66
|
+
get(generate_url('subtasks', params))
|
48
67
|
end
|
49
68
|
|
50
69
|
def subtasks_from_list(list_id, completed=false)
|
51
|
-
|
52
|
-
|
70
|
+
params = @params
|
71
|
+
params['list_id'] = list_id
|
72
|
+
params['completed'] = completed
|
53
73
|
|
54
|
-
get(generate_url('subtasks',
|
74
|
+
get(generate_url('subtasks', params))
|
55
75
|
end
|
56
76
|
|
57
77
|
private
|
58
78
|
|
59
79
|
def generate_url(resource, params, target_id=nil)
|
60
|
-
|
61
|
-
|
80
|
+
req_params = params.collect {|p, v| "#{p}=#{v}&"}.join("")
|
81
|
+
req_params.slice!(-1)
|
62
82
|
|
63
83
|
if target_id
|
64
|
-
"#{BASE_ENDPOINT}/#{resource}/#{target_id}?#{
|
84
|
+
"#{BASE_ENDPOINT}/#{resource}/#{target_id}?#{req_params}"
|
65
85
|
else
|
66
|
-
"#{BASE_ENDPOINT}/#{resource}?#{
|
86
|
+
"#{BASE_ENDPOINT}/#{resource}?#{req_params}"
|
67
87
|
end
|
68
88
|
end
|
69
89
|
|
@@ -76,5 +96,15 @@ module Wndrlst
|
|
76
96
|
|
77
97
|
JSON.parse(response.read)
|
78
98
|
end
|
99
|
+
|
100
|
+
def list_id(title)
|
101
|
+
list_id = ""
|
102
|
+
lists.each do |list|
|
103
|
+
if list[:title] == title
|
104
|
+
list_id = list[:id]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
list_id
|
108
|
+
end
|
79
109
|
end
|
80
110
|
end
|
data/lib/wndrlst/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wndrlst
|
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
|
- katsumata_ryo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|