Current section
Files
Jump to
Current section
Files
lib/open_xchange_client/api/mailaccount.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.Mailaccount do
@moduledoc """
API calls for all endpoints tagged `Mailaccount`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Creates a new mail account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MailAccountData): A JSON object describing the new account to create.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAccountUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec create_account(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MailAccountData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MailAccountUpdateResponse.t()} | {:error, Tesla.Env.t()}
def create_account(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/account?action=new")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountUpdateResponse{}}
])
end
@doc """
Deletes a mail account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body ([integer()]): A JSON array with the ID of the mail account that shall be deleted.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAccountDeletionResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_account(Tesla.Env.client(), String.t(), list(Integer.t()), keyword()) ::
{:ok, OpenXchangeClient.Model.MailAccountDeletionResponse.t()} | {:error, Tesla.Env.t()}
def delete_account(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/account?action=delete")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountDeletionResponse{}}
])
end
@doc """
Gets a mail account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- id (integer()): Account ID of the requested account.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAccountResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_account(Tesla.Env.client(), String.t(), integer(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailAccountResponse.t()} | {:error, Tesla.Env.t()}
def get_account(connection, session, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/account?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :id, id)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountResponse{}}
])
end
@doc """
Gets all mail accounts.
## 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,800\". Each column is specified by a numeric column identifier, see [Mail account data](#mail-account-data).
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAccountsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_accounts(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailAccountsResponse.t()} | {:error, Tesla.Env.t()}
def get_all_accounts(connection, session, columns, _opts \\ []) do
%{}
|> method(:get)
|> url("/account?action=all")
|> add_param(:query, :session, session)
|> add_param(:query, :columns, columns)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountsResponse{}}
])
end
@doc """
Gets the status for a mail account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :id (integer()): The optional account identifier to query the status for a single mail account. If not set the status for all accounts are returned
## Returns
{:ok, OpenXchangeClient.Model.MailAccountStatusResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec status_account(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailAccountStatusResponse.t()} | {:error, Tesla.Env.t()}
def status_account(connection, session, opts \\ []) do
optional_params = %{
:id => :query
}
%{}
|> method(:get)
|> url("/account?action=status")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountStatusResponse{}}
])
end
@doc """
Updates a mail account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MailAccountData): A JSON object identifying (by field `id`) and describing the account to update. Only modified fields are present.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAccountUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec update_account(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MailAccountData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MailAccountUpdateResponse.t()} | {:error, Tesla.Env.t()}
def update_account(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/account?action=update")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAccountUpdateResponse{}}
])
end
@doc """
Validates a mail account which shall be created.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MailAccountData): A JSON object describing the account to validate.
- opts (KeywordList): [optional] Optional parameters
- :tree (boolean()): Indicates whether on successful validation the folder tree shall be returned (or `null`on failure) or if set to `false` or missing only a boolean is returned which indicates validation result.
## Returns
{:ok, OpenXchangeClient.Model.MailAccountValidationResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec validate_account(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MailAccountData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MailAccountValidationResponse.t()}
| {:error, Tesla.Env.t()}
def validate_account(connection, session, body, opts \\ []) do
optional_params = %{
:tree => :query
}
%{}
|> method(:put)
|> url("/account?action=validate")
|> 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.MailAccountValidationResponse{}}
])
end
end