選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
1.7 KiB

  1. defmodule PlugMicropub.HandlerBehaviour do
  2. @moduledoc """
  3. Behaviour defining the interface for a PlugMicropub Handler
  4. """
  5. @type access_token :: String.t()
  6. @type handler_error_atom :: :invalid_request | :forbidden | :insufficient_scope
  7. @type handler_error ::
  8. {:error, handler_error_atom} | {:error, handler_error_atom, description :: String.t()}
  9. @callback handle_create(type :: String.t(), properties :: map, access_token) ::
  10. {:ok, :created | :accepted, url :: String.t()}
  11. | handler_error
  12. @callback handle_update(
  13. url :: String.t(),
  14. replace :: map,
  15. add :: map,
  16. delete :: map,
  17. access_token
  18. ) ::
  19. :ok
  20. | {:ok, url :: String.t()}
  21. | handler_error
  22. @callback handle_delete(url :: String.t(), access_token) ::
  23. :ok
  24. | handler_error
  25. @callback handle_undelete(url :: String.t(), access_token) ::
  26. :ok
  27. | {:ok, url :: String.t()}
  28. | {:error, handler_error}
  29. | {:error, handler_error, error_description :: String.t()}
  30. @callback handle_config_query(access_token) ::
  31. {:ok, map}
  32. | handler_error
  33. @callback handle_config_query(access_token) ::
  34. {:ok, map}
  35. | handler_error
  36. @callback handle_source_query(
  37. url :: String.t(),
  38. properties :: [String.t()],
  39. access_token
  40. ) ::
  41. {:ok, map}
  42. | handler_error
  43. @callback handle_media(file :: Plug.Upload.t(), access_token) ::
  44. {:ok, url :: String.t()} | handler_error
  45. end