Packages

mailslurp

11.7.211
15.17.22 15.17.21 15.17.17 15.17.16 15.17.15 15.17.14 15.17.13 15.17.12 15.17.11 15.17.10 15.17.9 15.17.8 15.17.7 15.17.6 15.17.5 15.17.4 15.17.3 15.17.2 15.17.1 15.17.0 15.16.22 15.16.21 15.16.20 15.16.19 15.16.18 15.16.17 15.16.16 15.16.15 15.16.14 15.16.13 15.16.12 15.16.11 15.16.10 15.16.9 15.16.8 15.16.7 15.16.6 15.16.5 15.16.4 15.16.3 15.16.2 15.16.1 15.16.0 15.15.5 15.15.4 15.15.2 15.15.1 15.14.0 15.13.32 15.13.31 15.13.30 15.13.29 15.13.28 15.13.27 15.13.26 15.13.25 15.13.24 15.13.23 15.13.22 15.13.21 15.13.20 15.13.19 15.13.18 15.13.17 15.13.16 15.13.15 15.13.14 15.13.13 15.13.11 15.13.10 15.13.9 15.13.8 15.13.7 15.13.6 15.13.5 15.13.4 15.13.3 15.13.2 15.13.1 15.13.0 15.12.17 15.12.16 15.12.15 15.12.14 15.12.13 15.12.12 15.12.11 15.12.3 15.12.2 15.12.1 15.12.0 15.11.1 15.11.0 15.9.0 15.8.1 15.8.0 15.7.17 15.7.16 15.7.15 15.7.14 15.7.13 15.7.12 15.7.10 15.7.8 15.7.7 15.7.5 15.7.4 15.7.1 15.7.0 15.6.0 15.5.6 15.5.5 15.5.4 15.5.3 15.5.2 15.5.1 15.5.0 15.4.2 15.4.1 15.4.0 15.3.1 15.3.0 15.2.8 15.2.7 15.2.6 15.2.5 15.2.4 15.2.2 15.2.1 15.2.0 15.1.4 15.1.3 15.1.2 15.1.1 15.1.0 15.0.3 15.0.2 15.0.1 15.0.0 14.0.6 14.0.5 14.0.3 14.0.2 14.0.1 14.0.0 13.1.0 13.0.1 13.0.0 12.8.4 12.8.3 12.8.2 12.8.1 12.8.0 12.7.1 12.7.0 12.6.4 12.6.3 12.6.1 12.6.0 12.5.0 12.4.8 12.4.7 12.4.6 12.4.5 12.4.4 12.4.2 12.4.1 12.4.0 12.3.333 12.3.2 12.3.1 12.3.0 12.2.2 12.2.1 12.2.0 12.1.3333 12.1.32 12.1.31 12.1.30 12.1.29 12.1.28 12.1.27 12.1.26 12.1.25 12.1.24 12.1.23 12.1.22 12.1.1 12.1.0 12.0.0 11.16666.0 11.15.0 11.14.0 11.13.0 11.12.0 11.11.1 11.11.0 11.10.3 11.10.2 11.10.1 11.10.0 11.9.7 11.9.6 11.9.4 11.9.3 11.9.2 11.9.1 11.9.0 11.8.13 11.8.12 11.8.11 11.8.10 11.8.9 11.8.8 11.8.6 11.8.5 11.8.4 11.8.3 11.8.2 11.8.1 11.8.0 11.7.509 11.7.508 11.7.506 11.7.505 11.7.502 11.7.501 11.7.500 11.7.400 11.7.314 11.7.313 11.7.312 11.7.311 11.7.310 11.7.309 11.7.308 11.7.307 11.7.306 11.7.304 11.7.302 11.7.301 11.7.300 11.7.215 11.7.214 11.7.213 11.7.212 11.7.211 11.7.210 11.7.203 11.7.202 11.7.201 11.7.200 11.7.122 11.7.11 11.7.10 11.7.9 11.7.8 11.7.7 11.7.6 11.7.5 11.7.4 11.7.2 11.7.1 11.7.0 11.6.24 11.6.23 11.6.22 11.6.21 11.6.20 11.6.19 11.6.18 11.6.16 11.6.15 11.6.14 11.6.13 11.6.12 11.6.11 11.6.10 11.6.9 11.6.8 11.6.7 11.6.6 11.6.5 11.6.4 11.6.3 11.6.2 11.6.1 11.5.2333

Elixir Email API for MailSlurp

Current section

Files

Jump to
mailslurp lib mail_slurp_api api email_controller.ex
Raw

