# NOTE: This file is auto generated by OpenAPI Generator 6.2.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule BrazeEx.Api.EmailListsAddresses do
@moduledoc """
API calls for all endpoints tagged `EmailListsAddresses`.
"""
alias BrazeEx.Connection
import BrazeEx.RequestBuilder
@doc """
## Blacklist Email Addresses
> Use this endpoint to unsubscribe a user from email and mark them as hard bounced.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.blacklist` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Request parameters
| Parameter | Required | Data Type | Description |
| --- | --- | --- | --- |
| `email` | Required | String or array | String email address to blacklist, or an array of up to 50 email addresses to blocklist. |
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:"Content-Type"` (String.t):
- `:Authorization` (String.t):
- `:body` (String.t):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_blacklist_post(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_blacklist_post(connection, opts \\ []) do
optional_params = %{
:"Content-Type" => :headers,
:Authorization => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/email/blacklist")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Blocklist Email Addresses
> Use this endpoint to unsubscribe a user from email and mark them as hard bounced.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.blacklist` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Request parameters
| Parameter | Required | Data Type | Description |
| --- | --- | --- | --- |
| `email` | Required | String or array | String email address to blacklist, or an array of up to 50 email addresses to blocklist. |
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:"Content-Type"` (String.t):
- `:Authorization` (String.t):
- `:body` (String.t):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_blocklist_post(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_blocklist_post(connection, opts \\ []) do
optional_params = %{
:"Content-Type" => :headers,
:Authorization => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/email/blocklist")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Remove Hard Bounced Emails
> Use this endpoint to remove email addresses from your Braze bounce list and bounce list maintained by your email provider.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.bounce.remove` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Request parameters
| Parameter | Required | Data Type | Description |
| --- | --- | --- | --- |
| `email` | Required | String or array | String email address to modify, or an array of up to 50 email addresses to modify. |
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:"Content-Type"` (String.t):
- `:Authorization` (String.t):
- `:body` (String.t):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_bounce_remove_post(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_bounce_remove_post(connection, opts \\ []) do
optional_params = %{
:"Content-Type" => :headers,
:Authorization => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/email/bounce/remove")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Query Hard Bounced Emails
> Use this endpoint to pull a list of email addresses that have “hard bounced” your email messages within a certain time frame.
> **Note:** You must provide an `end_date`, as well as either an `email` or a `start_date`. If you provide all three, `start_date`, `end_date`, and an `email`, we prioritize the emails given and disregard the date range.
If your date range has more than `limit` number of hard bounces, you will need to make multiple API calls, each time increasing the `offset` until a call returns either fewer than `limit` or zero results.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.hard_bounces` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Example request
```
curl --location --request GET 'https://rest.iad-01.braze.com/email/hard_bounces?start_date=2019-01-01&end_date=2019-02-01&limit=100&offset=1&email=example@braze.com' \
--header 'Authorization: Bearer YOUR-API-KEY-HERE'
```
## Response
Entries are listed in descending order.
``` json
Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
{
"emails": [
{
"email": "example1@braze.com",
"hard_bounced_at": "2016-08-25 15:24:32 +0000"
},
{
"email": "example2@braze.com",
"hard_bounced_at": "2016-08-24 17:41:58 +0000"
},
{
"email": "example3@braze.com",
"hard_bounced_at": "2016-08-24 12:01:13 +0000"
}
],
"message": "success"
}
```
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:Authorization` (String.t):
- `:start_date` (String.t): (Optional*) String in YYYY-MM-DD format Start date of the range to retrieve hard bounces, must be earlier than `end_date`. This is treated as midnight in UTC time by the API. *You must provide either an `email` or a `start_date`, and an `end_date`.
- `:end_date` (String.t): (Optional*) String in YYYY-MM-DD format String in YYYY-MM-DD format. End date of the range to retrieve hard bounces. This is treated as midnight in UTC time by the API. *You must provide either an `email` or a `start_date`, and an `end_date`.
- `:limit` (integer()): (Optional) Integer Optional field to limit the number of results returned. Defaults to 100, maximum is 500.
- `:offset` (integer()): (Optional) Integer Optional beginning point in the list to retrieve from.
- `:email` (String.t): (Optional*) String If provided, we will return whether or not the user has hard bounced. *You must provide either an `email` or a `start_date`, and an `end_date`.
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_hard_bounces_get(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_hard_bounces_get(connection, opts \\ []) do
optional_params = %{
:Authorization => :headers,
:start_date => :query,
:end_date => :query,
:limit => :query,
:offset => :query,
:email => :query
}
request =
%{}
|> method(:get)
|> url("/email/hard_bounces")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Remove Email Addresses from Spam List
> Use this endpoint to remove email addresses from your Braze spam list and spam list maintained by your email provider.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.spam.remove` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Request parameters
| Parameter | Required | Data Type | Description |
| --- | --- | --- | --- |
| `email` | Required | String or array | String email address to modify, or an array of up to 50 email addresses to modify. |
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:"Content-Type"` (String.t):
- `:Authorization` (String.t):
- `:body` (String.t):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_spam_remove_post(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_spam_remove_post(connection, opts \\ []) do
optional_params = %{
:"Content-Type" => :headers,
:Authorization => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/email/spam/remove")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Change Email Subscription Status
> Use this endpoint to set the email subscription state for your users. Users can be `opted_in`, `unsubscribed`, or `subscribed` (not specifically opted in or out).
You can set the email subscription state for an email address that is not yet associated with any of your users within Braze. When that email address is subsequently associated with a user, the email subscription state that you uploaded will be automatically set.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.status` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Request parameters
| Parameter | Required | Data Type | Description |
| --- | --- | --- | --- |
| `email` | Required | String or array | String email address to modify, or an array of up to 50 email addresses to modify. |
| `subscription_state` | Required | String | Either “subscribed”, “unsubscribed”, or “opted_in”. |
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:"Content-Type"` (String.t):
- `:Authorization` (String.t):
- `:body` (String.t):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_status_post(Tesla.Env.client(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()}
def email_status_post(connection, opts \\ []) do
optional_params = %{
:"Content-Type" => :headers,
:Authorization => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/email/status")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Query List of Unsubscribed Email Addresses
> Use this endpoint to return emails that have unsubscribed during the time period from `start_date` to `end_date`.
You can use this endpoint to set up a bi-directional sync between Braze and other email systems or your own database.
> **Note:** You must provide an `end_date`, as well as either an `email` or a `start_date`.
If your date range has more than `limit` number of unsubscribes, you will need to make multiple API calls, each time increasing the `offset` until a call returns either fewer than `limit` or zero results.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `email.unsubscribe` permission.
## Rate limit
We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Example request
```
curl --location --request GET 'https://rest.iad-01.braze.com/email/unsubscribes?start_date=2020-01-01&end_date=2020-02-01&limit=1&offset=1&sort_direction=desc&email=example@braze.com' \
--header 'Authorization: Bearer YOUR-API-KEY-HERE'
```
## Response
Entries are listed in descending order.
``` json
Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
{
"emails": [
{
"email": "example1@braze.com",
"unsubscribed_at": "2016-08-25 15:24:32 +0000"
},
{
"email": "example2@braze.com",
"unsubscribed_at": "2016-08-24 17:41:58 +0000"
},
{
"email": "example3@braze.com",
"unsubscribed_at": "2016-08-24 12:01:13 +0000"
}
],
"message": "success"
}
```
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:Authorization` (String.t):
- `:start_date` (String.t): (Optional*) String in YYYY-MM-DD format Start date of the range to retrieve unsubscribes, must be earlier than end_date. This is treated as midnight in UTC time by the API.
- `:end_date` (String.t): (Optional*) String in YYYY-MM-DD format End date of the range to retrieve unsubscribes. This is treated as midnight in UTC time by the API.
- `:limit` (integer()): (Optional) Integer Optional field to limit the number of results returned. Limit must be greater than 1. Defaults to 100, maximum is 500.
- `:offset` (integer()): (Optional) Integer Optional beginning point in the list to retrieve from.
- `:sort_direction` (String.t): (Optional) String Pass in the value `asc` to sort unsubscribes from oldest to newest. Pass in `desc` to sort from newest to oldest. If sort_direction is not included, the default order is newest to oldest.
- `:email` (String.t): (Optional*) String If provided, we will return whether or not the user has unsubscribed.
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec email_unsubscribes_get(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def email_unsubscribes_get(connection, opts \\ []) do
optional_params = %{
:Authorization => :headers,
:start_date => :query,
:end_date => :query,
:limit => :query,
:offset => :query,
:sort_direction => :query,
:email => :query
}
request =
%{}
|> method(:get)
|> url("/email/unsubscribes")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
end