# 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.MailCompose do
@moduledoc """
API calls for all endpoints tagged `MailCompose`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Delete an existing attachment.
## 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 composition space
- attachment_id (String.t): The ID of the attachment
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.InlineResponse2002.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_attachments_by_id(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
keyword()
) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.InlineResponse2002.t()}
| {:error, Tesla.Env.t()}
def delete_attachments_by_id(connection, session, id, attachment_id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/mail/compose/#{id}/attachments/#{attachment_id}")
|> add_param(:query, :session, session)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.InlineResponse2002{}},
{400, false},
{401, false}
])
end
@doc """
Deletes the composition space under the given identifier
## 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 composition space
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.InlineResponse2001.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_mail_compose_by_id(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.InlineResponse2001.t()}
| {:error, Tesla.Env.t()}
def delete_mail_compose_by_id(connection, session, id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/mail/compose/#{id}")
|> add_param(:query, :session, session)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.InlineResponse2001{}},
{400, false},
{401, false}
])
end
@doc """
Get binary attachment. This URL pattern can be used for inline images.
## 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 composition space
- attachment_id (String.t): The ID of the attachment
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachments_by_id(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, nil} | {:ok, String.t()} | {:error, Tesla.Env.t()}
def get_attachments_by_id(connection, session, id, attachment_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/mail/compose/#{id}/attachments/#{attachment_id}")
|> add_param(:query, :session, session)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false},
{400, false},
{401, false}
])
end
@doc """
Get all open spaces
Returns a JSON array of compositions spaces
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :columns (String.t): A comma-separated list of columns to return. Each column is specified by the name of the Composition Space attribute. If no columns are specified only the \"id\" column is set.
## Returns
{:ok, OpenXchangeClient.Model.MailComposeGetResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_compose(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeGetResponse.t()}
| {:error, Tesla.Env.t()}
def get_mail_compose(connection, session, opts \\ []) do
optional_params = %{
:columns => :query
}
%{}
|> method(:get)
|> url("/mail/compose")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeGetResponse{}},
{400, false},
{401, false}
])
end
@doc """
Load the composition space under the given identifier
## 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 composition space
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_mail_compose_by_id(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeResponse.t()}
| {:error, Tesla.Env.t()}
def get_mail_compose_by_id(connection, session, id, _opts \\ []) do
%{}
|> method(:get)
|> url("/mail/compose/#{id}")
|> add_param(:query, :session, session)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeResponse{}},
{400, false},
{401, false}
])
end
@doc """
Save as draft. Space gets deleted.
## 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 composition space
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeSendResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_save(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeSendResponse.t()}
| {:error, Tesla.Env.t()}
def get_save(connection, session, id, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/save")
|> add_param(:query, :session, session)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeSendResponse{}},
{400, false},
{401, false}
])
end
@doc """
Updates the composition space
Payload is JSON that reflects changes. Response is the current composition space message model after update.
## 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 composition space
- body (MailComposeMessageModel): An object containing the attributes to update
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec patch_mail_compose_by_id(
Tesla.Env.client(),
String.t(),
String.t(),
OpenXchangeClient.Model.MailComposeMessageModel.t(),
keyword()
) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeResponse.t()}
| {:error, Tesla.Env.t()}
def patch_mail_compose_by_id(connection, session, id, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/mail/compose/#{id}")
|> add_param(:query, :session, session)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeResponse{}},
{400, false},
{401, false}
])
end
@doc """
Add new attachment.
## 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 composition space
- file (String.t): The file to add
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_attachments(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t()}
| {:error, Tesla.Env.t()}
def post_attachments(connection, session, id, file, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/attachments")
|> add_param(:query, :session, session)
|> add_param(:file, :file, file)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeAttachmentResponse{}},
{400, false},
{401, false}
])
end
@doc """
Uploads an attachment again and removes the old attachment from the server. Used for image resize.
## 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 composition space
- attachment_id (String.t): The ID of the attachment
- file (String.t): The file to add
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_attachments_by_id(
Tesla.Env.client(),
String.t(),
String.t(),
String.t(),
String.t(),
keyword()
) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t()}
| {:error, Tesla.Env.t()}
def post_attachments_by_id(connection, session, id, attachment_id, file, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/attachments/#{attachment_id}")
|> add_param(:query, :session, session)
|> add_param(:file, :file, file)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeAttachmentResponse{}},
{400, false},
{401, false}
])
end
@doc """
Add all original attachments (useful for replies).
## 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 composition space
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeAttachmentPostResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_attachments_original(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, OpenXchangeClient.Model.MailComposeAttachmentPostResponse.t()}
| {:ok, nil}
| {:error, Tesla.Env.t()}
def post_attachments_original(connection, session, id, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/attachments/original")
|> add_param(:query, :session, session)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeAttachmentPostResponse{}},
{400, false},
{401, false}
])
end
@doc """
Attach vcard later on.
## 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 composition space
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_attachments_vcard(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeAttachmentResponse.t()}
| {:error, Tesla.Env.t()}
def post_attachments_vcard(connection, session, id, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/attachments/vcard")
|> add_param(:query, :session, session)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeAttachmentResponse{}},
{400, false},
{401, false}
])
end
@doc """
Create a new composition space
For any types but \"new\", the response provides ready-to-use values, e.g. to, cc, bcc, subject with prefix, attachments. Internally all mime headers are set properly (a..g to maintain threads). Only the content is still original, i.e. the client uses DOMPurify to sanitize and to quote the content.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- opts (KeywordList): [optional] Optional parameters
- :type (String.t): One of new/reply/replyall/forward/resend/edit/copy
- :vcard (boolean()): Attach users vcard
- :body ([OpenXchangeClient.Model.InlineObject.t]): Array of Objects (id, folderId) to reference mails (reply or multiple on forward as example)
## Returns
{:ok, OpenXchangeClient.Model.MailComposeResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_mail_compose(Tesla.Env.client(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeResponse.t()}
| {:error, Tesla.Env.t()}
def post_mail_compose(connection, session, opts \\ []) do
optional_params = %{
:type => :query,
:vcard => :query,
:body => :body
}
%{}
|> method(:post)
|> url("/mail/compose")
|> add_param(:query, :session, session)
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeResponse{}},
{400, false},
{401, false}
])
end
@doc """
Send message. Space gets deleted. Optionally deletes draft if referenced.
## 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 composition space
- j_son (String.t): Represents the request body as JSON string containing the [MailMessageModel](#/definitions/MailComposeMessageModel).
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.MailComposeSendResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec post_mail_compose_send(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, nil}
| {:ok, OpenXchangeClient.Model.MailComposeSendResponse.t()}
| {:error, Tesla.Env.t()}
def post_mail_compose_send(connection, session, id, j_son, _opts \\ []) do
%{}
|> method(:post)
|> url("/mail/compose/#{id}/send")
|> add_param(:query, :session, session)
|> add_param(:form, :JSON, j_son)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.MailComposeSendResponse{}},
{400, false},
{401, false}
])
end
end