todoist-ruby 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 309884cfd24f5159481f04897d2a65521369d46de9b0326bc0587c446599dc7e
4
- data.tar.gz: bc845f7ab3208f21d8eae90e04620699d56f4aef86a98f64fe81a1686f2917d5
3
+ metadata.gz: 2bf1a0ec8e68cba1c01003e993bc9058bea2cf8ed514309aa476f43b861efa67
4
+ data.tar.gz: d13e3faa7e24520bf0ee91fc669459db6c4c1f93b943fe026f2266fb415a1857
5
5
  SHA512:
6
- metadata.gz: a5cbba7094d34bbe6d3117f3c676d29fda609a866b651004238f2fbcf410ad6005d545788ca9342a704d5aa4992c9c350352484a08422e777709c2295d4af774
7
- data.tar.gz: f18fdd9c2021ec9582e23ba252034fc4c241c6a5c35a88c3bb899301a4cf6a5edcd9a23317ddb0d6bd249617263e462f557575710a0eb9dccabde708a90641fb
6
+ metadata.gz: 8f0152338f20587ef937bdbc5e2ac86b0505888b666f0a92c14680f0c0fcef70ac3100161aad76effb47a9f83b716cccfd58f232e31495d5acb93f5aca7d139a
7
+ data.tar.gz: 0b9811b53358d791780e2bdde0213203084fa515954ee029514b88d1590bc5992c12ad9f94f5323d9b91032655b58a3215b0eec23e6bd3b8fe62a95e531c72c5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Todoist Ruby
2
2
 
