# 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.ExportCustomEvents do
@moduledoc """
API calls for all endpoints tagged `ExportCustomEvents`.
"""
alias BrazeEx.Connection
import BrazeEx.RequestBuilder
@doc """
## Export Custom Events Analytics
> Use this endpoint to retrieve a series of the number of occurrences of a custom event in your app over a designated time period.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `events.data_series` 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/).
## Response
``` json
Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
{
"message": (required, string) the status of the export, returns 'success' when completed without errors,
"data" : [
{
"time" : (string) point in time - as ISO 8601 extended when unit is "hour" and as ISO 8601 date when unit is "day",
"count" : (int)
},
...
]
}
```
### Fatal error response codes
For status codes and associated error messages that will be returned if your request encounters a fatal error, reference [Fatal errors & responses](https://www.braze.com/docs/api/errors/#fatal-errors).
> **Tip:** For help with CSV and API exports, visit [Export troubleshooting](https://www.braze.com/docs/user_guide/data_and_analytics/export_braze_data/export_troubleshooting/).
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:Authorization` (String.t):
- `:event` (String.t): (Required) String The name of the custom event for which to return analytics.
- `:length` (integer()): (Required) Integer Maximum number of units (days or hours) before `ending_at` to include in the returned series. Must be between 1 and 100 (inclusive).
- `:unit` (String.t): (Optional) String Unit of time between data points - can be `day` or `hour`, defaults to `day`.
- `:ending_at` (String.t): (Optional) Datetime ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) string) Date on which the data series should end. Defaults to time of the request.
- `:app_id` (String.t): (Optional) String App API identifier retrieved from the [API Keys](https://www.braze.com/docs/user_guide/administrative/app_settings/api_settings_tab/) page to limit analytics to a specific app. Note: If you are using our [older navigation](https://www.braze.com/docs/navigation), `app_id` can be found at **Developer Console** > **API Settings**
- `:segment_id` (String.t): (Optional) String See [Segment API identifier](https://www.braze.com/docs/api/identifier_types/). Segment ID indicating the analytics-enabled segment for which event analytics should be returned.
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec events_data_series_get(Tesla.Env.client(), keyword()) ::
{:ok, nil} | {:error, Tesla.Env.t()}
def events_data_series_get(connection, opts \\ []) do
optional_params = %{
:Authorization => :headers,
:event => :query,
:length => :query,
:unit => :query,
:ending_at => :query,
:app_id => :query,
:segment_id => :query
}
request =
%{}
|> method(:get)
|> url("/events/data_series")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
@doc """
## Export Custom Events List
> Use this endpoint to export a list of custom events that have been recorded for your app. The event names are returned in groups of 250, sorted alphabetically.
## Prerequisites
To use this endpoint, you’ll need an [API key](https://braze.com/docs/api/api_key/) with the `events.list` permission.
## Rate limit
For customers who onboarded with Braze on or after September 16, 2021, we apply a shared rate limit of 1,000 requests per hour to this endpoint. This rate limit is shared with the `/purchases/product_list` endpoint, as documented in [API rate limits](https://www.braze.com/docs/api/api_limits/).
## Response
``` json
Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
{
"message": (required, string) the status of the export, returns 'success' when completed without errors,
"events" : [
"Event A", (string) the event name,
"Event B", (string) the event name,
"Event C", (string) the event name,
...
]
}
```
### Fatal error response codes
For status codes and associated error messages that will be returned if your request encounters a fatal error, reference [Fatal errors & responses](https://www.braze.com/docs/api/errors/#fatal-errors).
> **Tip:** For help with CSV and API exports, visit [Export troubleshooting](https://www.braze.com/docs/user_guide/data_and_analytics/export_braze_data/export_troubleshooting/).
### Parameters
- `connection` (BrazeEx.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:Authorization` (String.t):
- `:page` (integer()): (Optional) Integer The page of event names to return, defaults to 0 (returns the first set of up to 250).
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec events_list_get(Tesla.Env.client(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t()}
def events_list_get(connection, opts \\ []) do
optional_params = %{
:Authorization => :headers,
:page => :query
}
request =
%{}
|> method(:get)
|> url("/events/list")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, false}
])
end
end