summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2020-04-21 19:22:56 -0400
committerHubert Chathi <hubert@uhoreg.ca>2020-04-21 19:24:43 -0400
commite54a74a76eed8de5a052da72bb21f6fd13c5cf4b (patch)
tree53aca70302bfbfe3275a29798e48fe314f5febdd /lib
parentfix login endpoint add logout endpoint, and add functions for logging in/out (diff)
add some tests and some cleanups
Diffstat (limited to 'lib')
-rw-r--r--lib/polyjuice/client.ex1
-rw-r--r--lib/polyjuice/client/endpoint.ex2
-rw-r--r--lib/polyjuice/client/endpoint/post_join.ex2
-rw-r--r--lib/polyjuice/client/endpoint/post_logout.ex5
-rw-r--r--lib/polyjuice/client/room.ex2
5 files changed, 7 insertions, 5 deletions
diff --git a/lib/polyjuice/client.ex b/lib/polyjuice/client.ex
index 7de93b1..7433b19 100644
--- a/lib/polyjuice/client.ex
+++ b/lib/polyjuice/client.ex
@@ -128,6 +128,7 @@ defmodule Polyjuice.Client do
if auth_required and access_token == nil do
{:error, :auth_required}
else
+ # FIXME: handle errors
{:ok, status_code, resp_headers, body} =
:hackney.request(
method,
diff --git a/lib/polyjuice/client/endpoint.ex b/lib/polyjuice/client/endpoint.ex
index 82f9e11..97eb277 100644
--- a/lib/polyjuice/client/endpoint.ex
+++ b/lib/polyjuice/client/endpoint.ex
@@ -39,8 +39,8 @@ defmodule Polyjuice.Client.Endpoint do
:method,
:headers,
:url,
- :body,
:transform,
+ body: "",
auth_required: true
]
end
diff --git a/lib/polyjuice/client/endpoint/post_join.ex b/lib/polyjuice/client/endpoint/post_join.ex
index 66007cf..4e967e8 100644
--- a/lib/polyjuice/client/endpoint/post_join.ex
+++ b/lib/polyjuice/client/endpoint/post_join.ex
@@ -61,7 +61,7 @@ defmodule Polyjuice.Client.Endpoint.PostJoin do
if servers == [] do
nil
else
- Enum.join(Enum.map(servers, &"server_name=#{e.(&1)}"), "&")
+ servers |> Enum.map(&{"server_name", &1}) |> URI.encode_query()
end
}
diff --git a/lib/polyjuice/client/endpoint/post_logout.ex b/lib/polyjuice/client/endpoint/post_logout.ex
index d23f725..7523797 100644
--- a/lib/polyjuice/client/endpoint/post_logout.ex
+++ b/lib/polyjuice/client/endpoint/post_logout.ex
@@ -32,7 +32,8 @@ defmodule Polyjuice.Client.Endpoint.PostLogout do
%Polyjuice.Client.Endpoint.HttpSpec{
method: :post,
headers: [
- {"Accept", "application/json"}
+ {"Accept", "application/json"},
+ {"Content-Type", "application/json"}
],
url:
URI.merge(
@@ -40,7 +41,7 @@ defmodule Polyjuice.Client.Endpoint.PostLogout do
"#{Polyjuice.Client.prefix_r0()}/logout"
)
|> to_string(),
- body: "",
+ body: "{}",
transform: &Polyjuice.Client.Endpoint.PostLogout.transform/3
}
end
diff --git a/lib/polyjuice/client/room.ex b/lib/polyjuice/client/room.ex
index 0196571..6d84b13 100644
--- a/lib/polyjuice/client/room.ex
+++ b/lib/polyjuice/client/room.ex
@@ -157,7 +157,7 @@ defmodule Polyjuice.Client.Room do
client_api :: Polyjuice.Client.API.t(),
room :: String.t(),
servers :: list(String.t()),
- third_party_join :: map | nil
+ third_party_signed :: map | nil
) :: Any
def join(client_api, room, servers \\ [], third_party_signed \\ nil)
when is_binary(room) and is_list(servers) and