lib/vr_chat/api/invite.ex

# 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.Invite do
  @moduledoc """
  API calls for all endpoints tagged `Invite`.
  """

  alias VRChat.Connection
  import VRChat.RequestBuilder


  @doc """
  Get Invite Message
  Returns a single Invite Message. This returns the exact same information but less than `getInviteMessages`. Admin Credentials are required to view messages of other users!  Message type refers to a different collection of messages, used during different types of responses.  * `message` = Message during a normal invite * `response` = Message when replying to a message * `request` = Message when requesting an invite * `requestResponse` = Message when replying to a request for invite

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - message_type (String.t): 
  - slot (integer()): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, VRChat.Model.InviteMessage.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_invite_message(Tesla.Env.client, String.t, String.t, integer(), keyword()) :: {:ok, VRChat.Model.InviteMessage.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def get_invite_message(connection, user_id, message_type, slot, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/message/#{user_id}/#{message_type}/#{slot}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %VRChat.Model.InviteMessage{}},
      { 400, %VRChat.Model.Error{}},
      { 401, %VRChat.Model.Error{}},
      { 404, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  List Invite Messages
  Returns a list of all the users Invite Messages. Admin Credentials are required to view messages of other users!  Message type refers to a different collection of messages, used during different types of responses.  * `message` = Message during a normal invite * `response` = Message when replying to a message * `request` = Message when requesting an invite * `requestResponse` = Message when replying to a request for invite

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - message_type (String.t): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, [%InviteMessage{}, ...]} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_invite_messages(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, list(VRChat.Model.InviteMessage.t)} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def get_invite_messages(connection, user_id, message_type, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/message/#{user_id}/#{message_type}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, [%VRChat.Model.InviteMessage{}]},
      { 400, %VRChat.Model.Error{}},
      { 401, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  Invite User
  Sends an invite to a user. Returns the Notification of type `invite` that was sent.

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
    - :body (InviteRequest): Slot number of the Invite Message to use when inviting a user.
  ## Returns

  {:ok, VRChat.Model.Notification.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec invite_user(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Notification.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def invite_user(connection, user_id, opts \\ []) do
    optional_params = %{
      :body => :body
    }
    %{}
    |> method(:post)
    |> url("/invite/#{user_id}")
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %VRChat.Model.Notification{}},
      { 403, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  Request Invite
  Requests an invite from a user. Returns the Notification of type `requestInvite` that was sent.

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
    - :body (RequestInviteRequest): Slot number of the Request Message to use when request an invite.
  ## Returns

  {:ok, VRChat.Model.Notification.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec request_invite(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Notification.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def request_invite(connection, user_id, opts \\ []) do
    optional_params = %{
      :body => :body
    }
    %{}
    |> method(:post)
    |> url("/requestInvite/#{user_id}")
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %VRChat.Model.Notification{}},
      { 403, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  Reset Invite Message
  Resets a single Invite Message back to its original message, and then returns a list of all of them. Admin Credentials are required to update messages of other users!  Resetting a message respects the rate-limit, so it is not possible to reset within the 60 minutes countdown. Resetting it does however not set the rate-limit to 60 like when editing it. It is possible to edit it right after resetting it. Trying to edit a message before the cooldown timer expires results in a 429 \"Too Fast Error\".  Message type refers to a different collection of messages, used during different types of responses.  * `message` = Message during a normal invite * `response` = Message when replying to a message * `request` = Message when requesting an invite * `requestResponse` = Message when replying to a request for invite  The DELETE endpoint does not have/require any request body.

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - message_type (String.t): 
  - slot (integer()): 
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, [%InviteMessage{}, ...]} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec reset_invite_message(Tesla.Env.client, String.t, String.t, integer(), keyword()) :: {:ok, list(VRChat.Model.InviteMessage.t)} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def reset_invite_message(connection, user_id, message_type, slot, _opts \\ []) do
    %{}
    |> method(:delete)
    |> url("/message/#{user_id}/#{message_type}/#{slot}")
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, [%VRChat.Model.InviteMessage{}]},
      { 400, %VRChat.Model.Error{}},
      { 401, %VRChat.Model.Error{}},
      { 404, %VRChat.Model.Error{}},
      { 429, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  Respond Invite
  Respond to an invite request by sending a world invite to the requesting user. `:notificationId` is the ID of the requesting notification.

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - notification_id (String.t): 
  - opts (KeywordList): [optional] Optional parameters
    - :body (InviteResponse): Slot number of the Response Message to use when responding to a user.
  ## Returns

  {:ok, VRChat.Model.Notification.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec respond_invite(Tesla.Env.client, String.t, keyword()) :: {:ok, VRChat.Model.Notification.t} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def respond_invite(connection, notification_id, opts \\ []) do
    optional_params = %{
      :body => :body
    }
    %{}
    |> method(:post)
    |> url("/invite/#{notification_id}/response")
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, %VRChat.Model.Notification{}},
      { 400, %VRChat.Model.Error{}}
    ])
  end

  @doc """
  Update Invite Message
  Updates a single Invite Message and then returns a list of all of them. Admin Credentials are required to update messages of other users!  Updating a message automatically sets the cooldown timer to 60 minutes. Trying to edit a message before the cooldown timer expires results in a 429 \"Too Fast Error\".  Message type refers to a different collection of messages, used during different types of responses.  * `message` = Message during a normal invite * `response` = Message when replying to a message * `request` = Message when requesting an invite * `requestResponse` = Message when replying to a request for invite

  ## Parameters

  - connection (VRChat.Connection): Connection to server
  - user_id (String.t): 
  - message_type (String.t): 
  - slot (integer()): 
  - opts (KeywordList): [optional] Optional parameters
    - :body (UpdateInviteMessageRequest): Message of what to set the invite message to.
  ## Returns

  {:ok, [%InviteMessage{}, ...]} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_invite_message(Tesla.Env.client, String.t, String.t, integer(), keyword()) :: {:ok, list(VRChat.Model.InviteMessage.t)} | {:ok, VRChat.Model.Error.t} | {:error, Tesla.Env.t}
  def update_invite_message(connection, user_id, message_type, slot, opts \\ []) do
    optional_params = %{
      :body => :body
    }
    %{}
    |> method(:put)
    |> url("/message/#{user_id}/#{message_type}/#{slot}")
    |> add_optional_params(optional_params, opts)
    |> ensure_body()
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      { 200, [%VRChat.Model.InviteMessage{}]},
      { 400, %VRChat.Model.Error{}},
      { 401, %VRChat.Model.Error{}},
      { 429, %VRChat.Model.Error{}}
    ])
  end
end