Class: Basecampeverest::TodoItem
- Inherits:
-
Object
- Object
- Basecampeverest::TodoItem
- Defined in:
- lib/basecampeverest/resources/todo_item.rb
Class Method Summary collapse
-
.delete(project_id, todo_id) ⇒ Basecampeverest::TodoItem
delete a specific todo via the Basecamp API.
-
.find(project_id, todo_id) ⇒ Basecampeverest::TodoItem
find a specific todo via the Basecamp API.
-
.new(project_id, todolist_id, options = {}) ⇒ Basecampeverest::TodoItem
create a todo via the Basecamp API.
-
.update(project_id, todo_id, options = {}) ⇒ Basecampeverest::TodoItem
update a specific todo via the Basecamp API.
Class Method Details
.delete(project_id, todo_id) ⇒ Basecampeverest::TodoItem
delete a specific todo via the Basecamp API
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/basecampeverest/resources/todo_item.rb', line 62 def self.delete(project_id, todo_id) # for some reason ruby won't put in the project ID for a delete method. Solved by setting the url # and then calling delete url = "/projects/#{project_id}/todos/#{todo_id}.json" response = Basecampeverest::Connect.delete url # This checks the response code for validity and error checking if response.code == 204 = "Todo successfully deleted" elsif response.code == 403 = "You do not have permission to delete this todo" else = "Invalid project ID or authentication. The todo was not deleted." end # return the message end |
.find(project_id, todo_id) ⇒ Basecampeverest::TodoItem
find a specific todo via the Basecamp API
12 13 14 15 16 17 18 |
# File 'lib/basecampeverest/resources/todo_item.rb', line 12 def self.find(project_id, todo_id) url = "projects/#{project_id}/todos/#{todo_id}.json" response = Basecampeverest::Connect.get url # parse the response to remove HTTParty info response.parsed_response end |
.new(project_id, todolist_id, options = {}) ⇒ Basecampeverest::TodoItem
create a todo via the Basecamp API
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/basecampeverest/resources/todo_item.rb', line 25 def self.new(project_id, todolist_id, ={}) post_params = { :body => .to_json, :headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'}) } url = "/projects/#{project_id}/todolists/#{todolist_id}/todos.json" # make the http basecamp call response = Basecampeverest::Connect.post url, post_params # parse the response to remove HTTParty info response.parsed_response end |
.update(project_id, todo_id, options = {}) ⇒ Basecampeverest::TodoItem
update a specific todo via the Basecamp API
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/basecampeverest/resources/todo_item.rb', line 44 def self.update(project_id, todo_id, ={}) post_params = { :body => .to_json, :headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'}) } url = "/projects/#{project_id}/todos/#{todo_id}.json" # make the http basecamp call response = Basecampeverest::Connect.put url, post_params # parse the response to remove HTTParty info response.parsed_response end |