// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

use crate::consumer::attribute::Attributes;
use crate::consumer::device_history::DeviceInfo;
use crate::consumer::users::User;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AmazonOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AppleOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// AuthenticationFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthenticationFactor {
    /// type_: The type of authentication factor. The possible values are: `email_otp`, `impersonated`,
    /// `imported`,
    ///    `magic_link`, `oauth`, `otp`, `password`, `recovery_codes`, `sso`, `trusted_auth_token`, or `totp`.
    #[serde(rename = "type")]
    pub type_: AuthenticationFactorType,
    /// delivery_method: The method that was used to deliver the authentication factor. The possible values
    /// depend on the `type`:
    ///
    ///   `email_otp` – Only `email`.
    ///
    ///   `impersonated` – Only `impersonation`.
    ///
    ///   `imported` – Only `imported_auth0`.
    ///
    ///   `magic_link` – Only `email`.
    ///
    ///   `oauth` – The delivery method is determined by the specific OAuth provider used. The possible values
    /// are `oauth_google`, `oauth_microsoft`, `oauth_hubspot`, `oauth_slack`, or `oauth_github`.
    ///
    /// In addition, you may see an 'exchange' delivery method when a non-email-verifying OAuth factor
    /// originally authenticated in one organization is exchanged for a factor in another organization.
    /// This can happen during authentication flows such as
    /// [session exchange](https://stytch.com/docs/b2b/api/exchange-session).
    /// The non-email-verifying OAuth providers are Hubspot, Slack, and Github.
    /// Google is also considered non-email-verifying when the HD claim is empty.
    /// The possible exchange values are `oauth_exchange_google`, `oauth_exchange_hubspot`,
    /// `oauth_exchange_slack`, or `oauth_exchange_github`.
    ///
    /// The final possible value is `oauth_access_token_exchange`, if this factor came from an
    /// [access token exchange flow](https://stytch.com/docs/b2b/api/connected-app-access-token-exchange).
    ///
    ///   `otp` –  Only `sms`.
    ///
    ///   `password` – Only `knowledge`.
    ///
    ///   `recovery_codes` – Only `recovery_code`.
    ///
    ///   `sso` – Either `sso_saml` or `sso_oidc`.
    ///
    ///   `trusted_auth_token` – Only `trusted_token_exchange`.
    ///
    ///   `totp` – Only `authenticator_app`.
    ///
    pub delivery_method: AuthenticationFactorDeliveryMethod,
    /// last_authenticated_at: The timestamp when the factor was last authenticated.
    pub last_authenticated_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// created_at: The timestamp when the factor was initially authenticated.
    pub created_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// updated_at: The timestamp when the factor was last updated.
    pub updated_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// email_factor: Information about the email factor, if one is present.
    pub email_factor: std::option::Option<EmailFactor>,
    /// phone_number_factor: Information about the phone number factor, if one is present.
    pub phone_number_factor: std::option::Option<PhoneNumberFactor>,
    /// google_oauth_factor: Information about the Google OAuth factor, if one is present.
    pub google_oauth_factor: std::option::Option<GoogleOAuthFactor>,
    /// microsoft_oauth_factor: Information about the Microsoft OAuth factor, if one is present.
    pub microsoft_oauth_factor: std::option::Option<MicrosoftOAuthFactor>,
    pub apple_oauth_factor: std::option::Option<AppleOAuthFactor>,
    pub webauthn_factor: std::option::Option<WebAuthnFactor>,
    /// authenticator_app_factor: Information about the TOTP-backed Authenticator App factor, if one is present.
    pub authenticator_app_factor: std::option::Option<AuthenticatorAppFactor>,
    /// github_oauth_factor: Information about the Github OAuth factor, if one is present.
    pub github_oauth_factor: std::option::Option<GithubOAuthFactor>,
    pub recovery_code_factor: std::option::Option<RecoveryCodeFactor>,
    pub facebook_oauth_factor: std::option::Option<FacebookOAuthFactor>,
    pub crypto_wallet_factor: std::option::Option<CryptoWalletFactor>,
    pub amazon_oauth_factor: std::option::Option<AmazonOAuthFactor>,
    pub bitbucket_oauth_factor: std::option::Option<BitbucketOAuthFactor>,
    pub coinbase_oauth_factor: std::option::Option<CoinbaseOAuthFactor>,
    pub discord_oauth_factor: std::option::Option<DiscordOAuthFactor>,
    pub figma_oauth_factor: std::option::Option<FigmaOAuthFactor>,
    pub git_lab_oauth_factor: std::option::Option<GitLabOAuthFactor>,
    pub instagram_oauth_factor: std::option::Option<InstagramOAuthFactor>,
    pub linked_in_oauth_factor: std::option::Option<LinkedInOAuthFactor>,
    pub shopify_oauth_factor: std::option::Option<ShopifyOAuthFactor>,
    /// slack_oauth_factor: Information about the Slack OAuth factor, if one is present.
    pub slack_oauth_factor: std::option::Option<SlackOAuthFactor>,
    pub snapchat_oauth_factor: std::option::Option<SnapchatOAuthFactor>,
    pub spotify_oauth_factor: std::option::Option<SpotifyOAuthFactor>,
    pub steam_oauth_factor: std::option::Option<SteamOAuthFactor>,
    pub tik_tok_oauth_factor: std::option::Option<TikTokOAuthFactor>,
    pub twitch_oauth_factor: std::option::Option<TwitchOAuthFactor>,
    pub twitter_oauth_factor: std::option::Option<TwitterOAuthFactor>,
    pub embeddable_magic_link_factor: std::option::Option<EmbeddableMagicLinkFactor>,
    pub biometric_factor: std::option::Option<BiometricFactor>,
    /// saml_sso_factor: Information about the SAML SSO factor, if one is present.
    pub saml_sso_factor: std::option::Option<SAMLSSOFactor>,
    /// oidc_sso_factor: Information about the OIDC SSO factor, if one is present.
    pub oidc_sso_factor: std::option::Option<OIDCSSOFactor>,
    pub salesforce_oauth_factor: std::option::Option<SalesforceOAuthFactor>,
    pub yahoo_oauth_factor: std::option::Option<YahooOAuthFactor>,
    /// hubspot_oauth_factor: Information about the Hubspot OAuth factor, if one is present.
    pub hubspot_oauth_factor: std::option::Option<HubspotOAuthFactor>,
    /// slack_oauth_exchange_factor: Information about the Slack OAuth Exchange factor, if one is present.
    pub slack_oauth_exchange_factor: std::option::Option<SlackOAuthExchangeFactor>,
    /// hubspot_oauth_exchange_factor: Information about the Hubspot OAuth Exchange factor, if one is present.
    pub hubspot_oauth_exchange_factor: std::option::Option<HubspotOAuthExchangeFactor>,
    /// github_oauth_exchange_factor: Information about the Github OAuth Exchange factor, if one is present.
    pub github_oauth_exchange_factor: std::option::Option<GithubOAuthExchangeFactor>,
    /// google_oauth_exchange_factor: Information about the Google OAuth Exchange factor, if one is present.
    pub google_oauth_exchange_factor: std::option::Option<GoogleOAuthExchangeFactor>,
    /// impersonated_factor: Information about the impersonated factor, if one is present.
    pub impersonated_factor: std::option::Option<ImpersonatedFactor>,
    /// oauth_access_token_exchange_factor: Information about the access token exchange factor, if one is
    /// present.
    pub oauth_access_token_exchange_factor: std::option::Option<OAuthAccessTokenExchangeFactor>,
    /// trusted_auth_token_factor: Information about the trusted auth token factor, if one is present.
    pub trusted_auth_token_factor: std::option::Option<TrustedAuthTokenFactor>,
}
/// AuthenticatorAppFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthenticatorAppFactor {
    /// totp_id: Globally unique UUID that identifies a TOTP instance.
    pub totp_id: String,
}
/// AuthorizationCheck:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthorizationCheck {
    /// resource_id: A unique identifier of the RBAC Resource, provided by the developer and intended to be
    /// human-readable.
    ///
    ///   A `resource_id` is not allowed to start with `stytch`, which is a special prefix used for Stytch
    /// default Resources with reserved `resource_id`s.
    ///
    pub resource_id: String,
    /// action: An action to take on a Resource.
    pub action: String,
}
/// AuthorizationVerdict:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthorizationVerdict {
    /// authorized: Whether the User was authorized to perform the specified action on the specified Resource.
    /// Always true if the request succeeds.
    pub authorized: bool,
    /// granting_roles: The complete list of Roles that gave the User permission to perform the specified action
    /// on the specified Resource.
    pub granting_roles: std::vec::Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BiometricFactor {
    pub biometric_registration_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BitbucketOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CoinbaseOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CryptoWalletFactor {
    pub crypto_wallet_id: String,
    pub crypto_wallet_address: String,
    pub crypto_wallet_type: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DiscordOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// EmailFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EmailFactor {
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: String,
    /// email_address: The email address of the Member.
    pub email_address: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EmbeddableMagicLinkFactor {
    pub embedded_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FacebookOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FigmaOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GitLabOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// GithubOAuthExchangeFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GithubOAuthExchangeFactor {
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: String,
}
/// GithubOAuthFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GithubOAuthFactor {
    /// id: The unique ID of an OAuth registration.
    pub id: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: std::option::Option<String>,
}
/// GoogleOAuthExchangeFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GoogleOAuthExchangeFactor {
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: String,
}
/// GoogleOAuthFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GoogleOAuthFactor {
    /// id: The unique ID of an OAuth registration.
    pub id: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: std::option::Option<String>,
}
/// HubspotOAuthExchangeFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct HubspotOAuthExchangeFactor {
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: String,
}
/// HubspotOAuthFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct HubspotOAuthFactor {
    /// id: The unique ID of an OAuth registration.
    pub id: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: std::option::Option<String>,
}
/// ImpersonatedFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ImpersonatedFactor {
    /// impersonator_id: For impersonated sessions initiated via the Stytch Dashboard, the `impersonator_id`
    /// will be the impersonator's Stytch Dashboard `member_id`.
    pub impersonator_id: String,
    /// impersonator_email_address: The email address of the impersonator.
    pub impersonator_email_address: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct InstagramOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[allow(non_snake_case)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct JWK {
    pub kty: String,
    #[serde(rename = "use")]
    pub use_: String,
    pub key_ops: std::vec::Vec<String>,
    pub alg: String,
    pub kid: String,
    pub x5c: std::vec::Vec<String>,
    pub x5tS256: String,
    pub n: String,
    pub e: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LinkedInOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// MicrosoftOAuthFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MicrosoftOAuthFactor {
    /// id: The unique ID of an OAuth registration.
    pub id: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: std::option::Option<String>,
}
/// OAuthAccessTokenExchangeFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OAuthAccessTokenExchangeFactor {
    /// client_id: The ID of the Connected App client.
    pub client_id: String,
}
/// OIDCSSOFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OIDCSSOFactor {
    /// id: The unique ID of an SSO Registration.
    pub id: String,
    /// provider_id: Globally unique UUID that identifies a specific OIDC Connection.
    pub provider_id: String,
    /// external_id: The ID of the member given by the identity provider.
    pub external_id: String,
}
/// PhoneNumberFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PhoneNumberFactor {
    /// phone_id: The globally unique UUID of the Member's phone number.
    pub phone_id: String,
    /// phone_number: The phone number of the Member.
    pub phone_number: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RecoveryCodeFactor {
    pub totp_recovery_code_id: String,
}
/// SAMLSSOFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SAMLSSOFactor {
    /// id: The unique ID of an SSO Registration.
    pub id: String,
    /// provider_id: Globally unique UUID that identifies a specific SAML Connection.
    pub provider_id: String,
    /// external_id: The ID of the member given by the identity provider.
    pub external_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SalesforceOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// Session:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Session {
    /// session_id: A unique identifier for a specific Session.
    pub session_id: String,
    /// user_id: The unique ID of the affected User.
    pub user_id: String,
    /// authentication_factors: An array of different authentication factors that comprise a Session.
    pub authentication_factors: std::vec::Vec<AuthenticationFactor>,
    /// started_at: The timestamp when the Session was created. Values conform to the RFC 3339 standard and are
    /// expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub started_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// last_accessed_at: The timestamp when the Session was last accessed. Values conform to the RFC 3339
    /// standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub last_accessed_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// expires_at: The timestamp when the Session expires. Values conform to the RFC 3339 standard and are
    /// expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub expires_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
    /// attributes: Provided attributes help with fraud detection.
    pub attributes: std::option::Option<Attributes>,
    /// custom_claims: The custom claims map for a Session. Claims can be added to a session during a Sessions
    /// authenticate call.
    pub custom_claims: std::option::Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ShopifyOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// SlackOAuthExchangeFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SlackOAuthExchangeFactor {
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: String,
}
/// SlackOAuthFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SlackOAuthFactor {
    /// id: The unique ID of an OAuth registration.
    pub id: String,
    /// provider_subject: The unique identifier for the User within a given OAuth provider. Also commonly called
    /// the `sub` or "Subject field" in OAuth protocols.
    pub provider_subject: String,
    /// email_id: The globally unique UUID of the Member's email.
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SnapchatOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SpotifyOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SteamOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TikTokOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// TrustedAuthTokenFactor:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TrustedAuthTokenFactor {
    /// token_id: The ID of the trusted auth token.
    pub token_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TwitchOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TwitterOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct WebAuthnFactor {
    pub webauthn_registration_id: String,
    pub domain: String,
    pub user_agent: std::option::Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct YahooOAuthFactor {
    pub id: String,
    pub provider_subject: String,
    pub email_id: std::option::Option<String>,
}
/// AttestRequest: Request type for `Sessions.attest`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct AttestRequest {
    /// profile_id: The ID of the trusted auth token profile to use for attestation.
    pub profile_id: String,
    /// token: The trusted auth token to authenticate.
    pub token: String,
    /// session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a
    /// new session if one doesn't already exist,
    ///   returning both an opaque `session_token` and `session_jwt` for this session. Remember that the
    /// `session_jwt` will have a fixed lifetime of
    ///   five minutes regardless of the underlying session duration, and will need to be refreshed over time.
    ///
    ///   This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
    ///
    ///   If a `session_token` or `session_jwt` is provided then a successful authentication will continue to
    /// extend the session this many minutes.
    ///
    ///   If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
    pub session_duration_minutes: std::option::Option<i32>,
    /// session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only
    /// created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be
    /// included on the Session object and in the JWT. To update a key in an existing Session, supply a new
    /// value. To delete a key, supply a null value.
    ///
    ///   Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be
    /// ignored. Total custom claims size cannot exceed four kilobytes.
    pub session_custom_claims: std::option::Option<serde_json::Value>,
    /// session_token: The `session_token` for the session that you wish to add the trusted auth token
    /// authentication factor to.
    pub session_token: std::option::Option<String>,
    /// session_jwt: The `session_jwt` for the session that you wish to add the trusted auth token
    /// authentication factor to.
    pub session_jwt: std::option::Option<String>,
    /// telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated
    /// fingerprints and IPGEO information for the User. Your workspace must be enabled for Device
    /// Fingerprinting to use this feature.
    pub telemetry_id: std::option::Option<String>,
}
/// AttestResponse: Response type for `Sessions.attest`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AttestResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// user_id: The unique ID of the affected User.
    pub user_id: String,
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: String,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    pub session_jwt: String,
    /// user: The `user` object affected by this API call. See the
    /// [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
    pub user: User,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    /// session: If you initiate a Session, by including `session_duration_minutes` in your authenticate call,
    /// you'll receive a full Session object in the response.
    ///
    ///   See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.
    ///
    pub session: std::option::Option<Session>,
    /// user_device: If a valid `telemetry_id` was passed in the request and the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) returned results, the
    /// `user_device` response field will contain information about the user's device attributes.
    pub user_device: std::option::Option<DeviceInfo>,
}
/// AuthenticateRequest: Request type for `Sessions.authenticate`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct AuthenticateRequest {
    /// session_token: The session token to authenticate.
    pub session_token: std::option::Option<String>,
    /// session_duration_minutes: Set the session lifetime to be this many minutes from now; minimum of 5 and a
    /// maximum of 527040 minutes (366 days). Note that a successful authentication will continue to extend the
    /// session this many minutes.
    pub session_duration_minutes: std::option::Option<i32>,
    /// session_jwt: The JWT to authenticate. You may provide a JWT that has expired according to its `exp`
    /// claim and needs to be refreshed. If the signature is valid and the underlying session is still active
    /// then Stytch will return a new JWT.
    pub session_jwt: std::option::Option<String>,
    /// session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only
    /// created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be
    /// included on the Session object and in the JWT. To update a key in an existing Session, supply a new
    /// value. To delete a key, supply a null value.
    ///
    ///   Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be
    /// ignored. Total custom claims size cannot exceed four kilobytes.
    pub session_custom_claims: std::option::Option<serde_json::Value>,
    /// authorization_check: If an `authorization_check` object is passed in, this endpoint will also check if
    /// the User is
    ///   authorized to perform the given action on the given Resource. A User is authorized if they are
    /// assigned a Role with adequate permissions.
    ///
    ///   If the User is not authorized to perform the specified action on the specified Resource, a 403 error
    /// will be thrown.
    ///   Otherwise, the response will contain a list of Roles that satisfied the authorization check.
    pub authorization_check: std::option::Option<AuthorizationCheck>,
}
/// AuthenticateResponse: Response type for `Sessions.authenticate`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthenticateResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// session: If you initiate a Session, by including `session_duration_minutes` in your authenticate call,
    /// you'll receive a full Session object in the response.
    ///
    ///   See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.
    ///
    pub session: Session,
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: String,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    pub session_jwt: String,
    /// user: The `user` object affected by this API call. See the
    /// [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
    pub user: User,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    /// verdict: If an `authorization_check` is provided in the request and the check succeeds, this field will
    /// return
    ///   information about why the User was granted permission.
    pub verdict: std::option::Option<AuthorizationVerdict>,
}
/// ExchangeAccessTokenRequest: Request type for `Sessions.exchange_access_token`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct ExchangeAccessTokenRequest {
    /// access_token: The access token to exchange for a Stytch Session. Must be granted the `full_access` scope.
    pub access_token: String,
    /// session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a
    /// new session if one doesn't already exist,
    ///   returning both an opaque `session_token` and `session_jwt` for this session. Remember that the
    /// `session_jwt` will have a fixed lifetime of
    ///   five minutes regardless of the underlying session duration, and will need to be refreshed over time.
    ///
    ///   This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
    ///
    ///   If a `session_token` or `session_jwt` is provided then a successful authentication will continue to
    /// extend the session this many minutes.
    ///
    ///   If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
    pub session_duration_minutes: std::option::Option<i32>,
    /// session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only
    /// created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be
    /// included on the Session object and in the JWT. To update a key in an existing Session, supply a new
    /// value. To delete a key, supply a null value.
    ///
    ///   Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be
    /// ignored. Total custom claims size cannot exceed four kilobytes.
    pub session_custom_claims: std::option::Option<serde_json::Value>,
    /// telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated
    /// fingerprints and IPGEO information for the User. Your workspace must be enabled for Device
    /// Fingerprinting to use this feature.
    pub telemetry_id: std::option::Option<String>,
}
/// ExchangeAccessTokenResponse: Response type for `Sessions.exchange_access_token`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ExchangeAccessTokenResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// user_id: The unique ID of the affected User.
    pub user_id: String,
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: String,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    pub session_jwt: String,
    /// user: The `user` object affected by this API call. See the
    /// [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
    pub user: User,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    /// session: If you initiate a Session, by including `session_duration_minutes` in your authenticate call,
    /// you'll receive a full Session object in the response.
    ///
    ///   See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.
    ///
    pub session: std::option::Option<Session>,
    /// user_device: If a valid `telemetry_id` was passed in the request and the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) returned results, the
    /// `user_device` response field will contain information about the user's device attributes.
    pub user_device: std::option::Option<DeviceInfo>,
}
/// GetJWKSRequest: Request type for `Sessions.get_jwks`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct GetJWKSRequest {
    /// project_id: The `project_id` to get the JWKS for.
    pub project_id: String,
}
/// GetJWKSResponse: Response type for `Sessions.get_jwks`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetJWKSResponse {
    /// keys: The list of JWKs associated with the project.
    pub keys: std::vec::Vec<JWK>,
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// GetRequest: Request type for `Sessions.get`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct GetRequest {
    /// user_id: The `user_id` to get active Sessions for. You may use an `external_id` here if one is set for
    /// the user.
    pub user_id: String,
}
/// GetResponse: Response type for `Sessions.get`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// sessions: An array of [Session objects](https://stytch.com/docs/api/session-object).
    pub sessions: std::vec::Vec<Session>,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}
