lib/open_xchange_client/api/reminder.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 OpenXchangeClient.Api.Reminder do
  @moduledoc """
  API calls for all endpoints tagged `Reminder`.
  """

  alias OpenXchangeClient.Connection
  import OpenXchangeClient.RequestBuilder

  @doc """
  Deletes reminders.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - body ([OpenXchangeClient.Model.ReminderListElement.t]): A JSON array with JSON objects containing the field `id` of the reminders to delete.
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, OpenXchangeClient.Model.RemindersResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec delete_reminders(
          Tesla.Env.client(),
          String.t(),
          list(OpenXchangeClient.Model.ReminderListElement.t()),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.RemindersResponse.t()} | {:error, Tesla.Env.t()}
  def delete_reminders(connection, session, body, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/reminder?action=delete")
    |> add_param(:query, :session, session)
    |> add_param(:body, :body, body)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.RemindersResponse{}}
    ])
  end

  @doc """
  Gets a reminder range.
  Gets all reminders which are scheduled until the specified time (end date).

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - opts (KeywordList): [optional] Optional parameters
    - :end (integer()): The end date of the reminder range.
    - :modules (String.t): A comma separated list of module ids to retrieve (e.g. \"1,4\" for tasks and appointments). If the parameter is missing or empty then all modules are retrieved.
  ## Returns

  {:ok, OpenXchangeClient.Model.RemindersResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_range(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.RemindersResponse.t()} | {:error, Tesla.Env.t()}
  def get_range(connection, session, opts \\ []) do
    optional_params = %{
      :end => :query,
      :modules => :query
    }

    %{}
    |> method(:get)
    |> url("/reminder?action=range")
    |> add_param(:query, :session, session)
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.RemindersResponse{}}
    ])
  end

  @doc """
  Updates the reminder alarm.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (integer()): The ID of the reminder whose alarm date shall be changed.
  - body (ReminderUpdateBody): A JSON object containing the field `alarm` which provides the new reminder date.
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, OpenXchangeClient.Model.ReminderResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec remind_again(
          Tesla.Env.client(),
          String.t(),
          integer(),
          OpenXchangeClient.Model.ReminderUpdateBody.t(),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.ReminderResponse.t()} | {:error, Tesla.Env.t()}
  def remind_again(connection, session, id, body, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/reminder?action=remindAgain")
    |> add_param(:query, :session, session)
    |> add_param(:query, :id, id)
    |> add_param(:body, :body, body)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.ReminderResponse{}}
    ])
  end
end