ruby-todoist-api-v7 1.0.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df19e65ed5e5d8219709deb6ada10a2e52089449f83d84d840174ccd2d65ee06
4
- data.tar.gz: 6fb988cf0bf314284854d496150729045c0b4156b10c77252a55c64f7de51acb
3
+ metadata.gz: 890aa4ab100332126c65d1c5cc7f2a92ff2d59ed5cb9956f7760bece49af9f52
4
+ data.tar.gz: 6ee1faf254430cac124564881d16c6427c4d8232fc0d409c5bd8a5e25f36d5e0
5
5
  SHA512:
6
- metadata.gz: 03a93424bafb16a76eab65bd7d2bf5f337c1bbb02e06e12420ab5fb37a1a27a5e5d33ebc885cc05a176e80fcddad60b6733f6eeecf2943fe7859054c30247798
7
- data.tar.gz: d25232ea6aaeed8cce29d47bcec77e8c79e16109ccb168acdb03efaca6a33a1cd1a2eccff9a81280ed18cd7ecdc9dc1adf497648aad2a2af15d086ac47ff89a5
6
+ metadata.gz: bac45a3dad615c66762bb9dee9bac14c444b29290f861259bb4fb44e364b7ae909e0aa3beabd8d4b77edcb1687d2e2da80727cab3f63a27a51cca208521a86bd
7
+ data.tar.gz: f1cd84ae4e65f4e77ed9e6cdc8f9b18adf9ef6f0bbc3ae2aa27d5db7034f1f32391f610bc7a515700211f7ef1df188e033a7c4ec3ec8ab30ed747403aa52d60b
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ ruby-todoist-api*.gem
@@ -25,8 +25,13 @@ module Todoist
25
25
  is_archived
26
26
  sync_id
27
27
  date_added
28
+
29
+ all_day
30
+ date_completed
31
+ parent_id
28
32
  )
29
33
 
34
+
30
35
  def project=(project)
31
36
  self.project_id = project.to_hash['id']
32
37
  end
@@ -5,8 +5,14 @@ module Todoist
5
5
  attr_reader :data
6
6
 
7
7
  def initialize(result)
8
+ if result['type'] == 'viewall' then
9
+ data = flatten(result['data'])
10
+ else
11
+ data = result['data']
12
+ end
13
+
8
14
  @query = result['query']
9
- @data = result['data']
15
+ @data = data
10
16
  end
11
17
 
12
18
  def each(&block)
@@ -19,6 +25,12 @@ module Todoist
19
25
  data.size
20
26
  end
21
27
 
28
+ private
29
+
30
+ def flatten(data)
31
+ data.map{|project_block| project_block['uncompleted'] }.flatten
32
+ end
33
+
22
34
  end
23
35
 
24
36
  class Query
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -22,5 +22,17 @@ describe Todoist::Query do
22
22
  expect(result['tomorrow'].size).to eq 2
23
23
  expect(result['tomorrow'].first.id).to eq 35825425
24
24
  end
25
+
26
+ it "flattens results of 'view all' query" do
27
+ stub_request(:post, "https://todoist.com/API/v7/query").
28
+ with(:body => {"queries"=>"[\"view all\"]", "token"=>"api_token"}).
29
+ to_return(:status => 200, :body => json_response_raw('query_view_all'), :headers => {})
30
+
31
+ result = query.search(['view all'])[nil]
32
+
33
+ expect(result.size).to eq 3
34
+ expect(result.map{|item| item.content}.flatten).to eq ["foo", "bar", "baz"]
35
+ end
36
+
25
37
  end
26
38
  end
@@ -3,52 +3,49 @@
3
3
  "query": "tomorrow",
4
4
  "type": "date",
