57 lines
1.7 KiB
Elixir
57 lines
1.7 KiB
Elixir
defmodule PlugIndie.HandlerBehaviour do
|
|
@moduledoc """
|
|
Behaviour defining the interface for a PlugIndie Handler
|
|
"""
|
|
|
|
@type access_token :: String.t()
|
|
@type handler_error_atom :: :invalid_request | :forbidden | :insufficient_scope
|
|
@type handler_error ::
|
|
{:error, handler_error_atom} | {:error, handler_error_atom, description :: String.t()}
|
|
|
|
@callback handle_create(type :: String.t(), properties :: map, access_token) ::
|
|
{:ok, :created | :accepted, url :: String.t()}
|
|
| handler_error
|
|
|
|
@callback handle_update(
|
|
url :: String.t(),
|
|
replace :: map,
|
|
add :: map,
|
|
delete :: map,
|
|
access_token
|
|
) ::
|
|
:ok
|
|
| {:ok, url :: String.t()}
|
|
| handler_error
|
|
|
|
@callback handle_delete(url :: String.t(), access_token) ::
|
|
:ok
|
|
| handler_error
|
|
|
|
@callback handle_undelete(url :: String.t(), access_token) ::
|
|
:ok
|
|
| {:ok, url :: String.t()}
|
|
| handler_error
|
|
|
|
@callback handle_config_query(access_token) ::
|
|
{:ok, map}
|
|
| handler_error
|
|
|
|
@callback handle_config_query(access_token) ::
|
|
{:ok, map}
|
|
| handler_error
|
|
|
|
@callback handle_syndicate_to_query(access_token) ::
|
|
{:ok, map}
|
|
| handler_error
|
|
|
|
@callback handle_source_query(
|
|
url :: String.t(),
|
|
properties :: [String.t()],
|
|
access_token
|
|
) ::
|
|
{:ok, map}
|
|
| handler_error
|
|
|
|
@callback handle_media(file :: Plug.Upload.t(), access_token) ::
|
|
{:ok, url :: String.t()} | handler_error
|
|
end
|