/*
 * Svix API
 *
 * Welcome to the Svix API documentation!  Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/)  # Introduction  This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com).  ## Main concepts  In Svix you have four important entities you will be interacting with:  - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each user on your platform. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint.   ## Authentication  Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`.  <SecurityDefinitions />   ## Code samples  The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/).   ## Idempotency  Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response.  To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions.  Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result.  Please note that idempotency is only supported for `POST` requests.   ## Cross-Origin Resource Sharing  This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site. 
 *
 * The version of the OpenAPI document: 1.4
 * 
 * Generated by: https://openapi-generator.tech
 */


use reqwest;

use crate::apis::ResponseContent;
use super::{Error, configuration};

/// struct for passing parameters to the method `create_endpoint_api_v1_app_app_id_endpoint_post`
#[derive(Clone, Debug)]
pub struct CreateEndpointApiV1AppAppIdEndpointPostParams {
    pub app_id: String,
    pub endpoint_in: crate::models::EndpointIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `delete_endpoint_api_v1_app_app_id_endpoint_endpoint_id_delete`
#[derive(Clone, Debug)]
pub struct DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `get_endpoint_api_v1_app_app_id_endpoint_endpoint_id_get`
#[derive(Clone, Debug)]
pub struct GetEndpointApiV1AppAppIdEndpointEndpointIdGetParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `get_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_get`
#[derive(Clone, Debug)]
pub struct GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `get_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_get`
#[derive(Clone, Debug)]
pub struct GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `get_endpoint_stats_api_v1_app_app_id_endpoint_endpoint_id_stats_get`
#[derive(Clone, Debug)]
pub struct GetEndpointStatsApiV1AppAppIdEndpointEndpointIdStatsGetParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `get_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_get`
#[derive(Clone, Debug)]
pub struct GetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationGetParams {
    pub endpoint_id: String,
    pub app_id: String,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `list_endpoints_api_v1_app_app_id_endpoint_get`
#[derive(Clone, Debug)]
pub struct ListEndpointsApiV1AppAppIdEndpointGetParams {
    pub app_id: String,
    pub iterator: Option<String>,
    pub limit: Option<i32>,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `patch_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_patch`
#[derive(Clone, Debug)]
pub struct PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchParams {
    pub app_id: String,
    pub endpoint_id: String,
    pub endpoint_headers_patch_in: crate::models::EndpointHeadersPatchIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `recover_failed_webhooks_api_v1_app_app_id_endpoint_endpoint_id_recover_post`
#[derive(Clone, Debug)]
pub struct RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostParams {
    pub app_id: String,
    pub endpoint_id: String,
    pub recover_in: crate::models::RecoverIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `rotate_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_rotate_post`
#[derive(Clone, Debug)]
pub struct RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostParams {
    pub endpoint_id: String,
    pub app_id: String,
    pub endpoint_secret_rotate_in: crate::models::EndpointSecretRotateIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `send_event_type_example_message_api_v1_app_app_id_endpoint_endpoint_id_send_example_post`
#[derive(Clone, Debug)]
pub struct SendEventTypeExampleMessageApiV1AppAppIdEndpointEndpointIdSendExamplePostParams {
    pub app_id: String,
    pub endpoint_id: String,
    pub event_example_in: crate::models::EventExampleIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `set_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_patch`
#[derive(Clone, Debug)]
pub struct SetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationPatchParams {
    pub app_id: String,
    pub endpoint_id: String,
    pub endpoint_transformation_in: crate::models::EndpointTransformationIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `simulate_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_simulate_post`
#[derive(Clone, Debug)]
pub struct SimulateEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationSimulatePostParams {
    pub endpoint_id: String,
    pub app_id: String,
    pub endpoint_transformation_simulate_in: crate::models::EndpointTransformationSimulateIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `update_endpoint_api_v1_app_app_id_endpoint_endpoint_id_put`
#[derive(Clone, Debug)]
pub struct UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutParams {
    pub endpoint_id: String,
    pub app_id: String,
    pub endpoint_update: crate::models::EndpointUpdate,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}

/// struct for passing parameters to the method `update_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_put`
#[derive(Clone, Debug)]
pub struct UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutParams {
    pub app_id: String,
    pub endpoint_id: String,
    pub endpoint_headers_in: crate::models::EndpointHeadersIn,
    /// The request's idempotency key
    pub idempotency_key: Option<String>
}


/// struct for typed errors of method `create_endpoint_api_v1_app_app_id_endpoint_post`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateEndpointApiV1AppAppIdEndpointPostError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `delete_endpoint_api_v1_app_app_id_endpoint_endpoint_id_delete`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `get_endpoint_api_v1_app_app_id_endpoint_endpoint_id_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEndpointApiV1AppAppIdEndpointEndpointIdGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `get_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `get_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `get_endpoint_stats_api_v1_app_app_id_endpoint_endpoint_id_stats_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEndpointStatsApiV1AppAppIdEndpointEndpointIdStatsGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `get_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `list_endpoints_api_v1_app_app_id_endpoint_get`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListEndpointsApiV1AppAppIdEndpointGetError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `patch_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_patch`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `recover_failed_webhooks_api_v1_app_app_id_endpoint_endpoint_id_recover_post`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `rotate_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_rotate_post`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostError {
    Status400(crate::models::HttpErrorOut),
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `send_event_type_example_message_api_v1_app_app_id_endpoint_endpoint_id_send_example_post`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SendEventTypeExampleMessageApiV1AppAppIdEndpointEndpointIdSendExamplePostError {
    Status400(crate::models::HttpErrorOut),
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `set_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_patch`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationPatchError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `simulate_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_simulate_post`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SimulateEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationSimulatePostError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `update_endpoint_api_v1_app_app_id_endpoint_endpoint_id_put`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method `update_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_put`
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutError {
    Status401(crate::models::HttpErrorOut),
    Status403(crate::models::HttpErrorOut),
    Status404(crate::models::HttpErrorOut),
    Status409(crate::models::HttpErrorOut),
    Status422(crate::models::HttpValidationError),
    Status429(crate::models::HttpErrorOut),
    UnknownValue(serde_json::Value),
}


/// Create a new endpoint for the application.  When `secret` is `null` the secret is automatically generated (recommended)
pub async fn create_endpoint_api_v1_app_app_id_endpoint_post(configuration: &configuration::Configuration, params: CreateEndpointApiV1AppAppIdEndpointPostParams) -> Result<crate::models::EndpointOut, Error<CreateEndpointApiV1AppAppIdEndpointPostError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_in = params.endpoint_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/", configuration.base_path, app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<CreateEndpointApiV1AppAppIdEndpointPostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Delete an endpoint.
pub async fn delete_endpoint_api_v1_app_app_id_endpoint_endpoint_id_delete(configuration: &configuration::Configuration, params: DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteParams) -> Result<(), Error<DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Get an application.
pub async fn get_endpoint_api_v1_app_app_id_endpoint_endpoint_id_get(configuration: &configuration::Configuration, params: GetEndpointApiV1AppAppIdEndpointEndpointIdGetParams) -> Result<crate::models::EndpointOut, Error<GetEndpointApiV1AppAppIdEndpointEndpointIdGetError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetEndpointApiV1AppAppIdEndpointEndpointIdGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Get the additional headers to be sent with the webhook
pub async fn get_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_get(configuration: &configuration::Configuration, params: GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetParams) -> Result<crate::models::EndpointHeadersOut, Error<GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/headers/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Get the endpoint's signing secret.  This is used to verify the authenticity of the webhook. For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/).
pub async fn get_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_get(configuration: &configuration::Configuration, params: GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetParams) -> Result<crate::models::EndpointSecretOut, Error<GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/secret/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Get basic statistics for the endpoint.
pub async fn get_endpoint_stats_api_v1_app_app_id_endpoint_endpoint_id_stats_get(configuration: &configuration::Configuration, params: GetEndpointStatsApiV1AppAppIdEndpointEndpointIdStatsGetParams) -> Result<crate::models::EndpointStats, Error<GetEndpointStatsApiV1AppAppIdEndpointEndpointIdStatsGetError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/stats/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetEndpointStatsApiV1AppAppIdEndpointEndpointIdStatsGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Get the transformation code associated with this endpoint
pub async fn get_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_get(configuration: &configuration::Configuration, params: GetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationGetParams) -> Result<crate::models::EndpointTransformationOut, Error<GetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationGetError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/transformation/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// List the application's endpoints.
pub async fn list_endpoints_api_v1_app_app_id_endpoint_get(configuration: &configuration::Configuration, params: ListEndpointsApiV1AppAppIdEndpointGetParams) -> Result<crate::models::ListResponseEndpointOut, Error<ListEndpointsApiV1AppAppIdEndpointGetError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let iterator = params.iterator;
    let limit = params.limit;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/", configuration.base_path, app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = iterator {
        local_var_req_builder = local_var_req_builder.query(&[("iterator", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = limit {
        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<ListEndpointsApiV1AppAppIdEndpointGetError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Partially set the additional headers to be sent with the webhook
pub async fn patch_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_patch(configuration: &configuration::Configuration, params: PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchParams) -> Result<(), Error<PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_id = params.endpoint_id;
    let endpoint_headers_patch_in = params.endpoint_headers_patch_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/headers/", configuration.base_path, app_id=crate::apis::urlencode(app_id), endpoint_id=crate::apis::urlencode(endpoint_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_headers_patch_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Resend all failed messages since a given time.
pub async fn recover_failed_webhooks_api_v1_app_app_id_endpoint_endpoint_id_recover_post(configuration: &configuration::Configuration, params: RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostParams) -> Result<serde_json::Value, Error<RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_id = params.endpoint_id;
    let recover_in = params.recover_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/recover/", configuration.base_path, app_id=crate::apis::urlencode(app_id), endpoint_id=crate::apis::urlencode(endpoint_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&recover_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Rotates the endpoint's signing secret.  The previous secret will be valid for the next 24 hours.
pub async fn rotate_endpoint_secret_api_v1_app_app_id_endpoint_endpoint_id_secret_rotate_post(configuration: &configuration::Configuration, params: RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostParams) -> Result<(), Error<RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let endpoint_secret_rotate_in = params.endpoint_secret_rotate_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/secret/rotate/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_secret_rotate_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Send an example message for event
pub async fn send_event_type_example_message_api_v1_app_app_id_endpoint_endpoint_id_send_example_post(configuration: &configuration::Configuration, params: SendEventTypeExampleMessageApiV1AppAppIdEndpointEndpointIdSendExamplePostParams) -> Result<crate::models::MessageOut, Error<SendEventTypeExampleMessageApiV1AppAppIdEndpointEndpointIdSendExamplePostError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_id = params.endpoint_id;
    let event_example_in = params.event_example_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/send-example/", configuration.base_path, app_id=crate::apis::urlencode(app_id), endpoint_id=crate::apis::urlencode(endpoint_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&event_example_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SendEventTypeExampleMessageApiV1AppAppIdEndpointEndpointIdSendExamplePostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Set or unset the transformation code associated with this endpoint
pub async fn set_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_patch(configuration: &configuration::Configuration, params: SetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationPatchParams) -> Result<(), Error<SetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationPatchError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_id = params.endpoint_id;
    let endpoint_transformation_in = params.endpoint_transformation_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/transformation/", configuration.base_path, app_id=crate::apis::urlencode(app_id), endpoint_id=crate::apis::urlencode(endpoint_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_transformation_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<SetEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationPatchError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Simulate running the transformation on the payload and code
pub async fn simulate_endpoint_transformation_api_v1_app_app_id_endpoint_endpoint_id_transformation_simulate_post(configuration: &configuration::Configuration, params: SimulateEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationSimulatePostParams) -> Result<crate::models::EndpointTransformationSimulateOut, Error<SimulateEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationSimulatePostError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let endpoint_transformation_simulate_in = params.endpoint_transformation_simulate_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/transformation/simulate/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_transformation_simulate_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<SimulateEndpointTransformationApiV1AppAppIdEndpointEndpointIdTransformationSimulatePostError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Update an endpoint.
pub async fn update_endpoint_api_v1_app_app_id_endpoint_endpoint_id_put(configuration: &configuration::Configuration, params: UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutParams) -> Result<crate::models::EndpointOut, Error<UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutError>> {
    // unbox the parameters
    let endpoint_id = params.endpoint_id;
    let app_id = params.app_id;
    let endpoint_update = params.endpoint_update;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/", configuration.base_path, endpoint_id=crate::apis::urlencode(endpoint_id), app_id=crate::apis::urlencode(app_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_update);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        serde_json::from_str(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

/// Set the additional headers to be sent with the webhook
pub async fn update_endpoint_headers_api_v1_app_app_id_endpoint_endpoint_id_headers_put(configuration: &configuration::Configuration, params: UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutParams) -> Result<(), Error<UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutError>> {
    // unbox the parameters
    let app_id = params.app_id;
    let endpoint_id = params.endpoint_id;
    let endpoint_headers_in = params.endpoint_headers_in;
    let idempotency_key = params.idempotency_key;


    let local_var_client = &configuration.client;

    let local_var_uri_str = format!("{}/api/v1/app/{app_id}/endpoint/{endpoint_id}/headers/", configuration.base_path, app_id=crate::apis::urlencode(app_id), endpoint_id=crate::apis::urlencode(endpoint_id));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(local_var_param_value) = idempotency_key {
        local_var_req_builder = local_var_req_builder.header("idempotency-key", local_var_param_value.to_string());
    }
    if let Some(ref local_var_token) = configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&endpoint_headers_in);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutError> = serde_json::from_str(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