/// MigrateRequest: Request type for `Sessions.migrate`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MigrateRequest {
    /// session_token: The authorization token Stytch will pass in to the external userinfo endpoint.
    pub session_token: String,
    /// session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a
    /// new session if one doesn't already exist,
    ///   returning both an opaque `session_token` and `session_jwt` for this session. Remember that the
    /// `session_jwt` will have a fixed lifetime of
    ///   five minutes regardless of the underlying session duration, and will need to be refreshed over time.
    ///
    ///   This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
    ///
    ///   If a `session_token` or `session_jwt` is provided then a successful authentication will continue to
    /// extend the session this many minutes.
    ///
    ///   If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
    pub session_duration_minutes: std::option::Option<i32>,
    /// session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only
    /// created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be
    /// included on the Session object and in the JWT. To update a key in an existing Session, supply a new
    /// value. To delete a key, supply a null value.
    ///
    ///   Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be
    /// ignored. Total custom claims size cannot exceed four kilobytes.
    pub session_custom_claims: std::option::Option<serde_json::Value>,
    /// telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated
    /// fingerprints and IPGEO information for the User. Your workspace must be enabled for Device
    /// Fingerprinting to use this feature.
    pub telemetry_id: std::option::Option<String>,
}
/// MigrateResponse: Response type for `Sessions.migrate`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MigrateResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// user_id: The unique ID of the affected User.
    pub user_id: String,
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: String,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    pub session_jwt: String,
    /// user: The `user` object affected by this API call. See the
    /// [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
    pub user: User,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    /// session: If you initiate a Session, by including `session_duration_minutes` in your authenticate call,
    /// you'll receive a full Session object in the response.
    ///
    ///   See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.
    ///
    pub session: std::option::Option<Session>,
    /// user_device: If a valid `telemetry_id` was passed in the request and the
    /// [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) returned results, the
    /// `user_device` response field will contain information about the user's device attributes.
    pub user_device: std::option::Option<DeviceInfo>,
}
/// RevokeRequest: Request type for `Sessions.revoke`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct RevokeRequest {
    /// session_id: The `session_id` to revoke.
    pub session_id: std::option::Option<String>,
    /// session_token: The session token to revoke.
    pub session_token: std::option::Option<String>,
    /// session_jwt: A JWT for the session to revoke.
    pub session_jwt: std::option::Option<String>,
}
/// RevokeResponse: Response type for `Sessions.revoke`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RevokeResponse {
    /// request_id: Globally unique UUID that is returned with every API call. This value is important to log
    /// for debugging purposes; we may ask for this value to help identify a specific API call when helping you
    /// debug an issue.
    pub request_id: String,
    /// status_code: The HTTP status code of the response. Stytch follows standard HTTP response status code
    /// patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX
    /// are server errors.
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum AuthenticationFactorDeliveryMethod {
    #[serde(rename = "email")]
    #[default]
    Email,
    #[serde(rename = "sms")]
    Sms,
    #[serde(rename = "whatsapp")]
    Whatsapp,
    #[serde(rename = "embedded")]
    Embedded,
    #[serde(rename = "oauth_google")]
    OAuthGoogle,
    #[serde(rename = "oauth_microsoft")]
    OAuthMicrosoft,
    #[serde(rename = "oauth_apple")]
    OAuthApple,
    #[serde(rename = "webauthn_registration")]
    WebAuthnRegistration,
    #[serde(rename = "authenticator_app")]
    AuthenticatorApp,
    #[serde(rename = "oauth_github")]
    OAuthGithub,
    #[serde(rename = "recovery_code")]
    RecoveryCode,
    #[serde(rename = "oauth_facebook")]
    OAuthFacebook,
    #[serde(rename = "crypto_wallet")]
    CryptoWallet,
    #[serde(rename = "oauth_amazon")]
    OAuthAmazon,
    #[serde(rename = "oauth_bitbucket")]
    OAuthBitbucket,
    #[serde(rename = "oauth_coinbase")]
    OAuthCoinbase,
    #[serde(rename = "oauth_discord")]
    OAuthDiscord,
    #[serde(rename = "oauth_figma")]
    OAuthFigma,
    #[serde(rename = "oauth_gitlab")]
    OAuthGitlab,
    #[serde(rename = "oauth_instagram")]
    OAuthInstagram,
    #[serde(rename = "oauth_linkedin")]
    OAuthLinkedin,
    #[serde(rename = "oauth_shopify")]
    OAuthShopify,
    #[serde(rename = "oauth_slack")]
    OAuthSlack,
    #[serde(rename = "oauth_snapchat")]
    OAuthSnapchat,
    #[serde(rename = "oauth_spotify")]
    OAuthSpotify,
    #[serde(rename = "oauth_steam")]
    OAuthSteam,
    #[serde(rename = "oauth_tiktok")]
    OAuthTiktok,
    #[serde(rename = "oauth_twitch")]
    OAuthTwitch,
    #[serde(rename = "oauth_twitter")]
    OAuthTwitter,
    #[serde(rename = "knowledge")]
    Knowledge,
    #[serde(rename = "biometric")]
    Biometric,
    #[serde(rename = "sso_saml")]
    SSOSAML,
    #[serde(rename = "sso_oidc")]
    SSOOIDC,
    #[serde(rename = "oauth_salesforce")]
    OAuthSalesforce,
    #[serde(rename = "oauth_yahoo")]
    OAuthYahoo,
    #[serde(rename = "oauth_hubspot")]
    OAuthHubspot,
    #[serde(rename = "imported_auth0")]
    ImportedAuth0,
    #[serde(rename = "oauth_exchange_slack")]
    OAuthExchangeSlack,
    #[serde(rename = "oauth_exchange_hubspot")]
    OAuthExchangeHubspot,
    #[serde(rename = "oauth_exchange_github")]
    OAuthExchangeGithub,
    #[serde(rename = "oauth_exchange_google")]
    OAuthExchangeGoogle,
    #[serde(rename = "impersonation")]
    Impersonation,
    #[serde(rename = "oauth_access_token_exchange")]
    OAuthAccessTokenExchange,
    #[serde(rename = "trusted_token_exchange")]
    TrustedTokenExchange,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum AuthenticationFactorType {
    #[serde(rename = "magic_link")]
    #[default]
    MagicLink,
    #[serde(rename = "otp")]
    OTP,
    #[serde(rename = "oauth")]
    OAuth,
    #[serde(rename = "webauthn")]
    WebAuthn,
    #[serde(rename = "totp")]
    TOTP,
    #[serde(rename = "crypto")]
    Crypto,
    #[serde(rename = "password")]
    Password,
    #[serde(rename = "signature_challenge")]
    SignatureChallenge,
    #[serde(rename = "sso")]
    SSO,
    #[serde(rename = "imported")]
    Imported,
    #[serde(rename = "recovery_codes")]
    RecoveryCodes,
    #[serde(rename = "email_otp")]
    EmailOTP,
    #[serde(rename = "impersonated")]
    Impersonated,
    #[serde(rename = "trusted_auth_token")]
    TrustedAuthToken,
}

pub struct Sessions {
    http_client: crate::client::Client,
}

impl Sessions {
    pub fn new(http_client: crate::client::Client) -> Self {
        Self {
            http_client: http_client.clone(),
        }
    }

    pub async fn get(&self, body: GetRequest) -> crate::Result<GetResponse> {
        let path = String::from("/v1/sessions");
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body,
            })
            .await
    }
    pub async fn authenticate(
        &self,
        body: AuthenticateRequest,
    ) -> crate::Result<AuthenticateResponse> {
        let path = String::from("/v1/sessions/authenticate");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn revoke(&self, body: RevokeRequest) -> crate::Result<RevokeResponse> {
        let path = String::from("/v1/sessions/revoke");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn migrate(&self, body: MigrateRequest) -> crate::Result<MigrateResponse> {
        let path = String::from("/v1/sessions/migrate");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn exchange_access_token(
        &self,
        body: ExchangeAccessTokenRequest,
    ) -> crate::Result<ExchangeAccessTokenResponse> {
        let path = String::from("/v1/sessions/exchange_access_token");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn get_jwks(&self, body: GetJWKSRequest) -> crate::Result<GetJWKSResponse> {
        let project_id = &body.project_id;
        let path = format!("/v1/sessions/jwks/{project_id}");
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body,
            })
            .await
    }
    pub async fn attest(&self, body: AttestRequest) -> crate::Result<AttestResponse> {
        let path = String::from("/v1/sessions/attest");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
}
