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

use crate::b2b::mfa::MfaRequired;
use crate::b2b::organizations::Member;
use crate::b2b::organizations::Organization;
use crate::consumer::device_history::DeviceInfo;
use crate::consumer::sessions::AuthenticationFactor;
use crate::consumer::sessions::JWK;
use percent_encoding;
use serde::{Deserialize, Serialize};
use serde_urlencoded;

/// AuthorizationCheck:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AuthorizationCheck {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The Organization's ID
    /// must match the Member's Organization
    pub organization_id: String,
    /// 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. These include:
    ///
    ///   * `stytch.organization`
    ///   * `stytch.member`
    ///   * `stytch.sso`
    ///   * `stytch.self`
    ///
    ///   Check out the
    /// [guide on Stytch default Resources](https://stytch.com/docs/b2b/guides/rbac/stytch-default) for a more
    /// detailed explanation.
    ///
    ///
    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 Member 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 Member permission to perform the specified
    /// action on the specified Resource.
    pub granting_roles: std::vec::Vec<String>,
}
/// MemberSession:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MemberSession {
    /// member_session_id: Globally unique UUID that identifies a specific Session.
    pub member_session_id: String,
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_id: String,
    /// 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: 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: 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: chrono::DateTime<chrono::Utc>,
    /// authentication_factors: An array of different authentication factors that comprise a Session.
    pub authentication_factors: std::vec::Vec<AuthenticationFactor>,
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value.
    pub organization_id: String,
    pub roles: std::vec::Vec<String>,
    /// organization_slug: The unique URL slug of the Organization. The slug only accepts alphanumeric
    /// characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters
    /// in length. Wherever an organization_id is expected in a path or request parameter, you may also use the
    /// organization_slug as a convenience.
    pub organization_slug: String,
    /// 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>,
}
/// PrimaryRequired:
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PrimaryRequired {
    /// allowed_auth_methods: Details the auth method that the member must also complete to fulfill the primary
    /// authentication requirements of the Organization. For example, a value of `[magic_link]` indicates that
    /// the Member must also complete a magic link authentication step. If you have an intermediate session
    /// token, you must pass it into that primary authentication step.
    pub allowed_auth_methods: std::vec::Vec<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. The token must have an organization ID claim if JIT
    /// provisioning is enabled.
    pub token: String,
    /// organization_id: The organization ID that the session should be authenticated in. Must be provided if
    /// the trusted auth token does not have an organization ID claim.
    pub organization_id: std::option::Option<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 be created with a
    /// 60 minute duration. If you don't want
    ///   to use the Stytch session product, you can ignore the session fields in the response.
    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 Member. 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,
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_id: String,
    /// member_session: The [Session object](https://stytch.com/docs/b2b/api/session-object).
    pub member_session: MemberSession,
    /// 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,
    /// member: The [Member object](https://stytch.com/docs/b2b/api/member-object)
    pub member: Member,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// 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,
    /// member_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
    /// `member_device` response field will contain information about the member's device attributes.
    pub member_device: std::option::Option<DeviceInfo>,
}
/// AuthenticateRequest: Request type for `Sessions.authenticate`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct AuthenticateRequest {
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: std::option::Option<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 be created with a
    /// 60 minute duration. If you don't want
    ///   to use the Stytch session product, you can ignore the session fields in the response.
    pub session_duration_minutes: std::option::Option<i32>,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    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 Member is
    ///   authorized to perform the given action on the given Resource in the specified Organization. A Member
    /// is authorized if
    ///   their Member Session contains a Role, assigned
    ///   [explicitly or implicitly](https://stytch.com/docs/b2b/guides/rbac/role-assignment), with adequate
    /// permissions.
    ///   In addition, the `organization_id` passed in the authorization check must match the Member's
    /// Organization.
    ///
    ///   The Roles on the Member Session may differ from the Roles you see on the Member object - Roles that
    /// are implicitly
    ///   assigned by SSO connection or SSO group will only be valid for a Member Session if there is at least
    /// one authentication
    ///   factor on the Member Session from the specified SSO connection.
    ///
    ///   If the Member is not authorized to perform the specified action on the specified Resource, or if the
    ///   `organization_id` does not match the Member's Organization, 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,
    /// member_session: The [Session object](https://stytch.com/docs/b2b/api/session-object).
    pub member_session: MemberSession,
    /// 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,
    /// member: The [Member object](https://stytch.com/docs/b2b/api/member-object)
    pub member: Member,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// 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 Member 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 be created with a
    /// 60 minute duration. If you don't want
    ///   to use the Stytch session product, you can ignore the session fields in the response.
    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 Member. 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,
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_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,
    /// member: The [Member object](https://stytch.com/docs/b2b/api/member-object)
    pub member: Member,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// 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,
    /// member_session: The [Session object](https://stytch.com/docs/b2b/api/session-object).
    pub member_session: std::option::Option<MemberSession>,
    /// member_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
    /// `member_device` response field will contain information about the member's device attributes.
    pub member_device: std::option::Option<DeviceInfo>,
}
/// ExchangeRequest: Request type for `Sessions.exchange`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct ExchangeRequest {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// session_token: The `session_token` belonging to the member that you wish to associate the email with.
    pub session_token: std::option::Option<String>,
    /// session_jwt: The `session_jwt` belonging to the member that you wish to associate the email with.
    pub session_jwt: std::option::Option<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 be created with a
    /// 60 minute duration. If you don't want
    ///   to use the Stytch session product, you can ignore the session fields in the response.
    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>,
    /// locale: If the Member needs to complete an MFA step, and the Member has a phone number, this endpoint
    /// will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will
    /// be used to determine which language to use when sending the passcode.
    ///
    /// Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/),
    /// e.g. `"en"`.
    ///
    /// Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese
    /// (`"pt-br"`); if no value is provided, the copy defaults to English.
    ///
    /// Request support for additional languages
    /// [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
    ///
    pub locale: std::option::Option<ExchangeRequestLocale>,
    /// 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 Member. Your workspace must be enabled for Device
    /// Fingerprinting to use this feature.
    pub telemetry_id: std::option::Option<String>,
}
/// ExchangeResponse: Response type for `Sessions.exchange`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ExchangeResponse {
    /// 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,
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_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,
    /// member: The [Member object](https://stytch.com/docs/b2b/api/member-object)
    pub member: Member,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    /// member_authenticated: Indicates whether the Member is fully authenticated. If false, the Member needs to
    /// complete an MFA step to log in to the Organization.
    pub member_authenticated: bool,
    /// intermediate_session_token: The returned Intermediate Session Token contains any Email Magic Link or
    /// OAuth factors from the original member session that are valid for the target Organization. If this value
    /// is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token
    /// can be used with the
    /// [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms),
    /// [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or
    /// [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an
    /// MFA flow and log in to the Organization. The token has a default expiry of 10 minutes. It can also be
    /// used with the
    /// [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session)
    /// to join a specific Organization that allows the factors represented by the intermediate session token;
    /// or the
    /// [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member. Intermediate Session Tokens have a default expiry of 10 minutes.
    pub intermediate_session_token: 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,
    /// member_session: The [Session object](https://stytch.com/docs/b2b/api/session-object).
    pub member_session: std::option::Option<MemberSession>,
    /// mfa_required: Information about the MFA requirements of the Organization and the Member's options for
    /// fulfilling MFA.
    pub mfa_required: std::option::Option<MfaRequired>,
    /// primary_required: Information about the primary authentication requirements of the Organization.
    pub primary_required: std::option::Option<PrimaryRequired>,
    /// member_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
    /// `member_device` response field will contain information about the member's device attributes.
    pub member_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 {
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: String,
    /// member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to
    /// perform operations on a Member, so be sure to preserve this value. You may use an external_id here if
    /// one is set for the member.
    pub member_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,
    /// member_sessions: An array of [Session objects](https://stytch.com/docs/b2b/api/session-object).
    pub member_sessions: std::vec::Vec<MemberSession>,
    /// 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,
    /// organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is
    /// critical to perform operations on an Organization, so be sure to preserve this value. You may also use
    /// the organization_slug or organization_external_id here as a convenience.
    pub organization_id: 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 be created with a
    /// 60 minute duration. If you don't want
    ///   to use the Stytch session product, you can ignore the session fields in the response.
    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>,
}
/// 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,
    /// member_id: Globally unique UUID that identifies a specific Member.
    pub member_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,
    /// member: The [Member object](https://stytch.com/docs/b2b/api/member-object)
    pub member: Member,
    /// organization: The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
    pub organization: Organization,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
    /// member_session: The [Session object](https://stytch.com/docs/b2b/api/session-object).
    pub member_session: std::option::Option<MemberSession>,
}
/// RevokeRequest: Request type for `Sessions.revoke`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct RevokeRequest {
    /// member_session_id: Globally unique UUID that identifies a specific Session in the Stytch API. The
    /// `member_session_id` is critical to perform operations on an Session, so be sure to preserve this value.
    pub member_session_id: std::option::Option<String>,
    /// session_token: A secret token for a given Stytch Session.
    pub session_token: std::option::Option<String>,
    /// session_jwt: The JSON Web Token (JWT) for a given Stytch Session.
    pub session_jwt: std::option::Option<String>,
    /// member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to
    /// perform operations on a Member, so be sure to preserve this value.
    pub member_id: 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 ExchangeRequestLocale {
    #[serde(rename = "en")]
    #[default]
    En,
    #[serde(rename = "es")]
    Es,
    #[serde(rename = "ptbr")]
    Ptbr,
    #[serde(rename = "fr")]
    Fr,
    #[serde(rename = "it")]
    It,
    #[serde(rename = "deDE")]
    DeDE,
    #[serde(rename = "zhHans")]
    ZhHans,
    #[serde(rename = "caES")]
    CaES,
}

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 = format!(
            "/v1/b2b/sessions?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
    pub async fn authenticate(
        &self,
        body: AuthenticateRequest,
    ) -> crate::Result<AuthenticateResponse> {
        let path = String::from("/v1/b2b/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/b2b/sessions/revoke");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn exchange(&self, body: ExchangeRequest) -> crate::Result<ExchangeResponse> {
        let path = String::from("/v1/b2b/sessions/exchange");
        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/b2b/sessions/exchange_access_token");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
    pub async fn attest(&self, body: AttestRequest) -> crate::Result<AttestResponse> {
        let path = String::from("/v1/b2b/sessions/attest");
        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/b2b/sessions/migrate");
        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 = percent_encoding::utf8_percent_encode(
            &body.project_id,
            percent_encoding::NON_ALPHANUMERIC,
        )
        .to_string();
        let path = format!(
            "/v1/b2b/sessions/jwks/{project_id}?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
}
