ElasticEmail 4.2.0

Official Rust SDK for the Elastic Email REST API v4
Documentation
/*
 * Elastic Email REST API
 *
 * This API is based on the REST API architecture, allowing the user to easily manage their data with this resource-based approach.    Every API call is established on which specific request type (GET, POST, PUT, DELETE) will be used.    The API has a limit of 20 concurrent connections and a hard timeout of 600 seconds per request.    To start using this API, you will need your Access Token (available <a target='_blank' href='https://app.elasticemail.com/marketing/settings/new/manage-api'>here</a>). Remember to keep it safe. Required access levels are listed in the given request’s description.    Downloadable library clients can be found in our Github repository <a target='_blank' href='https://github.com/ElasticEmail?tab=repositories&q=%22rest+api%22+in%3Areadme'>here</a>
 *
 * The version of the OpenAPI document: 4.0.0
 * Contact: support@elasticemail.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// ApiKeyPayload : Create a new ApiKey
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ApiKeyPayload {
    /// Name of the ApiKey for ease of reference.
    #[serde(rename = "Name")]
    pub name: String,
    /// Access level or permission to be assigned to this ApiKey.
    #[serde(rename = "AccessLevel")]
    pub access_level: Vec<models::AccessLevel>,
    /// Date this ApiKey expires.
    #[serde(rename = "Expires", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub expires: Option<Option<String>>,
    /// Which IPs can use this ApiKey
    #[serde(rename = "RestrictAccessToIPRange", skip_serializing_if = "Option::is_none")]
    pub restrict_access_to_ip_range: Option<Vec<String>>,
    /// Email of the subaccount for which this ApiKey should be created
    #[serde(rename = "Subaccount", skip_serializing_if = "Option::is_none")]
    pub subaccount: Option<String>,
}

impl ApiKeyPayload {
    /// Create a new ApiKey
    pub fn new(name: String, access_level: Vec<models::AccessLevel>) -> ApiKeyPayload {
        ApiKeyPayload {
            name,
            access_level,
            expires: None,
            restrict_access_to_ip_range: None,
            subaccount: None,
        }
    }
}