5
5
  "data": [
6
- { "due_date": "Wed 08 Oct 2014 20:59:59 +0000",
7
- "is_deleted": 0,
6
+ { "is_deleted": 0,
8
7
  "assigned_by_uid": 1855589,
9
8
  "is_archived": 0,
10
9
  "labels": [],
11
10
  "sync_id": null,
12
- "day_order": 0,
13
- "postpone_count": 0,
11
+ "date_completed": null,
12
+ "all_day": false,
14
13
  "in_history": 0,
15
- "has_notifications": 0,
16
- "indent": 1,
17
14
  "date_added": "Tue 07 Oct 2014 06:11:06 +0000",
18
- "user_id": 1855589,
19
- "children": null,
15
+ "indent": 1,
16
+ "date_lang": "en",
17
+ "id": 35825425,
20
18
  "priority": 1,
21
- "complete_count": 0,
22
19
  "checked": 0,
23
- "id": 35825425,
20
+ "user_id": 1855589,
21
+ "due_date_utc": "Wed 08 Oct 2014 20:59:59 +0000",
24
22
  "content": "Task2",
23
+ "parent_id": null,
25
24
  "item_order": 2,
26
- "seq_no": 2306453653,
27
25
  "responsible_uid": null,
28
26
  "project_id": 128501470,
29
27
  "collapsed": 0,
30
28
  "date_string": "8 Oct" },
31
- { "due_date": "Wed 08 Oct 2014 20:59:59 +0000",
29
+ {
32
30
  "is_deleted": 0,
33
31
  "assigned_by_uid": 1855589,
34
32
  "is_archived": 0,
35
33
  "labels": [],
36
34
  "sync_id": null,
37
- "day_order": 1,
38
- "postpone_count": 0,
35
+ "date_completed": null,
36
+ "all_day": false,
39
37
  "in_history": 0,
40
- "has_notifications": 0,
41
- "indent": 1,
42
38
  "date_added": "Tue 07 Oct 2014 06:20:48 +0000",
43
- "user_id": 1855589,
44
- "children": null,
39
+ "indent": 1,
40
+ "date_lang": "en",
41
+ "id": 35826737,
45
42
  "priority": 1,
46
- "complete_count": 0,
47
43
  "checked": 0,
48
- "id": 35826737,
44
+ "user_id": 1855589,
45
+ "due_date_utc": "Wed 08 Oct 2014 20:59:59 +0000",
49
46
  "content": "Task 3",
47
+ "parent_id": null,
50
48
  "item_order": 3,
51
- "seq_no": 2306541514,
52
49
  "responsible_uid": null,
53
50
  "project_id": 128501470,
54
51
  "collapsed": 0,
@@ -59,26 +56,25 @@
59
56
  "query": "p1",
60
57
  "type": "priority",
61
58
  "data": [
62
- { "due_date": null,
63
- "is_deleted": 0,
59
+ { "is_deleted": 0,
64
60
  "assigned_by_uid": 1855589,
65
61
  "is_archived": 0,
66
62
  "labels": [],
67
63
  "sync_id": null,
68
- "postpone_count": 5,
64
+ "date_completed": null,
65
+ "all_day": false,
69
66
  "in_history": 0,
70
- "has_notifications": 0,
71
- "indent": 1,
72
67
  "date_added": "Fri 26 Sep 2014 11:54:48 +0000",
73
- "user_id": 1855589,
74
- "children": null,
68
+ "indent": 1,
69
+ "date_lang": "en",
70
+ "id": 33548400,
75
71
  "priority": 4,
76
- "complete_count": 1,
77
72
  "checked": 0,
78
- "id": 33548400,
73
+ "user_id": 1855589,
74
+ "due_date_utc": null,
79
75
  "content": "Task1",
76
+ "parent_id": null,
80
77
  "item_order": 1,
81
- "seq_no": 2306454606,
82
78
  "responsible_uid": null,
83
79
  "project_id": 128501470,
84
80
  "collapsed": 0,
@@ -0,0 +1,100 @@
1
+ [
2
+ {
3
+ "data": [
4
+ {
5
+ "project_name": "Inbox",
6
+ "completed_count": 0,
7
+ "uncompleted": [
8
+ {
9
+ "is_deleted": 0,
10
+ "assigned_by_uid": null,
11
+ "is_archived": 0,
12
+ "labels": [],
13
+ "sync_id": null,
14
+ "date_completed": null,
15
+ "all_day": false,
16
+ "in_history": 0,
17
+ "date_added": "Fri 11 May 2018 16:07:48 +0000",
18
+ "indent": 1,
19
+ "date_lang": null,
20
+ "id": 2647597413,
21
+ "priority": 1,
22
+ "checked": 0,
23
+ "user_id": 9933517,
24
+ "due_date_utc": null,
25
+ "content": "foo",
26
+ "parent_id": null,
27
+ "item_order": 1,
28
+ "responsible_uid": null,
29
+ "project_id": 185577290,
30
+ "collapsed": 0,
31
+ "date_string": null
32
+ }
33
+ ],
34
+ "history_max_order": 0,
35
+ "cache_count": 0,
36
+ "project_id": 185577290
37
+ },
38
+ {
39
+ "project_name": "Personal",
40
+ "completed_count": 0,
41
+ "uncompleted": [
42
+ {
43
+ "is_deleted": 0,
44
+ "assigned_by_uid": null,
45
+ "is_archived": 0,
46
+ "labels": [],
47
+ "sync_id": null,
48
+ "date_completed": null,
49
+ "all_day": false,
50
+ "in_history": 0,
51
+ "date_added": "Sun 01 Oct 2017 08:27:29 +0000",
52
+ "indent": 1,
53
+ "date_lang": null,
54
+ "id": 2346456937,
55
+ "priority": 1,
56
+ "checked": 0,
57
+ "user_id": 9933517,
58
+ "due_date_utc": null,
59
+ "content": "bar",
60
+ "parent_id": null,
61
+ "item_order": 1,
62
+ "responsible_uid": null,
63
+ "project_id": 185577291,
64
+ "collapsed": 0,
65
+ "date_string": null
66
+ },
67
+ {
68
+ "is_deleted": 0,
69
+ "assigned_by_uid": null,
70
+ "is_archived": 0,
71
+ "labels": [],
72
+ "sync_id": null,
73
+ "date_completed": null,
74
+ "all_day": false,
75
+ "in_history": 0,
76
+ "date_added": "Sun 01 Oct 2017 19:16:00 +0000",
77
+ "indent": 1,
78
+ "date_lang": null,
79
+ "id": 2346910752,
80
+ "priority": 1,
81
+ "checked": 0,
82
+ "user_id": 9933517,
83
+ "due_date_utc": null,
84
+ "content": "baz",
85
+ "parent_id": null,
86
+ "item_order": 2,
87
+ "responsible_uid": null,
88
+ "project_id": 185577291,
89
+ "collapsed": 0,
90
+ "date_string": null
91
+ }
92
+ ],
93
+ "history_max_order": 0,
94
+ "cache_count": 0,
95
+ "project_id": 185577291
96
+ }
97
+ ],
98
+ "type": "viewall"
99
+ }
100
+ ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-todoist-api-v7
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten van Vliet
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-09 00:00:00.000000000 Z
12
+ date: 2018-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -102,6 +102,7 @@ files:
102
102
  - spec/support/responses/note.json
103
103
  - spec/support/responses/project.json
104
104
  - spec/support/responses/query.json
105
+ - spec/support/responses/query_view_all.json
105
106
  - spec/support/responses/reminder.json
106
107
  homepage: https://github.com/stesie/ruby-todoist-api
107
108
  licenses:
@@ -151,4 +152,5 @@ test_files:
151
152
  - spec/support/responses/note.json
152
153
  - spec/support/responses/project.json
153
154
  - spec/support/responses/query.json
155
+ - spec/support/responses/query_view_all.json
154
156
  - spec/support/responses/reminder.json