3
- This is an unofficial client library that interfaces with the [Todoist API](https://developer.todoist.com/).
3
+ This is an unofficial client library that interfaces with the [Todoist API](https://developer.todoist.com/sync/v8/).
4
4
 
5
5
  ## What's implemented
6
6
 
@@ -8,21 +8,21 @@ This is an unofficial client library that interfaces with the [Todoist API](http
8
8
 
9
9
  The "sync" API is almost fully implemented with the exception of collaboration features.
10
10
 
11
- * [Projects](https://developer.todoist.com/#projects)
12
- * [Templates](https://developer.todoist.com/#templates)
13
- * [Items](https://developer.todoist.com/#items)
14
- * [Labels](https://developer.todoist.com/#labels)
15
- * [Notes](https://developer.todoist.com/#notes)
16
- * [Filters](https://developer.todoist.com/#filters)
17
- * [Reminders](https://developer.todoist.com/#reminders)
11
+ * [Projects](https://developer.todoist.com/sync/v8/#projects)
12
+ * [Templates](https://developer.todoist.com/sync/v8/#templates)
13
+ * [Items](https://developer.todoist.com/sync/v8/#items)
14
+ * [Labels](https://developer.todoist.com/sync/v8/#labels)
15
+ * [Notes](https://developer.todoist.com/sync/v8/#notes)
16
+ * [Filters](https://developer.todoist.com/sync/v8/#filters)
17
+ * [Reminders](https://developer.todoist.com/sync/v8/#reminders)
18
18
 
19
19
  ### Other APIs
20
20
 
21
- * [Miscellaneous](https://developer.todoist.com/#miscellaneous)
22
- * [Quick](https://developer.todoist.com/#quick)
23
- * [Activity](https://developer.todoist.com/#activity)
24
- * [Uploads](https://developer.todoist.com/#uploads)
25
- * [Backups](https://developer.todoist.com/#backups)
21
+ * [Miscellaneous](https://developer.todoist.com/sync/v8/#miscellaneous)
22
+ * [Quick](https://developer.todoist.com/sync/v8/#quick)
23
+ * [Activity](https://developer.todoist.com/sync/v8/#activity)
24
+ * [Uploads](https://developer.todoist.com/sync/v8/#uploads)
25
+ * [Backups](https://developer.todoist.com/sync/v8/#backups)
26
26
 
27
27
  In addition to the above mentioned APIs, there is also an implementation of the "query" method call provided (with limitations documented).
28
28
 
@@ -30,10 +30,10 @@ In addition to the above mentioned APIs, there is also an implementation of the
30
30
 
31
31
  Generally speaking collaboration features are not supported through this API but contributions are welcome and encouraged primarily due to testing limitations and the requirement to have multiple accounts. This includes:
32
32
 
33
- * [Emails](https://developer.todoist.com/#emails)
34
- * [User](https://developer.todoist.com/#user)
35
- * [Sharing](https://developer.todoist.com/#sharing)
36
- * [Live notifications](https://developer.todoist.com/#live-notifications)
33
+ * [Emails](https://developer.todoist.com/sync/v8/#emails)
34
+ * [User](https://developer.todoist.com/sync/v8/#user)
35
+ * [Sharing](https://developer.todoist.com/sync/v8/#sharing)
36
+ * [Live notifications](https://developer.todoist.com/sync/v8/#live-notifications)
37
37
 
38
38
  ## Installation
39
39
 
@@ -232,6 +232,7 @@ Use:
232
232
 
233
233
 
234
234
  ## Version History
235
+ * 0.2.4: Numerous bug fixes to address v7 to v8 changes that go beyond just an endpoint change. Passing all specs.
235
236
  * 0.2.3: Updated to v8 endpoints
236
237
  * 0.2.2: For some code paths, it seems OpenSSL does not get loaded. Added require 'openssl' to network helper
237
238
  * 0.2.1: Major refactoring of library to support implementations that require multi-user support in a concurrent environment (e.g. Rails app). The previous implementation relied heavily on class singletons. Internally, the code has been cleaned up significantly. Due to the scale of changes, 0.2.1 is not compatible 0.1.x versions of the library.
data/lib/todoist.rb CHANGED
@@ -19,7 +19,6 @@ require "todoist/misc/items"
19
19
  require "todoist/misc/quick"
20
20
  require "todoist/misc/activity"
21
21
  require "todoist/misc/backups"
22
- require "todoist/misc/query"
23
22
 
24
23
  module Todoist
25
24
 
@@ -1,9 +1,9 @@
1
1
  module Todoist
2
- class Client
2
+ class Client
3
3
 
4
4
  def self.create_client_by_token(token)
5
5
  client = Client.new
6
- client.token = token
6
+ client.token = token
7
7
  client
8
8
  end
9
9
 
@@ -17,13 +17,13 @@ module Todoist
17
17
  end
18
18
 
19
19
  def token=(token)
20
- @token = token
20
+ @token = token.chomp
21
21
  end
22
-
22
+
23
23
  def token
24
24
  @token
25
25
  end
26
-
26
+
27
27
  def sync
28
28
  @api_helper.sync
29
29
  end
@@ -112,7 +112,7 @@ module Todoist
112
112
  def initialize
113
113
  @api_helper = Todoist::Util::ApiHelper.new(self)
114
114
  end
115
-
115
+
116
116
 
117
117
 
118
118
  end
@@ -5,7 +5,6 @@ module Todoist
5
5
  # List of commands supported
6
6
  @@command_list = [
7
7
  TODOIST_SYNC_COMMAND = "/sync",
8
- TODOIST_QUERY_COMMAND = "/query",
9
8
  TODOIST_TEMPLATES_IMPORT_INTO_PROJECT_COMMAND = "/templates/import_into_project",
10
9
  TODOIST_TEMPLATES_EXPORT_AS_FILE_COMMAND = "/templates/export_as_file",
11
10
  TODOIST_TEMPLATES_EXPORT_AS_URL_COMMAND = "/templates/export_as_url",
@@ -1,50 +1,40 @@
1
1
  module Todoist
2
2
  module Misc
3
3
  class Activity < Todoist::Service
4
- include Todoist::Util
5
-
6
- # Returns the activity logs for a user. Full list of supported
7
- # parameters outlined in the API here: https://developer.todoist.com/#activity
8
- # The following objects are converted into parameters as appropriate:
9
- #
10
- # * object
11
- # * parent_project
12
- # * parent_item
13
- # * initiator
14
- # * until
15
- # * since
16
-
4
+ include Todoist::Util
5
+
6
+ # Returns the activity logs for a user.
7
+
17
8
  def get(params={})
18
9
  if params["until"]
19
10
  params["until"] = ParseHelper.format_time(params["until"])
20
11
  end
21
-
12
+
22
13
  if params["since"]
23
14
  params["since"] = ParseHelper.format_time(params["since"])
24
15
  end
25
-
16
+
26
17
  if params["object"]
27
18
  params["object_id"] = params["object"].id
28
19
  params.delete("object")
29
20
  end
30
-
21
+
31
22
  if params["parent_object"]
32
23
  params["parent_object_id"] = params["parent_object"].id
33
24
  params.delete("parent_object")
34
25
  end
35
-
26
+
36
27
  if params["parent_item"]
37
28
  params["parent_item_id"] = params["parent_item"].id
38
29
  params.delete("parent_item")
39
30
  end
40
-
31
+
41
32
  if params["initiator"]
42
33
  params["initiator_id"] = params["initiator"].id
43
34
  params.delete("initiator")
44
35
  end
45
-
36
+
46
37
  result = @client.api_helper.get_response(Config::TODOIST_ACTIVITY_GET_COMMAND, params)
47
- ParseHelper.make_objects_as_hash(result)
48
38
  end
49
39
  end
50
40
  end
@@ -1,7 +1,7 @@
1
1
  module Todoist
2
2
  module Sync
3
3
  class Items < Todoist::Service
4
- include Todoist::Util
4
+ include Todoist::Util
5
5
 
6
6
  # Return a Hash of items where key is the id of a item and value is a item
7
7
  def collection
@@ -20,7 +20,7 @@ module Todoist
20
20
 
21
21
  # Delete items given an array of items
22
22
  def delete(items)
23
- item_ids = items.collect { |item| item.id }
23
+ item_ids = items.collect { |item| item.id }
24
24
  args = {ids: item_ids.to_json}
25
25
  return @client.api_helper.command(args, "item_delete")
26
26
  end
@@ -29,59 +29,55 @@ module Todoist
29
29
  # Note that move requires a fully inflated item object because it uses
30
30
  # the project id in the item object.
31
31
  def move(item, project)
32
- project_items = {item.project_id => [item.id]}
33
- args = {project_items: project_items, to_project: project.id}
32
+ args = {id: item.id, project_id: project.id}
34
33
  return @client.api_helper.command(args, "item_move")
35
34
  end
36
-
37
- # Complete items and optionally move them to history given an array of items. When force_history = 1, items should be moved to history (where 1 is true and 0 is false, and the default is 1) This is useful when checking off sub items.
38
-
39
- def complete(items, force_history=1)
40
- item_ids = items.collect { |item| item.id }
41
- args = {ids: item_ids.to_json, force_history: force_history}
35
+
36
+ # Complete an item and optionally move them to history. When force_history = 1, items should be moved to history (where 1 is true and 0 is false, and the default is 1) This is useful when checking off sub items.
37
+
38
+ def complete(item, force_history=1)
39
+ args = {id: item.id, force_history: force_history}
42
40
  return @client.api_helper.command(args, "item_complete")
43
41
  end
44
-
45
- # Uncomplete items and move them to the active projects given an array
46
- # of items.
47
-
48
- def uncomplete(items)
49
- item_ids = items.collect { |item| item.id }
50
- args = {ids: item_ids.to_json}
42
+
43
+ # Uncomplete item and move them to the active projects
44
+
45
+ def uncomplete(item)
46
+ args = {id: item.id}
51
47
  return @client.api_helper.command(args, "item_uncomplete")
52
48
  end
53
-
54
- # Complete a recurring item given the id of the recurring item.
55
- # This method also accepts as optional a new DateTime in UTC, a date
56
- # string to reset the object to, and whether or not the item is to
57
- # be completed or not using the is_forward flag.
58
49
 
59
- def complete_recurring(item, new_date_utc = nil, date_string = nil,
50
+ # Complete a recurring item given the id of the recurring item.
51
+ # This method also accepts as optional a new DateTime in UTC, a date
52
+ # string to reset the object to, and whether or not the item is to
53
+ # be completed or not using the is_forward flag.
54
+
55
+ def complete_recurring(item, new_date_utc = nil, date_string = nil,
60
56
  is_forward = 1)
61
-
57
+
62
58
  args = {id: item.id, is_forward: is_forward}
63
59
  if new_date_utc
64
60
  # Reformat DateTime to the following string: YYYY-MM-DDTHH:MM
65
- args["new_date_utc"] = ParseHelper.format_time(new_date_utc)
61
+ args["due"] = {date: ParseHelper.format_time(new_date_utc)}
66
62
  end
67
-
63
+
68
64
  if date_string
69
- args["date_string"] = date_string
65
+ args["due"] = {string: date_string}
70
66
  end
71
-
67
+
72
68
  return @client.api_helper.command(args, "item_update_date_complete")
73
69
  end
74
-
75
- # A simplified version of item_complete / item_update_date_complete.
76
- # The command does exactly what official clients do when you close a item
70
+
71
+ # A simplified version of item_complete / item_update_date_complete.
72
+ # The command does exactly what official clients do when you close a item
77
73
  # given an item.
78
-
74
+
79
75
  def close(item)
80
76
  args = {id: item.id}
81
77
  return @client.api_helper.command(args, "item_close")
82
78
  end
83
-
84
- # Update the day orders of multiple items at once given an array of
79
+
80
+ # Update the day orders of multiple items at once given an array of
85
81
  # items
86
82
  def update_day_orders(items)
87
83
  ids_to_orders = {}
@@ -91,7 +87,7 @@ module Todoist
91
87
  args = {ids_to_orders: ids_to_orders.to_json}
92
88
  return @client.api_helper.command(args, "item_update_day_orders")
93
89
  end
94
-
90
+
95
91
  # Update orders and indents for an array of items
96
92
  def update_multiple_orders_and_indents(items)
97
93
  tuples = {}
@@ -101,7 +97,7 @@ module Todoist
101
97
  args = {ids_to_orders_indents: tuples.to_json}
102
98
  return @client.api_helper.command(args, "item_update_orders_indents")
103
99
  end
104
-
100
+
105
101
  end
106
102
  end
107
103
  end
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/todoist.gemspec CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_development_dependency "bundler", "~> 2.0.1"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "bundler", "~> 2.1.4"
34
+ spec.add_development_dependency "rake", "~> 12.3.3"
35
+ spec.add_development_dependency "rspec", "~>3.9"
36
36
  spec.add_development_dependency "pry", "~> 0.10"
37
37
  spec.add_development_dependency "vcr", "~> 3.0"
38
38
  spec.add_development_dependency "webmock", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todoist-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Han Yuan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-14 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.1
19
+ version: 2.1.4
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.1
26
+ version: 2.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -181,7 +181,6 @@ files:
181
181
  - lib/todoist/misc/completed.rb
182
182
  - lib/todoist/misc/items.rb
183
183
  - lib/todoist/misc/projects.rb
184
- - lib/todoist/misc/query.rb
185
184
  - lib/todoist/misc/quick.rb
186
185
  - lib/todoist/misc/templates.rb
187
186
  - lib/todoist/misc/uploads.rb
@@ -1,30 +0,0 @@
1
- # Exposes hidden API that allows queries to be issued to return items. Queries
2
- # are restricted to a single "type" of query that is related to priority or date.
3
- # When it cannot parse query, it either returns a date result for
4
- # today or occasionally a 500 error.
5
-
6
- module Todoist
7
- module Misc
8
- class Query < Todoist::Service
9
- include Todoist::Util
10
-
11
- # Given an array of queries, return multiple results with key being the
12
- # query results. Query results have three key elements: query, type,
13
- # and data. Data is where the items are stored.
14
- def queries(queries)
15
- result = @client.api_helper.get_response(Config::TODOIST_QUERY_COMMAND,
16
- queries: queries.to_json)
17
- return ParseHelper.make_objects_as_hash(result, "query")
18
- end
19
-
20
- # Given a query, return result. See return structure in comments above.
21
- def query(query)
22
- result = queries([query])
23
- return result[query]
24
- end
25
-
26
-
27
- end
28
- end
29
- end
30
-