# 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.Messaging do
@moduledoc """
API calls for all endpoints tagged `Messaging`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Creates a messaging account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MessagingAccountData): A JSON object describing the account to create. The ID is generated by the server and must not be present.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec create_messaging_account(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MessagingAccountData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t()}
| {:error, Tesla.Env.t()}
def create_messaging_account(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/messaging/account?action=new")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingAccountUpdateResponse{}}
])
end
@doc """
Deletes a messaging account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- messaging_service (String.t): The messaging service ID that the account belongs to.
- id (integer()): The messaging account ID.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_messaging_account(Tesla.Env.client(), String.t(), String.t(), integer(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t()}
| {:error, Tesla.Env.t()}
def delete_messaging_account(connection, session, messaging_service, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/messaging/account?action=delete")
|> add_param(:query, :session, session)
|> add_param(:query, :messagingService, messaging_service)
|> add_param(:query, :id, id)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingAccountUpdateResponse{}}
])
end
@doc """
Gets all messaging accounts.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :messaging_service (String.t): List only those accounts that belong to the given `messagingService`.
## Returns
{:ok, OpenXchangeClient.Model.MessagingAccountsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_messaging_accounts(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingAccountsResponse.t()} | {:error, Tesla.Env.t()}
def get_all_messaging_accounts(connection, session, opts \\ []) do
optional_params = %{
:messagingService => :query
}
%{}
|> method(:get)
|> url("/messaging/account?action=all")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingAccountsResponse{}}
])
end
@doc """
Gets all messaging messages.
## 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 column names, like \"folder,headers,body\". See [Messaging fields](#messaging fields) for valid column names.
- folder (String.t): The folder ID, like \"com.openexchange.messaging.twitter://535/defaultTimeline/directMessages\".
- opts (KeywordList): [optional] Optional parameters
- :sort (String.t): A column name to sort by.
- :order (String.t): The order direction which can be \"asc\" for ascending (default) or \"desc\" for descending.
## Returns
{:ok, OpenXchangeClient.Model.MessagingMessagesResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_messaging_messages(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingMessagesResponse.t()} | {:error, Tesla.Env.t()}
def get_all_messaging_messages(connection, session, columns, folder, opts \\ []) do
optional_params = %{
:sort => :query,
:order => :query
}
%{}
|> method(:get)
|> url("/messaging/message?action=all")
|> add_param(:query, :session, session)
|> add_param(:query, :columns, columns)
|> add_param(:query, :folder, folder)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingMessagesResponse{}}
])
end
@doc """
Gets all messaging services.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingServicesResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_messaging_services(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingServicesResponse.t()} | {:error, Tesla.Env.t()}
def get_all_messaging_services(connection, session, _opts \\ []) do
%{}
|> method(:get)
|> url("/messaging/service?action=all")
|> add_param(:query, :session, session)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingServicesResponse{}}
])
end
@doc """
Gets a messaging account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- messaging_service (String.t): The messaging service ID that the account belongs to.
- id (integer()): The messaging account ID.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingAccountResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_messaging_account(Tesla.Env.client(), String.t(), String.t(), integer(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingAccountResponse.t()} | {:error, Tesla.Env.t()}
def get_messaging_account(connection, session, messaging_service, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/messaging/account?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :messagingService, messaging_service)
|> add_param(:query, :id, id)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingAccountResponse{}}
])
end
@doc """
Gets a messaging message.
A messaging message consists of some metadata, headers and a content. The content attribute varies by the content-type header. If the content-type is `text/*` it is a string, if it is `multipart/*` it is an array of objects, each representing a part of the multipart. If it is anything else it is considered binary and is a Base64 encoded string. The folder ID of a message follows a predefined format: `[messagingService]://[accountId]/[path]`, like `com.openexchange.messaging.twitter://535/defaultTimeline/directMessages`.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- id (String.t): The ID of the message to load.
- folder (String.t): The folder ID of the message.
- opts (KeywordList): [optional] Optional parameters
- :peek (boolean()): If set to `true` the read/unread state of the message will not change. Default is `false`.
## Returns
{:ok, OpenXchangeClient.Model.MessagingMessageResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_messaging_message(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingMessageResponse.t()} | {:error, Tesla.Env.t()}
def get_messaging_message(connection, session, id, folder, opts \\ []) do
optional_params = %{
:peek => :query
}
%{}
|> method(:get)
|> url("/messaging/message?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :id, id)
|> add_param(:query, :folder, folder)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingMessageResponse{}}
])
end
@doc """
Gets a list of messaging messages.
## 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 column names, like \"folder,headers,body\". See [Messaging fields](#messaging-message-columns) for valid column names.
- body ([[map()]]): A JSON array of JSON arrays with the folder and ID as elements each identifying a message.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingMessagesResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_messaging_message_list(
Tesla.Env.client(),
String.t(),
String.t(),
list(list(Map.t())),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingMessagesResponse.t()} | {:error, Tesla.Env.t()}
def get_messaging_message_list(connection, session, columns, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/messaging/message?action=list")
|> add_param(:query, :session, session)
|> add_param(:query, :columns, columns)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingMessagesResponse{}}
])
end
@doc """
Gets a messaging service.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- id (String.t): The ID of the messaging service to load.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingServiceResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_messaging_service(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MessagingServiceResponse.t()} | {:error, Tesla.Env.t()}
def get_messaging_service(connection, session, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/messaging/service?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :id, id)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingServiceResponse{}}
])
end
@doc """
Performs a certain messaging action on a message.
On actions of type \"message\" the body should contain the JSON representation of the message the action should be applied to. To invoke a messaging action of type \"storage\" the folder and id are needed in URL parameters. Messaging actions of type \"none\" need a messaging message and account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- message_action (String.t): The message action to invoke.
- body (MessagingMessageData): A JSON array of JSON arrays with the folder and ID as elements each identifying a message.
- opts (KeywordList): [optional] Optional parameters
- :id (String.t): The ID of the message the action shall be invoked on. Only used on actions of type \"storage\".
- :folder (String.t): The folder ID of the message. Only used on actions of type \"storage\".
- :account (integer()): The account ID. Only used on actions of type \"none\".
## Returns
{:ok, OpenXchangeClient.Model.MessagingMessageUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec perform_messaging_action(
Tesla.Env.client(),
String.t(),
String.t(),
OpenXchangeClient.Model.MessagingMessageData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingMessageUpdateResponse.t()}
| {:error, Tesla.Env.t()}
def perform_messaging_action(connection, session, message_action, body, opts \\ []) do
optional_params = %{
:id => :query,
:folder => :query,
:account => :query
}
%{}
|> method(:put)
|> url("/messaging/message?action=perform")
|> add_param(:query, :session, session)
|> add_param(:query, :messageAction, message_action)
|> add_param(:body, :body, body)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingMessageUpdateResponse{}}
])
end
@doc """
Sends a messaging message.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MessagingMessageData): A JSON array of JSON arrays with the folder and ID as elements each identifying a message.
- opts (KeywordList): [optional] Optional parameters
- :recipients (String.t): A list of recipients as defined in [RFC822](https://tools.ietf.org/html/rfc822), like \"Joe Doe <joe@doe.org>\". If set the message is sent to the given list of recipients, otherwise this defaults to the \"To\" header of the message.
## Returns
{:ok, OpenXchangeClient.Model.MessagingMessageUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec send_messaging_message(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MessagingMessageData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingMessageUpdateResponse.t()}
| {:error, Tesla.Env.t()}
def send_messaging_message(connection, session, body, opts \\ []) do
optional_params = %{
:recipients => :query
}
%{}
|> method(:put)
|> url("/messaging/message?action=send")
|> 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.MessagingMessageUpdateResponse{}}
])
end
@doc """
Updates a messaging account.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MessagingAccountData): A JSON object containing the modified data of the account. The fields `id` and `messagingService` must always be set.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec update_messaging_account(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MessagingAccountData.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.MessagingAccountUpdateResponse.t()}
| {:error, Tesla.Env.t()}
def update_messaging_account(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/messaging/account?action=update")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MessagingAccountUpdateResponse{}}
])
end
end