Current section
Files
Jump to
Current section
Files
lib/open_xchange_client/api/attachments.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.Attachments do
@moduledoc """
API calls for all endpoints tagged `Attachments`.
"""
alias OpenXchangeClient.Connection
import OpenXchangeClient.RequestBuilder
@doc """
Creates an attachment.
#### Note It is possible to create multiple attachments at once. Therefor add additional form fields and replace \"[index]\" in `json_[index]` and `file_[index]` with the appropriate index, like `json_1`, `file_1`. The index always starts with 0 (mandatory attachment object).
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- json0 (String.t): A JSON string representing an attachment object as described in [AttachmentData](#/definitions/AttachmentData) model with at least the fields `folder`, `attached` and `module`.
- file0 (String.t): The attachment file as per `<input type=\\\"file\\\" />`.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec create_attachment(Tesla.Env.client(), String.t(), String.t(), String.t(), keyword()) ::
{:ok, String.t()} | {:error, Tesla.Env.t()}
def create_attachment(connection, session, json0, file0, _opts \\ []) do
%{}
|> method(:post)
|> url("/attachment?action=attach")
|> add_param(:query, :session, session)
|> add_param(:form, :json_0, json0)
|> add_param(:file, :file_0, file0)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Deletes attachments.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- body ([String.t]): A JSON array with the identifiers of the attachments that shall be deleted.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.CommonResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec delete_attachments(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
integer(),
list(String.t()),
keyword()
) :: {:ok, OpenXchangeClient.Model.CommonResponse.t()} | {:error, Tesla.Env.t()}
def delete_attachments(connection, session, attached, folder, module, body, _opts \\ []) do
%{}
|> method(:put)
|> url("/attachment?action=detach")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.CommonResponse{}}
])
end
@doc """
Gets all attachments for an object.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- columns (String.t): A comma-separated list of columns to return, like \"1,800\". Each column is specified by a numeric column identifier, see [Common object data](#common-object-data) and [Attachment data](#attachment-object).
- opts (KeywordList): [optional] Optional parameters
- :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.
## Returns
{:ok, OpenXchangeClient.Model.AttachmentsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_all_attachments(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
integer(),
String.t(),
keyword()
) :: {:ok, OpenXchangeClient.Model.AttachmentsResponse.t()} | {:error, Tesla.Env.t()}
def get_all_attachments(connection, session, attached, folder, module, columns, opts \\ []) do
optional_params = %{
:sort => :query,
:order => :query
}
%{}
|> method(:get)
|> url("/attachment?action=all")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> add_param(:query, :columns, columns)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.AttachmentsResponse{}}
])
end
@doc """
Gets an attachment.
## 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 infoitem.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.AttachmentResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachment(
Tesla.Env.client(),
String.t(),
String.t(),
integer(),
integer(),
integer(),
keyword()
) :: {:ok, OpenXchangeClient.Model.AttachmentResponse.t()} | {:error, Tesla.Env.t()}
def get_attachment(connection, session, id, attached, folder, module, _opts \\ []) do
%{}
|> method(:get)
|> url("/attachment?action=get")
|> add_param(:query, :session, session)
|> add_param(:query, :id, id)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.AttachmentResponse{}}
])
end
@doc """
Gets an attachment's document/filedata.
It is possible to add a filename to the request's URI like `/attachment/{filename}?action=document`. The filename may be added to the customary attachment path to suggest a filename to a Save-As dialog.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- id (String.t): Object ID of the requested attachment.
- opts (KeywordList): [optional] Optional parameters
- :content_type (String.t): If present the response declares the given `content_type` in the Content-Type header and not the attachments file MIME type.
- :scan (boolean()): Flag to request an Anti-Virus scan for the specified attachment before downloading it.
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachment_document(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
integer(),
String.t(),
keyword()
) :: {:ok, String.t()} | {:error, Tesla.Env.t()}
def get_attachment_document(connection, session, attached, folder, module, id, opts \\ []) do
optional_params = %{
:content_type => :query,
:scan => :query
}
%{}
|> method(:get)
|> url("/attachment?action=document")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> add_param(:query, :id, id)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
@doc """
Gets a list of attachments.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- columns (String.t): A comma-separated list of columns to return, like \"1,800\". Each column is specified by a numeric column identifier, see [Common object data](#common-object-data) and [Attachment data](#attachment-object).
- body ([integer()]): A JSON array with the identifiers of the requested attachments.
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, OpenXchangeClient.Model.InfoItemsResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachment_list(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
integer(),
String.t(),
list(Integer.t()),
keyword()
) :: {:ok, OpenXchangeClient.Model.InfoItemsResponse.t()} | {:error, Tesla.Env.t()}
def get_attachment_list(
connection,
session,
attached,
folder,
module,
columns,
body,
_opts \\ []
) do
%{}
|> method(:put)
|> url("/attachment?action=list")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> add_param(:query, :columns, columns)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.InfoItemsResponse{}}
])
end
@doc """
Gets the new and deleted attachments.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- columns (String.t): A comma-separated list of columns to return, like \"1,800\". Each column is specified by a numeric column identifier, see [Common object data](#common-object-data) and [Attachment data](#attachment-object).
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- opts (KeywordList): [optional] Optional parameters
- :timestamp (integer()): Timestamp of the last update of the requested infoitems.
- :ignore (String.t): Which kinds of updates should be ignored. Currently, the only valid value – \"deleted\" – causes deleted object IDs not to be 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.
## Returns
{:ok, OpenXchangeClient.Model.AttachmentUpdatesResponse.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_attachment_updates(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
String.t(),
integer(),
keyword()
) ::
{:ok, OpenXchangeClient.Model.AttachmentUpdatesResponse.t()} | {:error, Tesla.Env.t()}
def get_attachment_updates(connection, session, attached, folder, columns, module, opts \\ []) do
optional_params = %{
:timestamp => :query,
:ignore => :query,
:sort => :query,
:order => :query
}
%{}
|> method(:get)
|> url("/attachment?action=updates")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :columns, columns)
|> add_param(:query, :module, module)
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, %OpenXchangeClient.Model.AttachmentUpdatesResponse{}}
])
end
@doc """
Gets a ZIP archive for multipe attachment data.
## Parameters
- connection (OpenXchangeClient.Connection): Connection to server
- session (String.t): A session ID previously obtained from the login module.
- attached (integer()): The ID of the object to which the attachment belongs.
- folder (integer()): The folder ID of the object.
- module (integer()): The module type of the object: 1 (appointment), 4 (task), 7 (contact), 137 (infostore).
- body ([integer()]): A JSON array with the identifiers of the attachments, which shall be put into ZIP archive
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, String.t} on success
{:error, Tesla.Env.t} on failure
"""
@spec get_zipped_attachment_documents(
Tesla.Env.client(),
String.t(),
integer(),
integer(),
integer(),
list(Integer.t()),
keyword()
) :: {:ok, String.t()} | {:error, Tesla.Env.t()}
def get_zipped_attachment_documents(
connection,
session,
attached,
folder,
module,
body,
_opts \\ []
) do
%{}
|> method(:put)
|> url("/attachment?action=zipDocuments")
|> add_param(:query, :session, session)
|> add_param(:query, :attached, attached)
|> add_param(:query, :folder, folder)
|> add_param(:query, :module, module)
|> add_param(:body, :body, body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{200, false}
])
end
end