Class: Tarea

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/make_todo.rb

Class Method Summary collapse

Class Method Details

.allObject



14
15
16
17
# File 'lib/make_todo.rb', line 14

def self.all
  response = self.get("/todo_items")
  return JSON.parse(response.body)
end

.create(titulo) ⇒ Object



9
10
11
12
# File 'lib/make_todo.rb', line 9

def self.create(titulo)
  response = self.post("/todo_items?todo_item[title]=#{titulo}")
  return JSON.parse(response.body)
end

.destroy(id) ⇒ Object



24
25
26
27
# File 'lib/make_todo.rb', line 24

def self.destroy(id)
  self.delete("/todo_items/#{id}")
  return "Tarea Destruida"
end

.find(id) ⇒ Object



19
20
21
22
# File 'lib/make_todo.rb', line 19

def self.find(id)
  response = self.get("/todo_items/#{id}")
  return JSON.parse(response.body)
end

.update(id) ⇒ Object



29
30
31
32
# File 'lib/make_todo.rb', line 29

def self.update(id)
  self.patch("/todo_items/#{id}?todo_item[done]=true")
  return "Tarea Completada"
end