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

use crate::consumer::fraud::Fingerprints;
use crate::consumer::fraud::Metadata;
use crate::consumer::fraud::Properties;
use crate::consumer::fraud::Verdict;
use serde::{Deserialize, Serialize};

/// LookupRequest: Request type for `Fingerprint.lookup`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct LookupRequest {
    /// telemetry_id: The telemetry ID associated with the fingerprint getting looked up.
    pub telemetry_id: String,
    /// external_metadata: External identifiers that you wish to associate with the given telemetry ID. You will
    /// be able to search for fingerprint results by these identifiers in the DFP analytics dashboard. External
    /// metadata fields may not exceed 65 characters. They may only contain alphanumerics and the characters `_`
    /// `-` `+` `.` or `@`.
    pub external_metadata: std::option::Option<Metadata>,
}
/// LookupResponse: Response type for `Fingerprint.lookup`.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LookupResponse {
    /// 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,
    /// telemetry_id: The telemetry ID associated with the fingerprint getting looked up.
    pub telemetry_id: String,
    /// fingerprints: A Stytch fingerprint consists of the following identifiers:
    pub fingerprints: Fingerprints,
    /// verdict: The metadata associated with each fingerprint
    pub verdict: Verdict,
    /// external_metadata: External identifiers that you wish to associate with the given telemetry ID. You will
    /// be able to search for fingerprint results by these identifiers in the DFP analytics dashboard. External
    /// metadata fields may not exceed 65 characters. They may only contain alphanumerics and the characters `_`
    /// `-` `+` `.` or `@`.
    pub external_metadata: Metadata,
    /// created_at: The time when the fingerprint was taken. Values conform to the RFC 3339 standard and are
    /// expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
    pub created_at: chrono::DateTime<chrono::Utc>,
    /// expires_at: The timestamp when the fingerprint 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>,
    /// 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,
    /// properties: Additional information about the user's browser and network.
    pub properties: std::option::Option<Properties>,
    /// raw_signals: The raw device attributes, such as screen size, that were collected by the Device
    /// Fingerprinting product to generate the fingerprints and verdict. You must be specifically enabled for
    /// the raw signals feature to see this field. You can find documentation for the specific fields in the
    /// [guides](https://stytch.com/docs/fraud/guides/device-fingerprinting/reference/raw-signals).
    pub raw_signals: std::option::Option<serde_json::Value>,
}

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

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

    pub async fn lookup(&self, body: LookupRequest) -> crate::Result<LookupResponse> {
        let path = String::from("/v1/fingerprint/lookup");
        self.http_client
            .send(crate::Request {
                method: http::Method::POST,
                path,
                body,
            })
            .await
    }
}
