Skip to content

Commit 2185043

Browse files
authored
fix: idempotency_key dialyzer (#39)
* fix: idempotency_key dialyzer * split keys
1 parent c437134 commit 2185043

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lib/knock/api.ex

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule Knock.Api do
1515
@typedoc """
1616
Defines available options to pass to an API function
1717
"""
18-
@type options :: [Tesla.option() | {:idempotency_key, binary()}] | []
18+
@type options :: [Tesla.option() | {:idempotency_key, String.Chars.t()}] | []
1919

2020
@doc """
2121
Executes a get request against the Knock api.
@@ -33,9 +33,11 @@ defmodule Knock.Api do
3333
"""
3434
@spec put(Client.t(), String.t(), map(), options()) :: response()
3535
def put(client, path, body, opts \\ []) do
36+
{client_opts, tesla_opts} = Keyword.split(opts, [:idempotency_key])
37+
3638
client
37-
|> http_client(opts)
38-
|> Tesla.put(path, body, opts)
39+
|> http_client(client_opts)
40+
|> Tesla.put(path, body, tesla_opts)
3941
|> handle_response()
4042
end
4143

@@ -44,9 +46,11 @@ defmodule Knock.Api do
4446
"""
4547
@spec post(Client.t(), String.t(), map(), options()) :: response()
4648
def post(client, path, body, opts \\ []) do
49+
{client_opts, tesla_opts} = Keyword.split(opts, [:idempotency_key])
50+
4751
client
48-
|> http_client(opts)
49-
|> Tesla.post(path, body, opts)
52+
|> http_client(client_opts)
53+
|> Tesla.post(path, body, tesla_opts)
5054
|> handle_response()
5155
end
5256

@@ -55,9 +59,11 @@ defmodule Knock.Api do
5559
"""
5660
@spec delete(Client.t(), String.t(), options()) :: response()
5761
def delete(client, path, opts \\ []) do
62+
{client_opts, tesla_opts} = Keyword.split(opts, [:idempotency_key])
63+
5864
client
59-
|> http_client()
60-
|> Tesla.delete(path, opts)
65+
|> http_client(client_opts)
66+
|> Tesla.delete(path, tesla_opts)
6167
|> handle_response()
6268
end
6369

0 commit comments

Comments
 (0)