# NOTE: This file is auto generated by OpenAPI Generator 7.22.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule Spatio.Api.Inbox do
@moduledoc """
API calls for all endpoints tagged `Inbox`.
"""
alias Spatio.Connection
import Spatio.RequestBuilder
@doc """
Per-bucket unread counts.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, Spatio.Model.InboxCounts.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_inbox_counts(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.InboxCounts.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def get_inbox_counts(connection, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/inbox/counts")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.InboxCounts},
{401, Spatio.Model.ApiError}
])
end
@doc """
Unified inbox feed across mail, channel mentions, DMs, system notifications.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:category` (String.t):
- `:unreadOnly` (boolean()):
- `:limit` (integer()):
### Returns
- `{:ok, Spatio.Model.InboxListResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_inbox(Tesla.Env.client, keyword()) :: {:ok, Spatio.Model.InboxListResponse.t} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def list_inbox(connection, opts \\ []) do
optional_params = %{
:category => :query,
:unreadOnly => :query,
:limit => :query
}
request =
%{}
|> method(:get)
|> url("/v1/inbox")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, Spatio.Model.InboxListResponse},
{401, Spatio.Model.ApiError}
])
end
@doc """
Mark a single inbox item as read.
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec mark_inbox_item_read(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def mark_inbox_item_read(connection, id, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/inbox/#{id}/read")
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError},
{404, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_get_inbox_counts(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_get_inbox_counts(connection, org, workspace, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/inbox/counts")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, %{}}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_list_inbox(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, %{optional(String.t) => any()}} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_list_inbox(connection, org, workspace, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/inbox")
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, %{}},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
@doc """
### Parameters
- `connection` (Spatio.Connection): Connection to server
- `org` (String.t):
- `workspace` (String.t):
- `id` (String.t):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec workspace_mark_inbox_item_read(Tesla.Env.client, String.t, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t} | {:error, Tesla.Env.t}
def workspace_mark_inbox_item_read(connection, org, workspace, id, _opts \\ []) do
request =
%{}
|> method(:patch)
|> url("/v1/organizations/#{org}/workspaces/#{workspace}/inbox/#{id}/read")
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{401, Spatio.Model.ApiError},
{403, Spatio.Model.ApiError}
])
end
end