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

  alias OpenXchangeClient.Connection
  import OpenXchangeClient.RequestBuilder

  @doc """
  Checks the existing upload for given type.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): Object ID of the folder to check.
  - type (String.t): The type of the files to upload (e. g. 'filestorage, 'pim')
  - body (FolderCheckLimitsData): A JSON object containing an array of file meta data (size and name).
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

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

  @doc """
  Clears the content of a list of folders.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - body ([String.t]): A JSON array with object IDs of the folders.
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :push_token (String.t): The client's push token to restrict the generated drive event
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersCleanUpResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec clear_folders(Tesla.Env.client(), String.t(), list(String.t()), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersCleanUpResponse.t()} | {:error, Tesla.Env.t()}
  def clear_folders(connection, session, body, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :allowed_modules => :query,
      :pushToken => :query
    }

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

  @doc """
  Creates a new folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - folder_id (String.t): The parent folder object ID of the newly created folder.
  - session (String.t): A session ID previously obtained from the login module.
  - body (NewFolderBody): JSON object with \"folder\" object containing the modified fields and optional \"notification\" object to let added permission entities be notified about newly shared folders for all modules except mail. (Example: {\"folder\":{\"module\":\"infostore\",\"subscribed\":true,\"title\":\"Test123\"}} or  {\"folder\":{\"module\":\"infostore\",\"subscribed\":true,\"title\":\"Test123\",\"permissions\":[{\"bits\":403710016,\"entity\":84,\"group\":false}]},\"notification\":{\"transport\":\"mail\",\"message\":\"The message\"}})
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :push_token (String.t): The client's push token to restrict the generated drive event
  ## Returns

  {:ok, OpenXchangeClient.Model.FolderUpdateResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec create_folder(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          OpenXchangeClient.Model.NewFolderBody.t(),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.FolderUpdateResponse.t()} | {:error, Tesla.Env.t()}
  def create_folder(connection, folder_id, session, body, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :allowed_modules => :query,
      :pushToken => :query
    }

    %{}
    |> method(:put)
    |> url("/folders?action=new")
    |> add_param(:query, :folder_id, folder_id)
    |> add_param(:query, :session, session)
    |> add_param(:body, :body, body)
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.FolderUpdateResponse{}}
    ])
  end

  @doc """
  Deletes a list of folders.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - body ([String.t]): A JSON array with object IDs of the folders.
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :timestamp (integer()): The optional timestamp of the last update of the deleted folders.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :hard_delete (boolean()): If set to `true`, the folders are deleted permanently. Otherwise, and if the underlying storage supports a trash folder and the folders are not yet located below the trash folder, they are moved to the trash folder.
    - :fail_on_error (boolean()): If an error occured for one folder and this parameter is set to `true` the process will abort and throw an error.  If this parameter is set to 'false' the process will continue for the remaining folders and will add a warning to the response instead.
    - :extended_response (boolean()): If this parameter is set to `true` a different response will be returned. The response contains an array of json objects, which can contain the following fields:   <ul>     <li><code>new_path</code> - The new path of the folder in case of a trash operation.</li>     <li><code>path</code> - The old path.</li>     <li><code>hasFailed</code> - A boolean flag indicating that the delete operation has failed.</li>     <li><code>isTrashed</code> - A boolean flag indicating that the folder has been trashed.</li>     <li><code>isSuppoprted</code> - A boolean flag indicating that the folder storage supports trashing.</li>   </ul>
    - :push_token (String.t): The client's push token to restrict the generated drive event
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersCleanUpResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec delete_folders(Tesla.Env.client(), String.t(), list(String.t()), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersCleanUpResponse.t()} | {:error, Tesla.Env.t()}
  def delete_folders(connection, session, body, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :timestamp => :query,
      :allowed_modules => :query,
      :hardDelete => :query,
      :failOnError => :query,
      :extendedResponse => :query,
      :pushToken => :query
    }

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

  @doc """
  Gets a folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): Object ID of the requested folder.
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
  ## Returns

  {:ok, OpenXchangeClient.Model.FolderResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_folder(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.FolderResponse.t()} | {:error, Tesla.Env.t()}
  def get_folder(connection, session, id, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :allowed_modules => :query,
      :language => :query
    }

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

  @doc """
  Gets the new, modified and deleted folders of a given folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - parent (String.t): Object ID of a folder, which is the parent folder of the requested folders.
  - timestamp (integer()): Timestamp of the last update of the requested folders.
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
    - :ignore (String.t): Which kinds of updates should be ignored. Currently, the only valid value – \"deleted\" – causes deleted object IDs not to be returned.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
  ## Returns

  {:ok, OpenXchangeClient.Model.FolderUpdatesResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_folder_updates(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          integer(),
          String.t(),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.FolderUpdatesResponse.t()} | {:error, Tesla.Env.t()}
  def get_folder_updates(connection, session, parent, timestamp, columns, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :language => :query,
      :ignore => :query,
      :allowed_modules => :query
    }

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

  @doc """
  Gets the parent folders above the specified folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): Object ID of a folder.
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_path(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersResponse.t()} | {:error, Tesla.Env.t()}
  def get_path(connection, session, id, columns, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :allowed_modules => :query,
      :language => :query
    }

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

  @doc """
  Gets the folders at the root level of the folder structure.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
  ## Returns

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

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

  @doc """
  Gets shared folders of a certain module.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - content_type (String.t): The desired content type (either numbers or strings; e.g. \"tasks\", \"calendar\", \"contacts\", \"mail\", \"infostore\").
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
    - :all (integer()): Set to 1 to list even not subscribed folders.
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_shared_folders(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersResponse.t()} | {:error, Tesla.Env.t()}
  def get_shared_folders(connection, session, columns, content_type, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :language => :query,
      :all => :query
    }

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

  @doc """
  Gets the subfolders of a specified parent folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - parent (String.t): Object ID of a folder, which is the parent folder of the requested folders.
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - opts (KeywordList): [optional] Optional parameters
    - :all (integer()): Set to 1 to list even not subscribed folders.
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
    - :error_on_duplicate_name (boolean()):
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_sub_folders(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersResponse.t()} | {:error, Tesla.Env.t()}
  def get_sub_folders(connection, session, parent, columns, opts \\ []) do
    optional_params = %{
      :all => :query,
      :tree => :query,
      :allowed_modules => :query,
      :language => :query,
      :errorOnDuplicateName => :query
    }

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

  @doc """
  Gets all visible folders of a certain module.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - content_type (String.t): The desired content type (either numbers or strings; e.g. \"tasks\", \"calendar\", \"contacts\", \"mail\", \"infostore\").
  - columns (String.t): A comma-separated list of columns to return, like \"1,300\". Each column is specified by a numeric column identifier, see [Common folder data](#common-folder-data) and [Detailed folder data](#detailed-folder-data).
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :language (String.t): Optional locale to use instead of the currently configured locale of the user.
  ## Returns

  {:ok, OpenXchangeClient.Model.FoldersVisibilityResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec get_visible_folders(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
          {:ok, OpenXchangeClient.Model.FoldersVisibilityResponse.t()} | {:error, Tesla.Env.t()}
  def get_visible_folders(connection, session, content_type, columns, opts \\ []) do
    optional_params = %{
      :tree => :query,
      :language => :query
    }

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

  @doc """
  Notifies users or groups about a shared folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): Object ID of the shared folder to notify about.
  - body (FolderSharingNotificationBody): JSON object providing the JSON array `entities`, which holds the entity ID(s) of the users or groups that should be notified. To send a custom message to the recipients, an additional JSON object `notification` may be included, inside of which an optional message can be passed (otherwise, some default message is used). (Example: {\"entities\":[\"2332\"]} or {\"entities\":[\"2332\"],\"notification\":{\"transport\":\"mail\",\"message\":\"The message\"}})
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
  ## Returns

  {:ok, OpenXchangeClient.Model.FolderSharingNotificationResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec notify_about_shared_folder(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          OpenXchangeClient.Model.FolderSharingNotificationBody.t(),
          keyword()
        ) ::
          {:ok, OpenXchangeClient.Model.FolderSharingNotificationResponse.t()}
          | {:error, Tesla.Env.t()}
  def notify_about_shared_folder(connection, session, id, body, opts \\ []) do
    optional_params = %{
      :tree => :query
    }

    %{}
    |> method(:put)
    |> url("/folders?action=notify")
    |> add_param(:query, :session, session)
    |> add_param(:query, :id, id)
    |> add_param(:body, :body, body)
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.FolderSharingNotificationResponse{}}
    ])
  end

  @doc """
  Restore specified folders from trash folder

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - opts (KeywordList): [optional] Optional parameters
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :push_token (String.t): The client's push token to restrict the generated drive event
  ## Returns

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

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

  @doc """
  Updates a folder.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - id (String.t): Object ID of the updated folder.
  - body (FolderBody): JSON object with \"folder\" object containing the modified fields and optional \"notification\" object to let added permission entities be notified about newly shared folders for all modules except mail. (Example: {\"folder\":{\"title\":\"test123\"}} or {\"folder\":{\"permissions\":[{\"bits\":403710016,\"entity\":84,\"group\":false}]},\"notification\":{\"transport\":\"mail\",\"message\":\"The message\"}})
  - opts (KeywordList): [optional] Optional parameters
    - :allow_enqueue (boolean()): Optional flag that specifies whether the request is allowed for being submitted to job queue.
    - :timestamp (integer()): Timestamp of the updated folder. If the folder was modified after the specified timestamp, then the update must fail.
    - :tree (String.t): The identifier of the folder tree. If missing \"0\" (primary folder tree) is assumed.
    - :allowed_modules (String.t): An array of modules (either numbers or strings; e.g. \"tasks,calendar,contacts,mail\") supported by requesting client. If missing, all available modules are considered.
    - :cascade_permissions (boolean()): `true` to cascade permissions to all sub-folders. The user must have administrative permissions to all sub-folders subject to change. If one permission change fails, the entire operation fails.
    - :push_token (String.t): The client's push token to restrict the generated drive event
  ## Returns

  {:ok, OpenXchangeClient.Model.FolderUpdateResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_folder(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          OpenXchangeClient.Model.FolderBody.t(),
          keyword()
        ) ::
          {:ok, OpenXchangeClient.Model.FolderUpdateResponse.t()}
          | {:ok, OpenXchangeClient.Model.GetJobResponse.t()}
          | {:error, Tesla.Env.t()}
  def update_folder(connection, session, id, body, opts \\ []) do
    optional_params = %{
      :allow_enqueue => :query,
      :timestamp => :query,
      :tree => :query,
      :allowed_modules => :query,
      :cascadePermissions => :query,
      :pushToken => :query
    }

    %{}
    |> method(:put)
    |> url("/folders?action=update")
    |> add_param(:query, :session, session)
    |> add_param(:query, :id, id)
    |> add_param(:body, :body, body)
    |> add_optional_params(optional_params, opts)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.FolderUpdateResponse{}},
      {202, %OpenXchangeClient.Model.GetJobResponse{}}
    ])
  end
end