vpndetection 6.2.0

The official Rust client library for the VPNDetection API: anonymity detection covering VPNs, residential proxies, Tor nodes, hosting servers, CDNs and relays.
Documentation
/*
 * VPNDetection API
 *
 * The VPNDetection API: classify any IP address, and download the databases behind the answers.  Lookups need no API key: Unlimited, the free plan, answers any address with no daily or monthly cap, with a key or without one. Every paid plan answers every field, and a free account tries them. Unlimited's answers may be used commercially, but not redistributed or used in a competing service (https://vpndetection.io/terms#no-key).  See https://docs.vpndetection.io for guides and https://github.com/vpndetection-io for the official client libraries.
 *
 * The version of the OpenAPI document: 2026.11.20
 * Contact: support@vpndetection.io
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct TokenResponse {
    #[serde(rename = "access_token")]
    pub access_token: String,
    /// Always `Bearer`.
    #[serde(rename = "token_type")]
    pub token_type: String,
    /// Seconds until the access token expires.
    #[serde(rename = "expires_in")]
    pub expires_in: i32,
    /// Always returned. A refresh consumes the token it presents, so keep this one.
    #[serde(rename = "refresh_token", skip_serializing_if = "Option::is_none")]
    pub refresh_token: Option<String>,
    /// What was actually granted, which may be narrower than what was asked for.
    #[serde(rename = "scope", skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
    /// Not part of OAuth, and only for our own clients. The ID of the API key the person picked when they approved, returned by every grant while this authorization may still read that key back. Absent when no key was picked, or when the person's role no longer allows reading keys back.
    #[serde(rename = "mslm:apikey_id", skip_serializing_if = "Option::is_none")]
    pub mslm_colon_apikey_id: Option<String>,
    /// Not part of OAuth, and only for our own clients: a client that signed in with a Client ID Metadata Document or registered itself never receives a key. The API key itself, so a device ends up holding an ordinary key. Returned by the device code and authorization code grants only, never by a refresh, and only alongside `mslm:apikey_id`. Absent when that key's secret cannot be read back, which is the case for a key created before keys could be shown again in the console; a rotated key can be.
    #[serde(rename = "mslm:apikey", skip_serializing_if = "Option::is_none")]
    pub mslm_colon_apikey: Option<String>,
}

impl TokenResponse {
    pub fn new(access_token: String, token_type: String, expires_in: i32) -> TokenResponse {
        TokenResponse {
            access_token,
            token_type,
            expires_in,
            refresh_token: None,
            scope: None,
            mslm_colon_apikey_id: None,
            mslm_colon_apikey: None,
        }
    }
}