summaryrefslogtreecommitdiff
path: root/lib/polyjuice/client/endpoint/get_sync.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/polyjuice/client/endpoint/get_sync.ex')
-rw-r--r--lib/polyjuice/client/endpoint/get_sync.ex50
1 files changed, 15 insertions, 35 deletions
diff --git a/lib/polyjuice/client/endpoint/get_sync.ex b/lib/polyjuice/client/endpoint/get_sync.ex
index 42477a6..9f64234 100644
--- a/lib/polyjuice/client/endpoint/get_sync.ex
+++ b/lib/polyjuice/client/endpoint/get_sync.ex
@@ -36,52 +36,32 @@ defmodule Polyjuice.Client.Endpoint.GetSync do
]
defimpl Polyjuice.Client.Endpoint.Proto do
- def http_spec(
- %Polyjuice.Client.Endpoint.GetSync{
- filter: filter,
- since: since,
- full_state: full_state,
- set_presence: set_presence,
- timeout: timeout
- },
- base_url
- ) do
+ def http_spec(%Polyjuice.Client.Endpoint.GetSync{
+ filter: filter,
+ since: since,
+ full_state: full_state,
+ set_presence: set_presence,
+ timeout: timeout
+ }) do
query =
[
- [
- {"timeout", timeout}
- ],
- if(since, do: [{"since", since}], else: []),
- if(full_state, do: [{"full_state", "true"}], else: []),
+ [timeout: timeout],
+ if(since, do: [since: since], else: []),
+ if(full_state, do: [full_state: "true"], else: []),
case filter do
- %{} -> [{"filter", Jason.encode!(filter)}]
+ %{} -> [filter: Jason.encode!(filter)]
nil -> []
- _ -> [{"filter", filter}]
+ _ -> [filter: filter]
end,
case set_presence do
- :offline -> [{"set_presence", "offline"}]
- :unavailable -> [{"set_presence", "unavailable"}]
+ :offline -> [set_presence: "offline"]
+ :unavailable -> [set_presence: "unavailable"]
:online -> []
end
]
|> Enum.concat()
- |> URI.encode_query()
- url = %{
- URI.merge(
- base_url,
- "#{Polyjuice.Client.prefix_r0()}/sync"
- )
- | query: query
- }
-
- %Polyjuice.Client.Endpoint.HttpSpec{
- method: :get,
- headers: [
- {"Accept", "application/json"}
- ],
- url: to_string(url)
- }
+ Polyjuice.Client.Endpoint.HttpSpec.get(:r0, "sync", query: query)
end
def transform_http_result(req, status_code, resp_headers, body) do