Class: GSquire::Client
- Inherits:
-
Object
- Object
- GSquire::Client
- Defined in:
- lib/gsquire/client.rb
Overview
Very simple Google Tasks API wrapper. It won't perform authentication. Instead, it requires an already authenticated and authorized OAuth2::AccessToken token.
Constant Summary collapse
- GOOGLE_TASKS_API =
URI.parse 'https://www.googleapis.com/tasks/v1'
Instance Attribute Summary collapse
-
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
Instance Method Summary collapse
-
#create_task(task, tasklist_id = '@default') ⇒ Object
Creates a task in the given tasklist.
-
#create_tasklist(tasklist) ⇒ Object
Creates a tasklist.
-
#delete_tasklist(tasklist_id) ⇒ Object
Deletes a tasklist.
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
-
#move_task(task_id, tasklist_id = '@default', params = {}) ⇒ Object
Moves a task inside the given tasklist.
-
#task(task_id, tasklist_id = '@default') ⇒ Hash
Pulls a task of a tasklist.
-
#tasklist(tasklist_id = '@default', opts = {}) ⇒ Hash
Pulls a tasklist.
-
#tasklists ⇒ Array
Pulls all tasklists for authorized user.
-
#tasks(tasklist_id = '@default') ⇒ Array
Pulls all tasks of a tasklist.
-
#update_tasklist(tasklist) ⇒ Object
Updates a tasklist.
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/gsquire/client.rb', line 17 def initialize(token) @oauth_token = token end |
Instance Attribute Details
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
14 15 16 |
# File 'lib/gsquire/client.rb', line 14 def oauth_token @oauth_token end |
Instance Method Details
#create_task(task, tasklist_id = '@default') ⇒ Object
Creates a task in the given tasklist
73 74 75 |
# File 'lib/gsquire/client.rb', line 73 def create_task(task, tasklist_id = '@default') post gtasks_tasks_url(tasklist_id), strip(:task, :create, task) end |
#create_tasklist(tasklist) ⇒ Object
Creates a tasklist
39 40 41 |
# File 'lib/gsquire/client.rb', line 39 def create_tasklist(tasklist) post gtasks_tasklists_url, strip(:tasklist, :create, tasklist) end |
#delete_tasklist(tasklist_id) ⇒ Object
Deletes a tasklist
51 52 53 |
# File 'lib/gsquire/client.rb', line 51 def delete_tasklist(tasklist_id) delete gtasks_tasklist_url(tasklist_id) end |
#move_task(task_id, tasklist_id = '@default', params = {}) ⇒ Object
Moves a task inside the given tasklist
82 83 84 85 |
# File 'lib/gsquire/client.rb', line 82 def move_task(task_id, tasklist_id = '@default', params={}) return if params.empty? post gtasks_task_move_url(task_id, tasklist_id, params) end |
#task(task_id, tasklist_id = '@default') ⇒ Hash
Pulls a task of a tasklist
66 67 68 |
# File 'lib/gsquire/client.rb', line 66 def task(task_id, tasklist_id = '@default') get gtasks_task_url(task_id, tasklist_id) end |
#tasklist(tasklist_id = '@default', opts = {}) ⇒ Hash
Pulls a tasklist
31 32 33 34 35 |
# File 'lib/gsquire/client.rb', line 31 def tasklist(tasklist_id = '@default', opts={}) tasklist = get gtasks_tasklist_url(tasklist_id) tasklist['tasks'] = tasks tasklist_id if opts[:pull_tasks] tasklist end |
#tasklists ⇒ Array
Pulls all tasklists for authorized user
23 24 25 |
# File 'lib/gsquire/client.rb', line 23 def tasklists get gtasks_tasklists_url end |
#tasks(tasklist_id = '@default') ⇒ Array
Pulls all tasks of a tasklist
58 59 60 |
# File 'lib/gsquire/client.rb', line 58 def tasks(tasklist_id = '@default') get gtasks_tasks_url(tasklist_id) end |
#update_tasklist(tasklist) ⇒ Object
Updates a tasklist
45 46 47 |
# File 'lib/gsquire/client.rb', line 45 def update_tasklist(tasklist) put gtasks_tasklist_url(tasklist[:id]), strip(:tasklist, :update, tasklist) end |