# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.
defmodule VRChat.Api.Notifications do
@moduledoc """
API calls for all endpoints tagged `Notifications`.
"""
alias VRChat.Connection
import VRChat.RequestBuilder
@doc """
Accept Friend Request
Accept a friend request by notification `frq_` ID. Friend requests can be found using the NotificationsAPI `getNotifications` by filtering of type `friendRequest`.
## Parameters
- connection (VRChat.Connection): Connection to server
- notification_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, VRChat.Model.Success.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec accept_friend_request(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Success.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
def accept_friend_request(connection, notification_id, _opts \\ []) do
%{}
|> method(:put)
|> url("/auth/user/notifications/#{notification_id}/accept")
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %VRChat.Model.Success{}},
{ 401, %VRChat.Model.Error{}},
{ 404, %VRChat.Model.Error{}}
])
end
@doc """
Clear All Notifications
Clear **all** notifications.
## Parameters
- connection (VRChat.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, VRChat.Model.Success.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec clear_notifications(Tesla.Env.client, keyword()) :: {:ok, VRChat.Model.Success.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
def clear_notifications(connection, _opts \\ []) do
%{}
|> method(:put)
|> url("/auth/user/notifications/clear")
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %VRChat.Model.Success{}},
{ 401, %VRChat.Model.Error{}}
])
end
@doc """
Delete Notification
Delete a notification.
## Parameters
- connection (VRChat.Connection): Connection to server
- notification_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, VRChat.Model.Notification.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_notification(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Notification.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
def delete_notification(connection, notification_id, _opts \\ []) do
%{}
|> method(:put)
|> url("/auth/user/notifications/#{notification_id}/hide")
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %VRChat.Model.Notification{}},
{ 401, %VRChat.Model.Error{}}
])
end
@doc """
List Notifications
Retrieve all of the current user's notifications.
## Parameters
- connection (VRChat.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :type (String.t): Only send notifications of this type (can use `all` for all).
- :sent (boolean()): Return notifications sent by the user. Must be false or omitted.
- :hidden (boolean()): Whether to return hidden or non-hidden notifications. True only allowed on type `friendRequest`.
- :after (String.t): Only return notifications sent after this Date. Ignored if type is `friendRequest`.
- :n (integer()): The number of objects to return.
- :offset (integer()): A zero-based offset from the default object sorting from where search results start.
## Returns
{:ok, [%Notification{}, ...]} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_notifications(Tesla.Env.client, keyword()) :: {:ok, list(VRChat.Model.Notification.t)} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
def get_notifications(connection, opts \\ []) do
optional_params = %{
:type => :query,
:sent => :query,
:hidden => :query,
:after => :query,
:n => :query,
:offset => :query
}
%{}
|> method(:get)
|> url("/auth/user/notifications")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, [%VRChat.Model.Notification{}]},
{ 401, %VRChat.Model.Error{}}
])
end
@doc """
Mark Notification As Read
Mark a notification as seen.
## Parameters
- connection (VRChat.Connection): Connection to server
- notification_id (String.t):
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, VRChat.Model.Notification.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec mark_notification_as_read(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Notification.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
def mark_notification_as_read(connection, notification_id, _opts \\ []) do
%{}
|> method(:put)
|> url("/auth/user/notifications/#{notification_id}/see")
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %VRChat.Model.Notification{}},
{ 401, %VRChat.Model.Error{}}
])
end
end