Current section

Files

Jump to
open_xchange_client lib open_xchange_client api mail.ex
Raw

lib/open_xchange_client/api/mail.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.Mail do
@moduledoc """
API calls for all endpoints tagged `Mail`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Auto saves an e-mail as draft.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :csid (String.t): The \"csid\" parameter providing the composition space identifier.
- :nested_msgs ([OpenXchangeClient.Model.NestedMailData.t]): An array containing additional mails that are attached to this mail.
- :security_info ([OpenXchangeClient.Model.GuardSecurityInfo.t]): Information if mail is encrypted or signed. Requires Guard
- :security ([OpenXchangeClient.Model.GuardSecurityResult.t]): Information regarding signature verification or decryption type after processed by Guard
- :authenticity (OpenXchangeClient.Model.AuthenticationResult.t):
- :color_label (integer()): Color number used by Outlook to label the object. The assignment of colors to numbers is arbitrary and specified by the client. The numbers are integer numbers between 0 and 10 (inclusive).
- :id (String.t): Object ID of the mail.
- :folder_id (String.t): Object ID of the parent folder.
- :attachment (boolean()): Indicates whether this mail has attachments.
- :from ([[String.t]]): Each element is a two-element array specifying one sender (address). The first element of each address is the personal name, the second element is the email address. Missing address parts are represented by null values.
- :to ([[String.t]]): Each element is a two-element array (see the from field) specifying one receiver.
- :cc ([[String.t]]): Each element is a two-element array (see the from field) specifying one carbon-copy receiver.
- :bcc ([[String.t]]): Each element is a two-element array (see the from field) specifying one blind carbon-copy receiver.
- :subject (String.t): The mail's subject.
- :size (integer()): The size if the mail in bytes.
- :sent_date (integer()): Date and time as specified in the mail by the sending client.
- :received_date (integer()): Date and time as measured by the receiving server.
- :flags (integer()): Various system flags. A sum of zero or more of following values (see [javax.mail.Flags.Flag](http://docs.oracle.com/javaee/6/api/javax/mail/Flags.Flag.html) for details).
- :level (integer()): Zero-based nesting level in a thread.
- :disp_notification_to (String.t): Content of message's header \\\"Disposition-Notification-To\\\".
- :priority (integer()): Value of message's X-Priority header.
- :msg_ref (String.t): Message reference on reply/forward.
- :flag_seen (String.t): Special field to sort mails by seen status.
- :account_name (String.t): Message's account name.
- :account_id (integer()): Message's account identifier.
- :user ([String.t]): An array with user-defined flags as strings.
- :headers (map()): A map with fields for every non-standard header. The header name is the field name. The header value is the value of the field as string.
- :attachments ([OpenXchangeClient.Model.MailAttachment.t]): Each element is an attachment. The first element is the mail text. If the mail has multiple representations (multipart-alternative), then the alternatives are placed after the mail text and have the field disp set to alternative.
- :truncated (boolean()): `true` / `false` if the mail content was trimmed.
- :source (String.t): [RFC822](https://tools.ietf.org/html/rfc822) source of the mail. Only present for \\\"?action=get&attach_src=true\\\".
- :cid (String.t): The value of the \\\"Content-ID\\\" header, if the header is present.
- :original_id (String.t): The original mail identifier (e.g. if fetched from \\\"virtual/all\\\" folder).
- :original_folder_id (String.t): The original folder identifier (e.g. if fetched from \\\"virtual/all\\\" folder).
- :content_type (String.t): The MIME type of the mail.
- :text_preview (String.t): The optional preview of the mail body
## Returns
{:ok, OpenXchangeClient.Model.MailsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec autosave(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailsResponse.t()} | {:error, Tesla.Env.t()}
def autosave(connection, session, opts \\ []) do
optional_params = %{
:csid => :query,
:nested_msgs => :form,
:security_info => :form,
:security => :form,
:authenticity => :form,
:color_label => :form,
:id => :form,
:folder_id => :form,
:attachment => :form,
:from => :form,
:to => :form,
:cc => :form,
:bcc => :form,
:subject => :form,
:size => :form,
:sent_date => :form,
:received_date => :form,
:flags => :form,
:level => :form,
:disp_notification_to => :form,
:priority => :form,
:msg_ref => :form,
:flag_seen => :form,
:account_name => :form,
:account_id => :form,
:user => :form,
:headers => :form,
:attachments => :form,
:truncated => :form,
:source => :form,
:cid => :form,
:original_id => :form,
:original_folder_id => :form,
:content_type => :form,
:text_preview => :form
}
%{}
|> method(:put)
|> url("/mail?action=autosave")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsResponse{}}
])
end
@doc """
Clears the content of mail 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 mail folders that shall be cleared.
- opts (KeywordList): [optional] Optional parameters
- :timestamp (integer()): Not IMAP: timestamp of the last update of the deleted mails.
## Returns
{:ok, OpenXchangeClient.Model.MailsCleanUpResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec clear_mail_folders(Tesla.Env.client(), String.t(), list(String.t()), keyword()) ::
{:ok, OpenXchangeClient.Model.MailsCleanUpResponse.t()} | {:error, Tesla.Env.t()}
def clear_mail_folders(connection, session, body, opts \\ []) do
optional_params = %{
:timestamp => :query
}
%{}
|> method(:put)
|> url("/mail?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.MailsCleanUpResponse{}}
])
end
@doc """
Copies a mail to another 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 mail that shall be copied.
- folder (String.t): Object ID of the folder who contains the mails.
- body (MailDestinationBody): A JSON object containing the id of the destination folder.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailDestinationResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec copy_mail(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
OpenXchangeClient.Model.MailDestinationBody.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailDestinationResponse.t()} | {:error, Tesla.Env.t()}
def copy_mail(connection, session, id, folder, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/mail?action=copy")
|> add_param(:query, :session, session)
|> add_param(:query, :id, id)
|> add_param(:query, :folder, folder)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailDestinationResponse{}}
])
end
@doc """
Deletes mails.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body ([OpenXchangeClient.Model.MailListElement.t]): A JSON array of JSON objects with the id and folder of the mails.
- opts (KeywordList): [optional] Optional parameters
- :timestamp (integer()): Not IMAP: timestamp of the last update of the deleted mails.
- :harddelete (boolean()): Flag to hard delete the messages, meaning not to create a backup copy of each message in default trash if set to `true`.
- :return_affected_folders (boolean()): Flag to generate an JSON reponse as described below. If set to `false` just an empty JSON Array is returned.
## Returns
{:ok, OpenXchangeClient.Model.MailsCleanUpResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_mails(
Tesla.Env.client(),
String.t(),
list(OpenXchangeClient.Model.MailListElement.t()),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailsCleanUpResponse.t()} | {:error, Tesla.Env.t()}
def delete_mails(connection, session, body, opts \\ []) do
optional_params = %{
:timestamp => :query,
:harddelete => :query,
:returnAffectedFolders => :query
}
%{}
|> method(:put)
|> url("/mail?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.MailsCleanUpResponse{}}
])
end
@doc """
Examines a specifed mail folder and provides its basic status information
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): The identifier of the folder to provide the status information for
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.ExamineResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec examine(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.ExamineResponse.t()} | {:error, Tesla.Env.t()}
def examine(connection, session, folder, _opts \\ []) do
%{}
|> method(:get)
|> url("/mail?action=examine")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.ExamineResponse{}}
])
end
@doc """
Forwards a mail.
Returns the data for the message that shall be forwarded.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the requested message.
- opts (KeywordList): [optional] Optional parameters
- :view (String.t): Content 'text' forces the server to deliver a text-only version of the requested mail's body, even if content is HTML. 'html' to allow a possible HTML mail body being transferred as it is (but white-list filter applied). NOTE: if set, the corresponding gui config setting will be ignored.
- :max_size (integer()): A positive integer number (greater than 10000) to specify how many characters of the message content will be returned. If the number is smaller than 10000 the value will be ignored and 10000 used.
- :decrypt (boolean()): If true, and the object is encrypted, an attempt will be made to decrypt the object. An error will be thrown if needed authentication isn't available. (Guard Required)
- :crypto_auth (String.t): Authentication token used for Guard in order to decrypt or sign items. Required if the token is not attached to the session and the decrypt flag was sent.
## Returns
{:ok, OpenXchangeClient.Model.MailReplyResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec forward_mail(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailReplyResponse.t()} | {:error, Tesla.Env.t()}
def forward_mail(connection, session, folder, id, opts \\ []) do
optional_params = %{
:view => :query,
:max_size => :query,
:decrypt => :query,
:cryptoAuth => :query
}
%{}
|> method(:get)
|> url("/mail?action=forward")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailReplyResponse{}}
])
end
@doc """
Gets all mails.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- columns (String.t): A comma-separated list of either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
- :unseen (boolean()): If `true` only mails without the `\\Seen` flag are returned.
- :deleted (boolean()): If `false` only mails without the `\\Deleted` flag are returned.
- :sort (String.t): The identifier of a column which determines the sort order of the response. If this parameter is specified, then the parameter order must be also specified.
- :order (String.t): \"asc\" if the response entities should be sorted in the ascending order, \"desc\" if the response entries should be sorted in the descending order. If this parameter is specified, then the parameter sort must be also specified.
- :left_hand_limit (integer()): A positive integer number to specify the \"left-hand\" limit of the range to return.
- :right_hand_limit (integer()): A positive integer number to specify the \"right-hand\" limit of the range to return.
- :limit (integer()): A positive integer number to specify how many items shall be returned according to given sorting; overrides `left_hand_limit`/`right_hand_limit` parameters and is equal to `left_hand_limit=0` and `right_hand_limit=<limit>`.
- :categoryid (String.t): The category id to filter for. If set to \"general\" all mails which does not belong to any other category are retrieved.
## Returns
{:ok, OpenXchangeClient.Model.MailsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_mails(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailsResponse.t()} | {:error, Tesla.Env.t()}
def get_all_mails(connection, session, folder, columns, opts \\ []) do
optional_params = %{
:headers => :query,
:unseen => :query,
:deleted => :query,
:sort => :query,
:order => :query,
:left_hand_limit => :query,
:right_hand_limit => :query,
:limit => :query,
:categoryid => :query
}
%{}
|> method(:get)
|> url("/mail?action=all")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsResponse{}}
])
end
@doc """
Gets multiple mail attachments as a ZIP file.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the mail which contains the attachments.
- attachment (String.t): A comma-separated list of IDs of the requested attachments.
- opts (KeywordList): [optional] Optional parameters
- :scan (boolean()): Flag to request an Anti-Virus scan for the specified e-mail attachments before downloading them.
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachments_as_zip(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
String.t(),
keyword()
) :: {:ok, String.t()} | {:error, Tesla.Env.t()}
def get_attachments_as_zip(connection, session, folder, id, attachment, opts \\ []) do
optional_params = %{
:scan => :query
}
%{}
|> method(:get)
|> url("/mail?action=zip_attachments")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_param(:query, :attachment, attachment)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Gets a mail.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- opts (KeywordList): [optional] Optional parameters
- :id (String.t): Object ID of the requested mail (can be substituded by `message_id` parameter).
- :message_id (String.t): The value of \"Message-Id\" header of the requested mail. This parameter is a substitute for \"id\" parameter.
- :edit (integer()): 1 indicates that this request should fill the message compose dialog to edit a message and thus display-specific date is going to be withheld.
- :view (String.t): \"Specifies the view of the mail's body: raw (returns the content as it is, meaning no preparation are performed and thus no guarantee for safe contents is given), text ( forces the server to deliver a text-only version of the requested mail's body, even if content is HTML), textNoHtmlAttach (is the same as 'text', but does not deliver the HTML part as attachment in case of multipart/alternative content), html (to allow a possible HTML mail body being transferred as it is (but white-list filter applied)), noimg (to allow a possible HTML content being transferred but without original image src attributes which references external images; can be used to prevent loading external linked images (spam privacy protection)). document (to have a inline HTML representation of message's content in a separate window) **If set, the corresponding gui config setting will be ignored.**\"
- :force_images (boolean()): Use `true` to enforce that images are allowed in HTML content. Only applicable in case `view` parameter is `document`
- :unseen (boolean()): Use `true` to leave an unseen mail as unseen although its content is requested.
- :max_size (integer()): A positive integer number (greater than 10000) to specify how many characters of the message content will be returned. If the number is smaller than 10000 the value will be ignored and 10000 used.
- :attach_src (integer()): 1 to let the JSON mail representation being extended by \"source\" field containing the mail raw RFC822 source data.
- :estimate_length (boolean()): If set to \"true\" the \"size\" field for mail attachments is adjusted by applying an estimation based on attachment's Content-Transfer-Encoding header
- :pregenerate_previews (boolean()): If set to \"true\" preview generation is triggered in the background for all file attachments of the referenced mail message
- :no_nested_message (boolean()): If set to \"true\" nested messages are handled as regular attachments
- :decrypt (boolean()): If true, and the object is encrypted, an attempt will be made to decrypt the object. An error will be thrown if needed authentication isn't available. (Guard Required)
- :crypto_auth (String.t): Authentication token used for Guard in order to decrypt or sign items. Required if the token is not attached to the session and the decrypt flag was sent.
## Returns
{:ok, OpenXchangeClient.Model.MailResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailResponse.t()} | {:error, Tesla.Env.t()}
def get_mail(connection, session, folder, opts \\ []) do
optional_params = %{
:id => :query,
:message_id => :query,
:edit => :query,
:view => :query,
:forceImages => :query,
:unseen => :query,
:max_size => :query,
:attach_src => :query,
:estimate_length => :query,
:pregenerate_previews => :query,
:no_nested_message => :query,
:decrypt => :query,
:cryptoAuth => :query
}
%{}
|> method(:get)
|> url("/mail?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailResponse{}}
])
end
@doc """
Gets a mail attachment.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the mail which contains the attachment.
- opts (KeywordList): [optional] Optional parameters
- :attachment (String.t): ID of the requested attachment (can be substituted by the parameter `cid` otherwise this parameter is **madatory**).
- :cid (String.t): Value of header 'Content-ID' of the requested attachment (can be substituted by the parameter `attachment` otherwise this parameter is **madatory**).
- :save (integer()): 1 overwrites the defined mimetype for this attachment to force the download dialog, otherwise 0.
- :filter (integer()): 1 to apply HTML white-list filter rules if and only if requested attachment is of MIME type `text/htm*` **AND** parameter `save` is set to 0.
- :allow_nested_messages (boolean()): A value of \"false\" leads to light-weight JSON objects for nested messages containing only the \"id\" field
- :scan (boolean()): Flag to request an Anti-Virus scan for the specified e-mail attachment before downloading it. Note that if there is a max file limitation set on the middleware, the URL parameter 'exact_length' has to be set to 'true' to instruct the middleware to calculate the attachment's size before passing it to the Anti-Virus scanner.
- :as_json (boolean()): Nested messages are parsed into full JSON objects. Can lead to longer loading times, for multiple nested messages.
- :decrypt (boolean()): If true, and the object is encrypted, an attempt will be made to decrypt the object. An error will be thrown if needed authentication isn't available. (Guard Required)
- :crypto_auth (String.t): Authentication token used for Guard in order to decrypt or sign items. Required if the token is not attached to the session and the decrypt flag was sent.
- :rotate (boolean()): Adds a 'rotate' transformation, leading to the image being rotated according to the contained EXIF information.
- :width (integer()): The maximum width of the target image.
- :height (integer()): The maximum height of the target image.
- :shrink_only (boolean()): Set to true to only scale images 'greater than' target size.
- :scale_type (String.t): Defines the scale type. Possible value: <ul> <li><code>cover</code> - The \"cover\" scale type, specifying the minimum target dimensions. <br> The source image will be resized in a way that the resulting image covers the target resolution entirely, with the original aspect ratio being preserved. For example, scaling an image with an original resolution of 640x480 pixels to 200x200 pixels and type \"cover\", will result in the picture being resized to 267x200 pixels.</li> <li><code>contain</code> - The \"contain\" scale type, specifying the maximum target dimensions. <br> The source image will be resized in a way that the resulting image fits into the target resolution entirely, with the original aspect ratio being preserved. For example, scaling an image with an original resolution of 640x480 pixels to 200x200 pixels and type \"contain\", will result in the picture being resized to 200x150 pixels.</li> <li><code>containforcedimension</code> - The \"containforcedimension\" scale type, specifying the maximum target dimensions. <br> The source image will be resized in a way that the resulting image fits into the target resolution entirely, with the original aspect ratio being preserved while smaller sides get padded to fit exact dimension. For example, scaling an image with an original resolution of 640x480 pixels to 200x200 pixels and type \"containforcedimension\", will result in the picture being first resized to 200x150 pixels, then height gets padded by 25 pixels per side resulting in exactly 200x200 pixels.</li> <li><code>coverandcrop</code> - The \"coverandcrop\" scale type, specifying the target dimensions. <br> If the source image is bigger than the target dimension, in a first step the image will be resized in a way that the resulting image covers the target resolution entirely, with the original aspect ratio being preserved. In a second step the image will be cropped to fit the target dimension. For example, scaling an image with an original resolution of 640x480 pixels to 200x200 pixels and type \"coverandcrop\", will result in the picture being resized to 267x200 pixels and then cropped to fit 200x200. In case the image is smaller than then target dimension the image will not be resized and instead it gets padded to fit exact dimension. For example, with an original resolution of 100x100 pixels and a target dimension of 200x200 pixels and type \"coverandcrop\", will result in the picture being padded on all sides with 50 pixels.</li> <li><code>auto</code> - The \"auto\" scale type.<br></li> </ul>
- :crop_width (integer()): The width of the specified rectangular region.
- :crop_height (integer()): The height of the specified rectangular region.
- :crop_x (integer()): The X coordinate of the upper-left corner of the specified rectangular region.
- :crop_y (integer()): The Y coordinate of the upper-left corner of the specified rectangular region.
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_attachment(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def get_mail_attachment(connection, session, folder, id, opts \\ []) do
optional_params = %{
:attachment => :query,
:cid => :query,
:save => :query,
:filter => :query,
:allow_nested_messages => :query,
:scan => :query,
:as_json => :query,
:decrypt => :query,
:cryptoAuth => :query,
:rotate => :query,
:width => :query,
:height => :query,
:shrinkOnly => :query,
:scaleType => :query,
:cropWidth => :query,
:cropHeight => :query,
:cropX => :query,
:cropY => :query
}
%{}
|> method(:get)
|> url("/mail?action=attachment")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Gets all mail conversations.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- columns (String.t): A comma-separated list of either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
- :unseen (boolean()): If `true` only mails without the `\\Seen` flag are returned.
- :deleted (boolean()): If `false` only mails without the `\\Deleted` flag are returned.
- :sort (String.t): The identifier of a column which determines the sort order of the response or the string “thread” to return thread-sorted messages. If this parameter is specified and holds a column number, then the parameter order must be also specified. Note: Applies only to root-level messages.
- :order (String.t): \"asc\" if the response entires should be sorted in the ascending order, \"desc\" if the response entries should be sorted in the descending order. If this parameter is specified, then the parameter sort must be also specified. Note: Applies only to root-level messages.
- :include_sent (boolean()): A boolean value to signal that conversations also include messages taken from special \"sent\" aka \"sent items\" folder.
- :left_hand_limit (integer()): A positive integer number to specify the \"left-hand\" limit of the range to return. Note: Applies only to root-level messages.
- :right_hand_limit (integer()): A positive integer number to specify the \"right-hand\" limit of the range to return. Note: Applies only to root-level messages.
- :limit (integer()): A positive integer number to specify how many items shall be returned according to given sorting; overrides `left_hand_limit`/`right_hand_limit` parameters and is equal to `left_hand_limit=0` and `right_hand_limit=<limit>`. Note: Applies only to root-level messages.
- :categoryid (String.t): The category id to filter for. Retrieves all conversations with at least one mail in the category.
- :max (String.t): The max. number of messages to consider.
## Returns
{:ok, OpenXchangeClient.Model.MailConversationsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_conversations(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailConversationsResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_conversations(connection, session, folder, columns, opts \\ []) do
optional_params = %{
:headers => :query,
:unseen => :query,
:deleted => :query,
:sort => :query,
:order => :query,
:includeSent => :query,
:left_hand_limit => :query,
:right_hand_limit => :query,
:limit => :query,
:categoryid => :query,
:max => :query
}
%{}
|> method(:get)
|> url("/mail?action=threadedAll")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailConversationsResponse{}}
])
end
@doc """
Gets the mail count.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailCountResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_count(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailCountResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_count(connection, session, folder, _opts \\ []) do
%{}
|> method(:get)
|> url("/mail?action=count")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailCountResponse{}}
])
end
@doc """
Gets the message headers as plain text.
#### Note By setting the query parameter `hdr` to 1 the response type of the request action changes. Then it is returned a JSON object with the field `data` containing the (formatted) message headers as plain text. The parameters below specify the ones that have an effect on the request.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- opts (KeywordList): [optional] Optional parameters
- :id (String.t): Object ID of the requested mail (can be substituded by `message_id` parameter).
- :message_id (String.t): The value of \"Message-Id\" header of the requested mail. This parameter is a substitute for \"id\" parameter.
- :unseen (boolean()): Use `true` to leave an unseen mail as unseen although its content is requested.
## Returns
{:ok, OpenXchangeClient.Model.MailHeadersResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_headers(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailHeadersResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_headers(connection, session, folder, opts \\ []) do
optional_params = %{
:id => :query,
:message_id => :query,
:unseen => :query
}
%{}
|> method(:get)
|> url("/mail?action=get&amp;hdr=1")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailHeadersResponse{}}
])
end
@doc """
Gets a list of mails.
## 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 either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- body ([OpenXchangeClient.Model.MailListElement.t]): A JSON array of JSON objects with the id and folder of the requested mails.
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
## Returns
{:ok, OpenXchangeClient.Model.MailsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_list(
Tesla.Env.client(),
String.t(),
String.t(),
list(OpenXchangeClient.Model.MailListElement.t()),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailsResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_list(connection, session, columns, body, opts \\ []) do
optional_params = %{
:headers => :query
}
%{}
|> method(:put)
|> url("/mail?action=list")
|> add_param(:query, :session, session)
|> add_param(:query, :columns, columns)
|> add_param(:body, :body, body)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsResponse{}}
])
end
@doc """
Gets the complete message source as plain text.
#### Note By setting the query parameter `src` to 1 the response type of the request action changes. Then it is returned a JSON object with the field `data` containing the complete message source as plain text. The parameters below specify the ones that have an effect on the request.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- opts (KeywordList): [optional] Optional parameters
- :id (String.t): Object ID of the requested mail (can be substituded by `message_id` parameter).
- :message_id (String.t): The value of \"Message-Id\" header of the requested mail. This parameter is a substitute for \"id\" parameter.
- :unseen (boolean()): Use `true` to leave an unseen mail as unseen although its content is requested.
- :save (integer()): 1 to write the complete message source to output stream. **NOTE:** This parameter will only be used if parameter `src` is set to 1.
## Returns
{:ok, OpenXchangeClient.Model.MailSourceResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_source(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailSourceResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_source(connection, session, folder, opts \\ []) do
optional_params = %{
:id => :query,
:message_id => :query,
:unseen => :query,
:save => :query
}
%{}
|> method(:get)
|> url("/mail?action=get&amp;src=1")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailSourceResponse{}}
])
end
@doc """
Gets updated mails.
Provides a list of updated mails. **Attention**: This does **not** work for IMAP mail accounts. In case of imap accounts an empty list is returned.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- columns (String.t): A comma-separated list of either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
- :ignore (String.t): The type of updates which should be ignored. Currently known values are 'deleted' and 'changed'. E.g. if you only want to retrieve deleted mails you use 'ignore=changed'.
## Returns
{:ok, OpenXchangeClient.Model.MailsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_updates(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailsResponse.t()} | {:error, Tesla.Env.t()}
def get_mail_updates(connection, session, folder, columns, opts \\ []) do
optional_params = %{
:headers => :query,
:ignore => :query
}
%{}
|> method(:get)
|> url("/mail?action=updates")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsResponse{}}
])
end
@doc """
Gets multiple mails as a ZIP file.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): A comma-separated list of Object IDs of the requested mails.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mails_as_zip(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def get_mails_as_zip(connection, session, folder, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/mail?action=zip_messages")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Gets all mail thread references.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- columns (String.t): A comma-separated list of either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
- :sort (String.t): The identifier of a column which determines the sort order of the response or the string “thread” to return thread-sorted messages. If this parameter is specified and holds a column number, then the parameter order must be also specified. Note: Applies only to root-level messages.
- :order (String.t): \"asc\" if the response entires should be sorted in the ascending order, \"desc\" if the response entries should be sorted in the descending order. If this parameter is specified, then the parameter sort must be also specified. Note: Applies only to root-level messages.
- :size (integer()): The optional number of latest messages to consider.
## Returns
{:ok, OpenXchangeClient.Model.MailThreadReferencesResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_thread_references(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailThreadReferencesResponse.t()}
| {:error, Tesla.Env.t()}
def get_thread_references(connection, session, folder, columns, opts \\ []) do
optional_params = %{
:headers => :query,
:sort => :query,
:order => :query,
:size => :query
}
%{}
|> method(:get)
|> url("/mail?action=thread_references")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailThreadReferencesResponse{}}
])
end
@doc """
Import of mails as MIME data block ([RFC822](https://tools.ietf.org/html/rfc822)).
This request can be used to store a single or a lot of mails in the OX mail storage backend. This action should be used instead of [/mail?action=new](#operation--mail-action-new-post) because it is faster and tolerant to 8-bit encoded emails. To import multiple mails add further form-data fields.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): The ID of the folder into that the emails should be imported.
- file (String.t): The [RFC822](https://tools.ietf.org/html/rfc822) encoded email as binary data.
- opts (KeywordList): [optional] Optional parameters
- :flags (String.t): In case the mail should be stored with status \"read\" (e.g. mail has been read already in the client inbox), the parameter \"flags\" has to be included. For information about mail flags see [Detailed mail data](#detailed-mail-data).
- :force (boolean()): If this parameter is set to `true`, the server skips checking the valid from address.
## Returns
{:ok, OpenXchangeClient.Model.MailImportResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec import_mail(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailImportResponse.t()} | {:error, Tesla.Env.t()}
def import_mail(connection, session, folder, file, opts \\ []) do
optional_params = %{
:flags => :query,
:force => :query
}
%{}
|> method(:post)
|> url("/mail?action=import")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:file, :file, file)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailImportResponse{}}
])
end
@doc """
Marks all mails of a folder as seen.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailsAllSeenResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec mark_all_mails_as_read(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailsAllSeenResponse.t()} | {:error, Tesla.Env.t()}
def mark_all_mails_as_read(connection, session, folder, _opts \\ []) do
%{}
|> method(:put)
|> url("/mail?action=all_seen")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsAllSeenResponse{}}
])
end
@doc """
Stores a mail attachment to the drive.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the mail which contains the attachment.
- attachment (String.t): ID of the requested attachment.
- dest_folder (String.t): Object ID of the folder in which the attachment should be stored.
- body (PutAttachmentBody): A possible empty JSON object containing the optional fields `description` and `filename`. The filename and description values will be used for the newly created file in the drive module.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.InlineResponse200.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec put_mail_attachment(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
String.t(),
String.t(),
OpenXchangeClient.Model.PutAttachmentBody.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.InlineResponse200.t()} | {:error, Tesla.Env.t()}
def put_mail_attachment(
connection,
session,
folder,
id,
attachment,
dest_folder,
body,
_opts \\ []
) do
%{}
|> method(:put)
|> url("/mail?action=attachment")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_param(:query, :attachment, attachment)
|> add_param(:query, :dest_folder, dest_folder)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.InlineResponse200{}}
])
end
@doc """
Requests a delivery receipt for a priviously sent mail.
This delivery receipt only acknowledges that the message could be receipted on the recipients computer.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (MailAckBody): A JSON object containing the information of a mail for which a delivery receipt shall be requested.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailAckResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec receipt_mail_ack(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.MailAckBody.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailAckResponse.t()} | {:error, Tesla.Env.t()}
def receipt_mail_ack(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/mail?action=receipt_ack")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailAckResponse{}}
])
end
@doc """
Replies a mail to all.
Returns the data for the message that shall be replied.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the requested message.
- opts (KeywordList): [optional] Optional parameters
- :view (String.t): Content 'text' forces the server to deliver a text-only version of the requested mail's body, even if content is HTML. 'html' to allow a possible HTML mail body being transferred as it is (but white-list filter applied). NOTE: if set, the corresponding gui config setting will be ignored.
- :set_from (boolean()): A flag (`true`/`false`) that signals if \"From\" header shall be pre-selected according to a suitable recipient address that matches one of user's email address aliases.
- :max_size (integer()): A positive integer number (greater than 10000) to specify how many characters of the message content will be returned. If the number is smaller than 10000 the value will be ignored and 10000 used.
- :decrypt (boolean()): If true, and the object is encrypted, an attempt will be made to decrypt the object. An error will be thrown if needed authentication isn't available. (Guard Required)
- :crypto_auth (String.t): Authentication token used for Guard in order to decrypt or sign items. Required if the token is not attached to the session and the decrypt flag was sent.
## Returns
{:ok, OpenXchangeClient.Model.MailReplyResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec reply_all_mail(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailReplyResponse.t()} | {:error, Tesla.Env.t()}
def reply_all_mail(connection, session, folder, id, opts \\ []) do
optional_params = %{
:view => :query,
:setFrom => :query,
:max_size => :query,
:decrypt => :query,
:cryptoAuth => :query
}
%{}
|> method(:get)
|> url("/mail?action=replyall")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailReplyResponse{}}
])
end
@doc """
Replies a mail.
Returns the data for the message that shall be replied.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- id (String.t): Object ID of the requested message.
- opts (KeywordList): [optional] Optional parameters
- :view (String.t): Content 'text' forces the server to deliver a text-only version of the requested mail's body, even if content is HTML. 'html' to allow a possible HTML mail body being transferred as it is (but white-list filter applied). NOTE: if set, the corresponding gui config setting will be ignored.
- :set_from (boolean()): A flag (`true`/`false`) that signals if \"From\" header shall be pre-selected according to a suitable recipient address that matches one of user's E-Mail address aliases.
- :max_size (integer()): A positive integer number (greater than 10000) to specify how many characters of the message content will be returned. If the number is smaller than 10000 the value will be ignored and 10000 used.
- :decrypt (boolean()): If true, and the object is encrypted, an attempt will be made to decrypt the object. An error will be thrown if needed authentication isn't available. (Guard Required)
- :crypto_auth (String.t): Authentication token used for Guard in order to decrypt or sign items. Required if the token is not attached to the session and the decrypt flag was sent.
## Returns
{:ok, OpenXchangeClient.Model.MailReplyResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec reply_mail(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailReplyResponse.t()} | {:error, Tesla.Env.t()}
def reply_mail(connection, session, folder, id, opts \\ []) do
optional_params = %{
:view => :query,
:setFrom => :query,
:max_size => :query,
:decrypt => :query,
:cryptoAuth => :query
}
%{}
|> method(:get)
|> url("/mail?action=reply")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :id, id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailReplyResponse{}}
])
end
@doc """
Resolves a given share reference
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- body (ResolveShareReferenceElement): A JSON object providing the share reference to resolve
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.ResolveShareReferenceResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec resolve_share_reference(
Tesla.Env.client(),
String.t(),
OpenXchangeClient.Model.ResolveShareReferenceElement.t(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.ResolveShareReferenceResponse.t()}
| {:error, Tesla.Env.t()}
def resolve_share_reference(connection, session, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/mail?action=resolve_share_reference")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.ResolveShareReferenceResponse{}}
])
end
@doc """
Searches for mails.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- columns (String.t): A comma-separated list of either columns or header names to return, like \"600,601,X-Custom-Header\". Each column is specified by a numeric column identifier, see [Detailed mail data](#detailed-mail-data).
- body (String.t): A JSON object describing the search term as described in [Advanced search](#advanced-search). Example: `{\"filter\":[\"and\",[\"=\", {\"field\":\"to\"},\"test1@example.com\"],[\"not\",[\"=\",{\"attachment\":\"name\"},\"document.pdf\"]]]}` which represents 'to = \"test1@example.com\" AND NOT from = \"test2@example.com\"'. Available field names are `from`, `to`, `cc`, `bcc`, `subject`, `received_date`, `sent_date`, `size`, `flags`, `content`, `content_type`, `disp`, and `priority`.
- opts (KeywordList): [optional] Optional parameters
- :headers (String.t): A comma-separated list of header names to return, like \"From,X-Custom-Header\". This parameter can be used in addition to the columns parameter.
- :unseen (boolean()): If `true` only mails without the `\\Seen` flag are returned.
- :deleted (boolean()): If `false` only mails without the `\\Deleted` flag are returned.
- :sort (String.t): The identifier of a column which determines the sort order of the response or the string “thread” to return thread-sorted messages. If this parameter is specified and holds a column number, then the parameter order must be also specified. Note: Applies only to root-level messages.
- :order (String.t): \"asc\" if the response entires should be sorted in the ascending order, \"desc\" if the response entries should be sorted in the descending order. If this parameter is specified, then the parameter sort must be also specified. Note: Applies only to root-level messages.
## Returns
{:ok, OpenXchangeClient.Model.MailsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec search_mails(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
String.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailsResponse.t()} | {:error, Tesla.Env.t()}
def search_mails(connection, session, folder, columns, body, opts \\ []) do
optional_params = %{
:headers => :query,
:unseen => :query,
:deleted => :query,
:sort => :query,
:order => :query
}
%{}
|> method(:put)
|> url("/mail?action=search")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_param(:body, :body, body)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailsResponse{}}
])
end
@doc """
Sends a mail.
The request accepts file fields in upload form that denote referenced files that are going to be appended as attachments. For \"text/plain\" mail bodies, the JSON boolean field \"raw\" may be specified inside the body's JSON representation to signal that the text content shall be kept as-is; meaning to keep all formatting intact.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- json0 (String.t): 'Contains the rudimentary mail as JSON object as described in [Detailed mail data](#detailed-mail-data) with just its message body (as html content) defined in nested JSON array `attachments` and its header data (from, to, subject, etc.). The field \\\"content_type\\\" defines whether the mail ought to be sent as plain text (\\\"text/plain\\\"), as html (\\\"text/html\\\") or as multipart/alternative (\\\"ALTERNATIVE\\\"). Sending a mail requires some special fields inside JSON mail object. The field \\\"infostore_ids\\\" defines a JSON array of infostore document ID(s) that ought to be appended to this mail as attachments. The field \\\"msgref\\\" indicates the ID of the referenced original mail. Moreover the field \\\"sendtype\\\" indicates the type of the message: <br> 0 (normal new mail),<br> 1 (a reply mail, field `msgref` must be present),<br> 2 (a forward mail, field `msgref` must be present),<br> 3 (draft edit operation, field `msgref` must be present in order to delete previous draft message since e.g. IMAP does not support changing/replacing a message but requires a delete-and-insert sequence),<br> 4 (transport of a draft mail, field `msgref` must be present),<br> 6 (signals that user intends to send out a saved draft message and expects the draft message (referenced by `msgref` field) being deleted after successful transport).'
- opts (KeywordList): [optional] Optional parameters
- :line_wrap_after (integer()): An integer value specifying the line-wrap setting (only effective for plain-text content); if absent the setting is taken from user's mail settings.
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec send_mail(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def send_mail(connection, session, json0, opts \\ []) do
optional_params = %{
:lineWrapAfter => :query
}
%{}
|> method(:post)
|> url("/mail?action=new")
|> add_param(:query, :session, session)
|> add_param(:form, :json_0, json0)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Sends or saves a mail as MIME data block ([RFC822](https://tools.ietf.org/html/rfc822)).
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :folder (String.t): In case the mail should not be sent out, but saved in a specific folder, the \"folder\" parameter can be used. If the mail should be sent out to the recipient, the \"folder\" parameter must not be included and the mail is stored in the folder \"Sent Items\".
- :flags (String.t): In case the mail should be stored with status \"read\" (e.g. mail has been read already in the client inbox), the parameter \"flags\" has to be included. If no `folder` parameter is specified, this parameter must not be included. For information about mail flags see [Mail data](#/definitions/MailData) model.
## Returns
{:ok, OpenXchangeClient.Model.MailDestinationResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec send_or_save_mail(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailDestinationResponse.t()} | {:error, Tesla.Env.t()}
def send_or_save_mail(connection, session, opts \\ []) do
optional_params = %{
:folder => :query,
:flags => :query
}
%{}
|> method(:put)
|> url("/mail?action=new")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailDestinationResponse{}}
])
end
@doc """
Updates a mail or a folder's messages and/or moves a mail to another folder.
The update request can perform an update of the color label and flags of one mail object. Beside it is possible to change the mail's folder, meaning move the mail to another folder. Both operations can be performed at once too. If neither parameter `id` nor parameter `message_id` is specified, all folder's messages are updated accordingly.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- folder (String.t): Object ID of the folder who contains the mails.
- body (MailUpdateBody): A JSON object containing the new values that ought to be applied to mail and/or the id of the destination folder (if the mail shall be moved, otherwise it must not be specified).
- opts (KeywordList): [optional] Optional parameters
- :id (String.t): Object ID of the requested mail that shall be updated (**mandatory** if a mail shall be moved).
- :message_id (String.t): The value of \"Message-Id\" header of the requested mail. This parameter is a substitute for \"id\" parameter.
## Returns
{:ok, OpenXchangeClient.Model.MailDestinationResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec update_mail(
Tesla.Env.client(),
String.t(),
String.t(),
OpenXchangeClient.Model.MailUpdateBody.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.MailDestinationResponse.t()} | {:error, Tesla.Env.t()}
def update_mail(connection, session, folder, body, opts \\ []) do
optional_params = %{
:id => :query,
:message_id => :query
}
%{}
|> method(:put)
|> url("/mail?action=update")
|> add_param(:query, :session, session)
|> add_param(:query, :folder, folder)
|> add_param(:body, :body, body)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailDestinationResponse{}}
])
end
end