# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). # https://openapi-generator.tech # Do not edit the class manually. defmodule MailSlurpAPI.Api.AttachmentController do @moduledoc """ API calls for all endpoints tagged `AttachmentController`. """ alias MailSlurpAPI.Connection import MailSlurpAPI.RequestBuilder @doc """ Upload an attachment for sending using base64 file encoding. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. ## Parameters - connection (MailSlurpAPI.Connection): Connection to server - upload_options (UploadAttachmentOptions): uploadOptions - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, [%String{}, ...]} on success {:error, info} on failure """ @spec upload_attachment(Tesla.Env.client, MailSlurpAPI.Model.UploadAttachmentOptions.t, keyword()) :: {:ok, list(String.t)} | {:error, Tesla.Env.t} def upload_attachment(connection, upload_options, _opts \\ []) do %{} |> method(:post) |> url("/attachments") |> add_param(:body, :body, upload_options) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, []}, { 401, false}, { 403, false}, { 404, false} ]) end @doc """ Upload an attachment for sending using file byte stream input octet stream. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. ## Parameters - connection (MailSlurpAPI.Connection): Connection to server - opts (KeywordList): [optional] Optional parameters - :string (String.t): Optional contentType for file. For instance `application/pdf` - :filename (String.t): Optional filename to save upload with - :byte_array (binary()): Byte array request body ## Returns {:ok, [%String{}, ...]} on success {:error, info} on failure """ @spec upload_attachment_bytes(Tesla.Env.client, keyword()) :: {:ok, list(String.t)} | {:error, Tesla.Env.t} def upload_attachment_bytes(connection, opts \\ []) do optional_params = %{ :"String" => :query, :"filename" => :query, :"byteArray" => :body } %{} |> method(:post) |> url("/attachments/bytes") |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, []}, { 401, false}, { 403, false}, { 404, false} ]) end @doc """ Upload an attachment for sending using a Multipart Form request. Returns an array whose first element is the ID of the uploaded attachment. Email attachments are essentially files with meta data. Files are byte arrays and the meta data is a content type and a filename. These properties allow email clients to display the filename and icon etc. When sending emails with attachments first upload each attachment with an upload endpoint. Record the returned attachment ID and use it with subsequent email sending. For legacy reasons the ID is returned as the first element in an array. Only a single ID is ever returned. To send the attachments pass a list of attachment IDs with `SendEmailOptions` when sending an email. Using the upload endpoints prior to sending mean attachments can easily be reused. ## Parameters - connection (MailSlurpAPI.Connection): Connection to server - file (String.t): file - opts (KeywordList): [optional] Optional parameters - :content_type (String.t): Optional content type of attachment - :filename (String.t): Optional name of file - :x_filename (String.t): Optional content type header of attachment ## Returns {:ok, [%String{}, ...]} on success {:error, info} on failure """ @spec upload_multipart_form(Tesla.Env.client, String.t, keyword()) :: {:ok, list(String.t)} | {:error, Tesla.Env.t} def upload_multipart_form(connection, file, opts \\ []) do optional_params = %{ :"contentType" => :query, :"filename" => :query, :"x-filename" => :query } %{} |> method(:post) |> url("/attachments/multipart") |> add_param(:file, :"file", file) |> add_optional_params(optional_params, opts) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> evaluate_response([ { 201, []}, { 401, false}, { 403, false}, { 404, false} ]) end end