Current section
Files
Jump to
Current section
Files
lib/teac/api/predictions.ex
defmodule Teac.Api.Predictions do
def get(opts) do
token = Keyword.fetch!(opts, :token)
client_id = Keyword.get(opts, :client_id, Teac.client_id())
case Req.get!(Teac.api_uri() <> "predictions",
headers: [
{"Authorization", "Bearer #{token}"},
{"Client-Id", client_id}
],
params: []
) do
%Req.Response{status: 200, body: %{"data" => data}} -> {:ok, data}
%Req.Response{body: body} -> {:error, body}
end
end
def post(opts) do
token = Keyword.fetch!(opts, :token)
client_id = Keyword.get(opts, :client_id, Teac.client_id())
case Req.post!(Teac.api_uri() <> "predictions",
headers: [
{"Authorization", "Bearer #{token}"},
{"Client-Id", client_id},
{"Content-Type", "application/x-www-form-urlencoded"}
],
form: [],
decode_body: :json
) do
%Req.Response{status: 200, body: %{"data" => data}} -> {:ok, data}
%Req.Response{body: body} -> {:error, body}
end
end
def patch(opts) do
token = Keyword.fetch!(opts, :token)
client_id = Keyword.get(opts, :client_id, Teac.client_id())
case Req.patch!(Teac.api_uri() <> "predictions",
headers: [
{"Authorization", "Bearer #{token}"},
{"Client-Id", client_id},
{"Content-Type", "application/x-www-form-urlencoded"}
],
form: [],
decode_body: :json
) do
%Req.Response{status: 200, body: %{"data" => data}} -> {:ok, data}
%Req.Response{body: body} -> {:error, body}
end
end
end