Class: TodoableLogan
- Inherits:
-
Object
- Object
- TodoableLogan
- Defined in:
- lib/todoable_logan.rb
Constant Summary collapse
- BASE_URL =
"http://todoable.teachable.tech/api"
Instance Method Summary collapse
- #create_list(name) ⇒ Object
- #create_todo_item(name, list_id) ⇒ Object
- #delete_list(list_id) ⇒ Object
- #delete_todo_item(item_id, list_id) ⇒ Object
- #get_list(list_id) ⇒ Object
- #get_lists ⇒ Object
-
#initialize(user, password) ⇒ TodoableLogan
constructor
A new instance of TodoableLogan.
- #mark_todo_item_finished(item_id, list_id) ⇒ Object
- #update_list(list_id, name) ⇒ Object
Constructor Details
#initialize(user, password) ⇒ TodoableLogan
Returns a new instance of TodoableLogan.
7 8 9 10 11 |
# File 'lib/todoable_logan.rb', line 7 def initialize(user, password) @user = user @password = password authenticate() end |
Instance Method Details
#create_list(name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/todoable_logan.rb', line 19 def create_list(name) data = { list: { name: name } } rest("post", "lists", data) end |
#create_todo_item(name, list_id) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/todoable_logan.rb', line 47 def create_todo_item(name, list_id) data = { item: { name: name } } rest("post", "lists/#{list_id}/items", data) end |
#delete_list(list_id) ⇒ Object
41 42 43 44 45 |
# File 'lib/todoable_logan.rb', line 41 def delete_list(list_id) rest("delete", "lists/#{list_id}") return true end |
#delete_todo_item(item_id, list_id) ⇒ Object
60 61 62 63 64 |
# File 'lib/todoable_logan.rb', line 60 def delete_todo_item(item_id, list_id) rest("delete", "/lists/#{list_id}/items/#{item_id}") return true end |
#get_list(list_id) ⇒ Object
37 38 39 |
# File 'lib/todoable_logan.rb', line 37 def get_list(list_id) rest("get", "lists/#{list_id}") end |
#get_lists ⇒ Object
13 14 15 16 17 |
# File 'lib/todoable_logan.rb', line 13 def get_lists response = rest("get", "lists") return response["lists"] end |
#mark_todo_item_finished(item_id, list_id) ⇒ Object
56 57 58 |
# File 'lib/todoable_logan.rb', line 56 def mark_todo_item_finished(item_id, list_id) rest("put", "lists/#{list_id}/items/#{item_id}/finish") end |
#update_list(list_id, name) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/todoable_logan.rb', line 28 def update_list(list_id, name) data = { list: { name: name } } rest("patch", "lists/#{list_id}", data) end |