lib/mail_slurp_api/api/email_controller.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 MailSlurpAPI.Api.EmailController do
@moduledoc """
API calls for all endpoints tagged `EmailController`.
"""
alias MailSlurpAPI.Connection
import MailSlurpAPI.RequestBuilder
@doc """
Delete all emails
Deletes all emails in your account. Be careful as emails cannot be recovered
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_all_emails(Tesla.Env.client, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_all_emails(connection, _opts \\ []) do
%{}
|> method(:delete)
|> url("/emails")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 204, false},
{ 401, false},
{ 403, false}
])
end
@doc """
Delete an email
Deletes an email and removes it from the inbox. Deleted emails cannot be recovered.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email to delete
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec delete_email(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def delete_email(connection, email_id, _opts \\ []) do
%{}
|> method(:delete)
|> url("/emails/#{email_id}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 204, false},
{ 401, false},
{ 403, false}
])
end
@doc """
Get email attachment bytes. If you have trouble with byte responses try the `downloadAttachmentBase64` response endpoints.
Returns the specified attachment for a given email as a stream / array of bytes. You can find attachment ids in email responses endpoint responses. The response type is application/octet-stream.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- attachment_id (String.t): ID of attachment
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
- :api_key (String.t): Can pass apiKey in url for this request if you wish to download the file in a browser. Content type will be set to original content type of the attachment file. This is so that browsers can download the file correctly.
## Returns
{:ok, %MailSlurpAPI.Model.binary(){}} on success
{:error, info} on failure
"""
@spec download_attachment(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t}
def download_attachment(connection, attachment_id, email_id, opts \\ []) do
optional_params = %{
:"apiKey" => :query
}
%{}
|> method(:get)
|> url("/emails/#{email_id}/attachments/#{attachment_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get email attachment as base64 encoded string (alternative to binary responses)
Returns the specified attachment for a given email as a base 64 encoded string. The response type is application/json. This method is similar to the `downloadAttachment` method but allows some clients to get around issues with binary responses.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- attachment_id (String.t): ID of attachment
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.DownloadAttachmentDto{}} on success
{:error, info} on failure
"""
@spec download_attachment_base64(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.DownloadAttachmentDto.t} | {:error, Tesla.Env.t}
def download_attachment_base64(connection, attachment_id, email_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/#{email_id}/attachments/#{attachment_id}/base64")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.DownloadAttachmentDto{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Forward email
Forward an existing email to new recipients.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email
- forward_email_options (ForwardEmailOptions): forwardEmailOptions
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %{}} on success
{:error, info} on failure
"""
@spec forward_email(Tesla.Env.client, String.t, MailSlurpAPI.Model.ForwardEmailOptions.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
def forward_email(connection, email_id, forward_email_options, _opts \\ []) do
%{}
|> method(:post)
|> url("/emails/#{email_id}/forward")
|> add_param(:body, :body, forward_email_options)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 201, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get email attachment metadata
Returns the metadata such as name and content-type for a given attachment and email.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- attachment_id (String.t): ID of attachment
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.AttachmentMetaData{}} on success
{:error, info} on failure
"""
@spec get_attachment_meta_data(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.AttachmentMetaData.t} | {:error, Tesla.Env.t}
def get_attachment_meta_data(connection, attachment_id, email_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/#{email_id}/attachments/#{attachment_id}/metadata")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.AttachmentMetaData{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get all email attachment metadata
Returns an array of attachment metadata such as name and content-type for a given email if present.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, [%AttachmentMetaData{}, ...]} on success
{:error, info} on failure
"""
@spec get_attachments(Tesla.Env.client, String.t, keyword()) :: {:ok, list(MailSlurpAPI.Model.AttachmentMetaData.t)} | {:error, Tesla.Env.t}
def get_attachments(connection, email_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/#{email_id}/attachments")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, [%MailSlurpAPI.Model.AttachmentMetaData{}]},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get email content
Returns a email summary object with headers and content. To retrieve the raw unparsed email use the getRawEmail endpoints
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): emailId
- opts (KeywordList): [optional] Optional parameters
- :decode (boolean()): Decode email body quoted-printable encoding to plain text. SMTP servers often encode text using quoted-printable format (for instance `=D7`). This can be a pain for testing
## Returns
{:ok, %MailSlurpAPI.Model.Email{}} on success
{:error, info} on failure
"""
@spec get_email(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.Email.t} | {:error, Tesla.Env.t}
def get_email(connection, email_id, opts \\ []) do
optional_params = %{
:"decode" => :query
}
%{}
|> method(:get)
|> url("/emails/#{email_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.Email{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get email content regex pattern match results. Runs regex against email body and returns match groups.
Return the matches for a given Java style regex pattern. Do not include the typical `/` at start or end of regex in some languages. Given an example `your code is: 12345` the pattern to extract match looks like `code is: (\\d{6})`. This will return an array of matches with the first matching the entire pattern and the subsequent matching the groups: `['code is: 123456', '123456']` See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html for more information of available patterns.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email to match against
- content_match_options (ContentMatchOptions): contentMatchOptions
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.EmailContentMatchResult{}} on success
{:error, info} on failure
"""
@spec get_email_content_match(Tesla.Env.client, String.t, MailSlurpAPI.Model.ContentMatchOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.EmailContentMatchResult.t} | {:error, Tesla.Env.t}
def get_email_content_match(connection, email_id, content_match_options, _opts \\ []) do
%{}
|> method(:post)
|> url("/emails/#{email_id}/contentMatch")
|> add_param(:body, :body, content_match_options)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.EmailContentMatchResult{}},
{ 201, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get email content as HTML
Retrieve email content as HTML response for viewing in browsers. Decodes quoted-printable entities and converts charset to UTF-8. Pass your API KEY as a request parameter when viewing in a browser: `?apiKey=xxx`
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): emailId
- opts (KeywordList): [optional] Optional parameters
- :decode (boolean()): decode
## Returns
{:ok, %MailSlurpAPI.Model.String.t{}} on success
{:error, info} on failure
"""
@spec get_email_html(Tesla.Env.client, String.t, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t}
def get_email_html(connection, email_id, opts \\ []) do
optional_params = %{
:"decode" => :query
}
%{}
|> method(:get)
|> url("/emails/#{email_id}/html")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Parse and return text from an email, stripping HTML and decoding encoded characters
Parse an email body and return the content as an array of text. HTML parsing uses JSoup which supports JQuery/CSS style selectors
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email to perform HTML query on
- opts (KeywordList): [optional] Optional parameters
- :html_selector (String.t): HTML selector to search for. Uses JQuery/JSoup/CSS style selector like '.my-div' to match content. See https://jsoup.org/apidocs/org/jsoup/select/Selector.html for more information.
## Returns
{:ok, %MailSlurpAPI.Model.EmailTextLinesResult{}} on success
{:error, info} on failure
"""
@spec get_email_html_query(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.EmailTextLinesResult.t} | {:error, Tesla.Env.t}
def get_email_html_query(connection, email_id, opts \\ []) do
optional_params = %{
:"htmlSelector" => :query
}
%{}
|> method(:get)
|> url("/emails/#{email_id}/htmlQuery")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.EmailTextLinesResult{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Parse and return text from an email, stripping HTML and decoding encoded characters
Parse an email body and return the content as an array of strings. HTML parsing uses JSoup and UNIX line separators.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email to fetch text for
- opts (KeywordList): [optional] Optional parameters
- :decode_html_entities (boolean()): Decode HTML entities
- :line_separator (String.t): Line separator character
## Returns
{:ok, %MailSlurpAPI.Model.EmailTextLinesResult{}} on success
{:error, info} on failure
"""
@spec get_email_text_lines(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.EmailTextLinesResult.t} | {:error, Tesla.Env.t}
def get_email_text_lines(connection, email_id, opts \\ []) do
optional_params = %{
:"decodeHtmlEntities" => :query,
:"lineSeparator" => :query
}
%{}
|> method(:get)
|> url("/emails/#{email_id}/textLines")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.EmailTextLinesResult{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get all emails
By default returns all emails across all inboxes sorted by ascending created at date. Responses are paginated. You can restrict results to a list of inbox IDs. You can also filter out read messages
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :inbox_id ([String.t]): Optional inbox ids to filter by. Can be repeated. By default will use all inboxes belonging to your account.
- :page (integer()): Optional page index in email list pagination
- :size (integer()): Optional page size in email list pagination. Maximum size is 100. Use page index and sort to page through larger results
- :sort (String.t): Optional createdAt sort direction ASC or DESC
- :unread_only (boolean()): Optional filter for unread emails only. All emails are considered unread until they are viewed in the dashboard or requested directly
## Returns
{:ok, %MailSlurpAPI.Model.PageEmailProjection{}} on success
{:error, info} on failure
"""
@spec get_emails_paginated(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.PageEmailProjection.t} | {:error, Tesla.Env.t}
def get_emails_paginated(connection, opts \\ []) do
optional_params = %{
:"inboxId" => :query,
:"page" => :query,
:"size" => :query,
:"sort" => :query,
:"unreadOnly" => :query
}
%{}
|> method(:get)
|> url("/emails")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.PageEmailProjection{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get latest email
Get the newest email in all inboxes or in a passed set of inbox IDs
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :inbox_ids ([String.t]): Optional set of inboxes to filter by. Only get the latest email from these inbox IDs
## Returns
{:ok, %MailSlurpAPI.Model.Email{}} on success
{:error, info} on failure
"""
@spec get_latest_email(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.Email.t} | {:error, Tesla.Env.t}
def get_latest_email(connection, opts \\ []) do
optional_params = %{
:"inboxIds" => :query
}
%{}
|> method(:get)
|> url("/emails/latest")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.Email{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get latest email
Get the newest email in all inboxes or in a passed set of inbox IDs
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :inbox_id (String.t): ID of the inbox you want to get the latest email from
## Returns
{:ok, %MailSlurpAPI.Model.Email{}} on success
{:error, info} on failure
"""
@spec get_latest_email_in_inbox(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.Email.t} | {:error, Tesla.Env.t}
def get_latest_email_in_inbox(connection, opts \\ []) do
optional_params = %{
:"inboxId" => :query
}
%{}
|> method(:get)
|> url("/emails/latestIn")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.Email{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get all organization emails
By default returns all emails across all team inboxes sorted by ascending created at date. Responses are paginated. You can restrict results to a list of inbox IDs. You can also filter out read messages
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :inbox_id ([String.t]): Optional inbox ids to filter by. Can be repeated. By default will use all inboxes belonging to your account.
- :page (integer()): Optional page index in email list pagination
- :size (integer()): Optional page size in email list pagination. Maximum size is 100. Use page index and sort to page through larger results
- :sort (String.t): Optional createdAt sort direction ASC or DESC
- :unread_only (boolean()): Optional filter for unread emails only. All emails are considered unread until they are viewed in the dashboard or requested directly
## Returns
{:ok, %MailSlurpAPI.Model.PageEmailProjection{}} on success
{:error, info} on failure
"""
@spec get_organization_emails_paginated(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.PageEmailProjection.t} | {:error, Tesla.Env.t}
def get_organization_emails_paginated(connection, opts \\ []) do
optional_params = %{
:"inboxId" => :query,
:"page" => :query,
:"size" => :query,
:"sort" => :query,
:"unreadOnly" => :query
}
%{}
|> method(:get)
|> url("/emails/organization")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.PageEmailProjection{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get raw email string
Returns a raw, unparsed, and unprocessed email. If your client has issues processing the response it is likely due to the response content-type which is text/plain. If you need a JSON response content-type use the getRawEmailJson endpoint
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.String.t{}} on success
{:error, info} on failure
"""
@spec get_raw_email_contents(Tesla.Env.client, String.t, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t}
def get_raw_email_contents(connection, email_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/#{email_id}/raw")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get raw email in JSON
Returns a raw, unparsed, and unprocessed email wrapped in a JSON response object for easier handling when compared with the getRawEmail text/plain response
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.RawEmailJson{}} on success
{:error, info} on failure
"""
@spec get_raw_email_json(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.RawEmailJson.t} | {:error, Tesla.Env.t}
def get_raw_email_json(connection, email_id, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/#{email_id}/raw/json")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.RawEmailJson{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Get unread email count
Get number of emails unread
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.UnreadCount{}} on success
{:error, info} on failure
"""
@spec get_unread_email_count(Tesla.Env.client, keyword()) :: {:ok, MailSlurpAPI.Model.UnreadCount.t} | {:error, Tesla.Env.t}
def get_unread_email_count(connection, _opts \\ []) do
%{}
|> method(:get)
|> url("/emails/unreadCount")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.UnreadCount{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Reply to an email
Send the reply to the email sender or reply-to and include same subject cc bcc etc. Reply to an email and the contents will be sent with the existing subject to the emails `to`, `cc`, and `bcc`.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of the email that should be replied to
- reply_to_email_options (ReplyToEmailOptions): replyToEmailOptions
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.SentEmailDto{}} on success
{:error, info} on failure
"""
@spec reply_to_email(Tesla.Env.client, String.t, MailSlurpAPI.Model.ReplyToEmailOptions.t, keyword()) :: {:ok, MailSlurpAPI.Model.SentEmailDto.t} | {:error, Tesla.Env.t}
def reply_to_email(connection, email_id, reply_to_email_options, _opts \\ []) do
%{}
|> method(:put)
|> url("/emails/#{email_id}")
|> add_param(:body, :body, reply_to_email_options)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 200, %MailSlurpAPI.Model.SentEmailDto{}},
{ 201, false},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
@doc """
Validate email
Validate the HTML content of email if HTML is found. Considered valid if no HTML.
## Parameters
- connection (MailSlurpAPI.Connection): Connection to server
- email_id (String.t): ID of email
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %MailSlurpAPI.Model.ValidationDto{}} on success
{:error, info} on failure
"""
@spec validate_email(Tesla.Env.client, String.t, keyword()) :: {:ok, MailSlurpAPI.Model.ValidationDto.t} | {:error, Tesla.Env.t}
def validate_email(connection, email_id, _opts \\ []) do
%{}
|> method(:post)
|> url("/emails/#{email_id}/validate")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> evaluate_response([
{ 201, %MailSlurpAPI.Model.ValidationDto{}},
{ 401, false},
{ 403, false},
{ 404, false}
])
end
end