summaryrefslogtreecommitdiff
path: root/lib/matrix_app_service/client_behaviour.ex
blob: 7a1f7fe92042188144d9acfff3ded28c984d8d2c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
defmodule MatrixAppService.ClientBehaviour do
  @moduledoc """
  Behaviour defining callbacks implemented in `MatrixAppService.Client`. Can be used to mock the client, for instance with `mox`:

  TODO: example
  """

  @type create_opts :: [
          access_token: String.t() | nil,
          user_id: String.t() | nil,
          device_id: String.t() | nil,
          storage: Polyjuice.Client.Storage.t() | nil
        ]
  @type client_options :: {:base_url, String.t()} | create_opts()

  @callback client() ::
              Polyjuice.Client.LowLevel.t()
  @callback client([client_options()]) ::
              Polyjuice.Client.LowLevel.t()
  @callback create_room(Keyword.t()) :: {:ok, map()} | Any
  @callback create_room(Keyword.t(), client_options()) :: {:ok, map()} | Any
  @callback create_alias(String.t(), String.t(), client_options()) :: {:ok, String.t()} | Any
  @callback send_message(String.t(), String.t()) :: {:ok, String.t()} | Any
  @callback send_message(String.t(), String.t(), client_options()) :: {:ok, String.t()} | Any
  @callback register() ::
              {:ok, String.t()} | Any
  @callback register(Polyjuice.Client.LowLevel.register_opts()) ::
              {:ok, String.t()} | Any
  @callback register(Polyjuice.Client.LowLevel.register_opts(), client_options()) ::
              {:ok, String.t()} | Any
  @callback get_profile(Polyjuice.Client.LowLevel.t(), String.t()) :: {:ok, map()} | any
  @callback get_data(Polyjuice.Client.LowLevel.t(), String.t(), String.t()) :: {:ok, map()} | any
  @callback put_displayname(Polyjuice.Client.LowLevel.t(), String.t(), String.t()) :: :ok | any
  @callback join(Polyjuice.Client.LowLevel.t(), String.t()) :: :ok | any
end