diff options
author | Pierre de Lacroix <pierre@pdelacroix.com> | 2020-09-17 20:37:11 +0000 |
---|---|---|
committer | Pierre de Lacroix <pierre@pdelacroix.com> | 2020-09-17 20:37:11 +0000 |
commit | fd84f69a9fa6dd890ec076f9a50e3509ff3bfacf (patch) | |
tree | 9b03918900edd997d6325958e3862cb2e15633e6 | |
parent | fix MatrixAppService.Client (diff) | |
parent | add typespecs (diff) |
Merge branch 'typespec/matrix_client' into 'master'
Typespec/matrix client
See merge request kazarma/matrix_app_service.ex!3
-rw-r--r-- | lib/matrix_app_service/client.ex | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/matrix_app_service/client.ex b/lib/matrix_app_service/client.ex index ff5efa1..5cb720d 100644 --- a/lib/matrix_app_service/client.ex +++ b/lib/matrix_app_service/client.ex @@ -1,9 +1,13 @@ defmodule MatrixAppService.Client do + @type client_options :: [user_id: String.t(), storage: Polyjuice.Client.Storage.t()] + + @spec client(String.t() | nil, Polyjuice.Client.Storage.t() | nil) :: + Polyjuice.Client.LowLevel.t() def client(user_id \\ nil, storage \\ nil) do base_url = Application.get_env(:matrix_app_service, :base_url) access_token = Application.get_env(:matrix_app_service, :access_token) - Polyjuice.Client.LowLevel.create(base_url, + Polyjuice.Client.LowLevel.create(base_url, access_token: access_token, # "@alice:matrix.imago.local", user_id: user_id, @@ -12,16 +16,19 @@ defmodule MatrixAppService.Client do ) end + @spec create_room(Keyword.t()) :: {:ok, String.t()} | Any def create_room(options) do client_with_options(options) |> Polyjuice.Client.Room.create_room(options) end + @spec create_alias(String.t(), String.t(), client_options()) :: {:ok, String.t()} | Any def create_alias(room_id, room_alias, options \\ []) do client_with_options(options) |> Polyjuice.Client.Room.create_alias(room_id, room_alias) end + @spec client(client_options(), Polyjuice.Client.Storage.t()) :: Polyjuice.Client.LowLevel.t() defp client_with_options(options) do user_id = Keyword.get(options, :user_id, nil) storage = Keyword.get(options, :storage, nil) |