Skip to content

Commit 41ae242

Browse files
committed
remove unused github client opts
1 parent 4b908ce commit 41ae242

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

lib/algora/integrations/github/client.ex

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,33 @@ defmodule Algora.Github.Client do
88

99
@type token :: String.t()
1010

11-
def http(host, method, path, headers, body, opts \\ []) do
11+
def http(host, method, path, headers, body) do
1212
# TODO: remove after migration
1313
if System.get_env("MIGRATION", "false") == "true" do
1414
cache_path = ".local/github/#{path}.json"
1515

1616
with :error <- read_from_cache(cache_path),
17-
{:ok, response_body} <- do_http_request(host, method, path, headers, body, opts) do
17+
{:ok, response_body} <- do_http_request(host, method, path, headers, body) do
1818
write_to_cache(cache_path, response_body)
1919
{:ok, response_body}
2020
else
2121
{:ok, cached_data} -> {:ok, cached_data}
2222
{:error, reason} -> {:error, reason}
2323
end
2424
else
25-
do_http_request(host, method, path, headers, body, opts)
25+
do_http_request(host, method, path, headers, body)
2626
end
2727
end
2828

29-
defp do_http_request(host, method, path, headers, body, opts) do
29+
defp do_http_request(host, method, path, headers, body) do
3030
url = "https://#{host}#{path}"
3131
headers = [{"Content-Type", "application/json"} | headers]
3232

3333
with {:ok, encoded_body} <- Jason.encode(body),
3434
request = Finch.build(method, url, headers, encoded_body),
35-
{:ok, response} <- Finch.request(request, Algora.Finch) do
36-
if opts[:skip_decoding], do: {:ok, response.body}, else: handle_response(response)
37-
end
38-
end
39-
40-
defp handle_response(%Finch.Response{body: body}) do
41-
case Jason.decode(body) do
42-
{:ok, decoded_body} -> maybe_handle_error(decoded_body)
43-
{:error, reason} -> {:error, reason}
35+
{:ok, %Finch.Response{body: body}} <- Finch.request(request, Algora.Finch),
36+
{:ok, decoded_body} <- Jason.decode(body) do
37+
maybe_handle_error(decoded_body)
4438
end
4539
end
4640

@@ -69,20 +63,18 @@ defmodule Algora.Github.Client do
6963
File.write!(cache_path, Jason.encode!(data))
7064
end
7165

72-
def fetch(access_token, url, method \\ "GET", body \\ nil, opts \\ [])
66+
def fetch(access_token, url, method \\ "GET", body \\ nil)
7367

74-
def fetch(access_token, "https://api.github.com" <> path, method, body, opts),
75-
do: fetch(access_token, path, method, body, opts)
68+
def fetch(access_token, "https://api.github.com" <> path, method, body), do: fetch(access_token, path, method, body)
7669

77-
def fetch(access_token, path, method, body, opts) do
70+
def fetch(access_token, path, method, body) do
7871
http(
7972
"api.github.com",
8073
method,
8174
path,
8275
[{"accept", "application/vnd.github.v3+json"}] ++
8376
if(access_token, do: [{"Authorization", "Bearer #{access_token}"}], else: []),
84-
body,
85-
opts
77+
body
8678
)
8779
end
8880

0 commit comments

Comments
 (0)