Skip to content

Commit

Permalink
Add token struct as argument for Token.delete/1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Zitter committed Sep 24, 2024
1 parent 01f1137 commit 3e7e30b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/ibanity/api/ponto_connect/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,32 @@ defmodule Ibanity.PontoConnect.Token do
## Examples
With refresh token as string
iex> [token: "H1Sc-bFi3946Xzca5yuUMZDjVz6WuZ061Hkt3V_lpWs.8wJzYLM8vx1ONzaYlMHcCl_OM_nPOzDGcuCAQPqKPAc"]
...> |> Ibanity.Request.attributes()
...> |> Ibanity.Request.application(:my_application)
...> Ibanity.PontoConnect.Token.delete()
{:ok, %{}}
With token struct
iex> Ibanity.PontoConnect.Token.delete(token)
{:ok, %{}}
"""
def delete(attrs) when is_list(attrs) do
attrs
|> Request.attributes()
|> delete()
end

def delete(%__MODULE__{} = token) do
[token: token.refresh_token]
|> Request.attributes()
|> Request.application(token.application)
|> delete()
end

def delete(%Request{attributes: %{token: token}} = request)
when not is_nil(token) do
request
Expand Down

0 comments on commit 3e7e30b

Please sign in to comment.