refactor(types): reconcile @specs with their success typings
This commit is contained in:
parent
263857ee26
commit
fd8e6ac178
17 changed files with 92 additions and 38 deletions
|
|
@ -8,6 +8,12 @@ defmodule Mv.Vereinfacht.Client do
|
|||
"""
|
||||
require Logger
|
||||
|
||||
@typedoc "Error reasons returned by Vereinfacht API calls."
|
||||
@type error_reason ::
|
||||
:not_configured
|
||||
| {:request_failed, map()}
|
||||
| {:http, non_neg_integer(), :html_response | binary()}
|
||||
|
||||
@content_type "application/vnd.api+json"
|
||||
|
||||
@doc """
|
||||
|
|
@ -31,7 +37,7 @@ defmodule Mv.Vereinfacht.Client do
|
|||
{:error, :not_configured}
|
||||
"""
|
||||
@spec test_connection(String.t() | nil, String.t() | nil, String.t() | nil) ::
|
||||
{:ok, :connected} | {:error, term()}
|
||||
{:ok, :connected} | {:error, error_reason()}
|
||||
def test_connection(api_url, api_key, club_id) do
|
||||
if blank?(api_url) or blank?(api_key) or blank?(club_id) do
|
||||
{:error, :not_configured}
|
||||
|
|
@ -230,7 +236,7 @@ defmodule Mv.Vereinfacht.Client do
|
|||
|
||||
Returns the full response body (decoded JSON) for debugging/display.
|
||||
"""
|
||||
@spec get_contact(String.t()) :: {:ok, map()} | {:error, term()}
|
||||
@spec get_contact(String.t()) :: {:ok, map()} | {:error, error_reason()}
|
||||
def get_contact(contact_id) when is_binary(contact_id) do
|
||||
fetch_contact(contact_id, [])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ defmodule Mv.Vereinfacht do
|
|||
- `{:error, {:http, status, message}}` – API returned an error (e.g. 401, 403)
|
||||
- `{:error, {:request_failed, reason}}` – network/transport error
|
||||
"""
|
||||
@spec test_connection() :: {:ok, :connected} | {:error, term()}
|
||||
@spec test_connection() :: {:ok, :connected} | {:error, Mv.Vereinfacht.Client.error_reason()}
|
||||
def test_connection do
|
||||
Client.test_connection(
|
||||
Mv.Config.vereinfacht_api_url(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue