Current section
Files
Jump to
Current section
Files
lib/synctera/resources/relationships.ex
defmodule Synctera.Relationships do
@moduledoc """
Synctera 'Relationships' endpoints.
Code generated by scripts/generate.py from the Synctera OpenAPI spec. Do
not edit by hand — re-run `mix generate` (or `python3 scripts/generate.py`)
to regenerate.
"""
alias Synctera.{Client, Error, HTTP}
@doc """
List relationships — Retrieves paginated list of relationships viewable by the authorized
requester.
## Options
Query options: `:id`, `:from_person_id`, `:from_business_id`, `:to_business_id`,
`:relationship_type`, `:limit`, `:page_token`
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec list_relationships(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def list_relationships(client, opts \\ []) do
HTTP.request(client, :get, "/relationships",
query: [
{"id", Keyword.get(opts, :id)},
{"from_person_id", Keyword.get(opts, :from_person_id)},
{"from_business_id", Keyword.get(opts, :from_business_id)},
{"to_business_id", Keyword.get(opts, :to_business_id)},
{"relationship_type", Keyword.get(opts, :relationship_type)},
{"limit", Keyword.get(opts, :limit)},
{"page_token", Keyword.get(opts, :page_token)}
],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `list_relationships/2` but returns the value directly and raises on error."
@spec list_relationships!(Client.t(), keyword()) :: Synctera.JSON.json()
def list_relationships!(client, opts) do
case list_relationships(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Create a relationship — Create a party relationship.
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec create_relationship(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def create_relationship(client, opts \\ []) do
HTTP.request(client, :post, "/relationships",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `create_relationship/2` but returns the value directly and raises on error."
@spec create_relationship!(Client.t(), keyword()) :: Synctera.JSON.json()
def create_relationship!(client, opts) do
case create_relationship(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Delete relationship — Delete party relationship by ID.
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec delete_relationship(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def delete_relationship(client, relationship_id, opts \\ []) do
HTTP.request(client, :delete, "/relationships/#{HTTP.path_segment(relationship_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `delete_relationship/3` but returns the value directly and raises on error."
@spec delete_relationship!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def delete_relationship!(client, relationship_id, opts) do
case delete_relationship(client, relationship_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Get relationship — Get relationship by ID.
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec get_relationship(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def get_relationship(client, relationship_id, opts \\ []) do
HTTP.request(client, :get, "/relationships/#{HTTP.path_segment(relationship_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `get_relationship/3` but returns the value directly and raises on error."
@spec get_relationship!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def get_relationship!(client, relationship_id, opts) do
case get_relationship(client, relationship_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Update relationship — Update relationship by ID.
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec update_relationship(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def update_relationship(client, relationship_id, opts \\ []) do
HTTP.request(client, :patch, "/relationships/#{HTTP.path_segment(relationship_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `update_relationship/3` but returns the value directly and raises on error."
@spec update_relationship!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def update_relationship!(client, relationship_id, opts) do
case update_relationship(client, relationship_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
end