module FluvipTodo
Constants
- HOST
- PATH
- TOKEN
- VERSION
Public Instance Methods
create_task(description)
click to toggle source
# File lib/fluvip_todo.rb, line 23 def create_task(description) uri = URI.parse("#{HOST}#{PATH}") http = Net::HTTP.new(uri.host, uri.port) data = {'task' => {"description" => description}} response = http.post(uri.path, data.to_json, headers) task = JSON.parse(response.body) puts "#{task["id"]} #{task["description"]}" end
headers()
click to toggle source
# File lib/fluvip_todo.rb, line 14 def headers { 'X-User-Token' => TOKEN, 'X-User-Email' => EMAIL, 'Accept' => 'application/json', 'Content-Type' => 'application/json' } end
list_tasks()
click to toggle source
# File lib/fluvip_todo.rb, line 33 def list_tasks uri = URI.parse("#{HOST}#{PATH}") http = Net::HTTP.new(uri.host, uri.port) response = http.get(uri.path, headers) tasks = JSON.parse(response.body) tasks.each do |t| puts "#{t["id"]} [#{t["status"]}] #{t["description"]}" end end