Current section
Files
Jump to
Current section
Files
lib/commons/http_helper.ex
defmodule HttpHelper do
use Tesla
@moduledoc false
@todoist_url System.get_env("TODOIST_URL", "https://api.todoist.com/rest/v1/")
@todoist_token System.get_env("TODOIST_TOKEN")
plug(Tesla.Middleware.BaseUrl, @todoist_url)
plug(Tesla.Middleware.Headers, [
{
"authorization",
"Bearer #{@todoist_token}"
},
{
"X-Request-Id",
UUID.uuid4()
}
])
plug(Tesla.Middleware.JSON)
def find(resource) do
get(resource)
end
def exclude(resource) do
delete(resource)
end
def create(resource, data) do
post(resource, data)
end
def update(resource, data) do
put(resource, data)
end
end