Current section

Files

Jump to
teac lib teac api moderation enforcements status.ex
Raw

lib/teac/api/moderation/enforcements/status.ex

defmodule Teac.Api.Moderation.Enforcements.Status do
def post(opts) do
token = Keyword.fetch!(opts, :token)
client_id = Keyword.get(opts, :client_id, Teac.client_id())
user_id = Keyword.fetch!(opts, :user_id)
msg_id = Keyword.fetch!(opts, :id)
action = Keyword.fetch!(opts, :action)
case Req.post!(Teac.api_uri() <> "moderation/enforcements/status",
headers: [
{"Authorization", "Bearer #{token}"},
{"Client-Id", client_id}
],
params: [user_id: user_id],
json: %{id: msg_id, action: action},
decode_body: :json
) do
%Req.Response{status: 200, body: %{"data" => data}} -> {:ok, data}
%Req.Response{status: 204} -> {:ok, nil}
%Req.Response{body: body} -> {:error, body}
end
end
end