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};

/// Location : Where the address is: the fields of our IP Country database on every answer, with or without a key, and our IP Geolocation database's finer ones on a paid plan. Each field your plan includes is present whenever the object is, so an address in no country, or a private one, answers empty strings and zeros.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Location {
    /// Continent code: AF, AN (Antarctica), AS, EU, NA, OC or SA.
    #[serde(rename = "continent")]
    pub continent: String,
    /// Continent name.
    #[serde(rename = "continent_name")]
    pub continent_name: String,
    /// ISO 3166-1 alpha-2 country code.
    #[serde(rename = "country")]
    pub country: String,
    /// Country name.
    #[serde(rename = "country_name")]
    pub country_name: String,
    /// IANA timezone of the address.
    #[serde(rename = "timezone")]
    pub timezone: String,
    /// ISO 4217 code of the country's currency, where there is one.
    #[serde(rename = "currency_code")]
    pub currency_code: String,
    /// Name of the country's currency, where there is one.
    #[serde(rename = "currency_name")]
    pub currency_name: String,
    /// Symbol of the country's currency, where known.
    #[serde(rename = "currency_symbol")]
    pub currency_symbol: String,
    /// The country's flag, as an emoji.
    #[serde(rename = "flag_emoji")]
    pub flag_emoji: String,
    /// The Unicode code points of the flag emoji.
    #[serde(rename = "flag_unicode")]
    pub flag_unicode: String,
    /// Region (state or province). Paid plans.
    #[serde(rename = "region", skip_serializing_if = "Option::is_none")]
    pub region: Option<String>,
    /// ISO 3166-2 region code. Paid plans.
    #[serde(rename = "region_code", skip_serializing_if = "Option::is_none")]
    pub region_code: Option<String>,
    /// City. Paid plans.
    #[serde(rename = "city", skip_serializing_if = "Option::is_none")]
    pub city: Option<String>,
    /// Postal code. Paid plans.
    #[serde(rename = "postal_code", skip_serializing_if = "Option::is_none")]
    pub postal_code: Option<String>,
    /// Latitude of the city. Paid plans.
    #[serde(rename = "latitude", skip_serializing_if = "Option::is_none")]
    pub latitude: Option<f64>,
    /// Longitude of the city. Paid plans.
    #[serde(rename = "longitude", skip_serializing_if = "Option::is_none")]
    pub longitude: Option<f64>,
    /// Radius in km holding the true location with 67% confidence; 20000 for an address announced everywhere, as an anycast one is. Paid plans.
    #[serde(rename = "accuracy_radius", skip_serializing_if = "Option::is_none")]
    pub accuracy_radius: Option<i32>,
    /// GeoNames ID of the city. Paid plans.
    #[serde(rename = "geoname_id", skip_serializing_if = "Option::is_none")]
    pub geoname_id: Option<String>,
    /// US TV market (DMA) code, empty outside the US. Paid plans.
    #[serde(rename = "dma_code", skip_serializing_if = "Option::is_none")]
    pub dma_code: Option<String>,
    /// The day the range's location last changed. Paid plans.
    #[serde(rename = "last_changed", skip_serializing_if = "Option::is_none")]
    pub last_changed: Option<String>,
}

impl Location {
    /// Where the address is: the fields of our IP Country database on every answer, with or without a key, and our IP Geolocation database's finer ones on a paid plan. Each field your plan includes is present whenever the object is, so an address in no country, or a private one, answers empty strings and zeros.
    pub fn new(
        continent: String,
        continent_name: String,
        country: String,
        country_name: String,
        timezone: String,
        currency_code: String,
        currency_name: String,
        currency_symbol: String,
        flag_emoji: String,
        flag_unicode: String,
    ) -> Location {
        Location {
            continent,
            continent_name,
            country,
            country_name,
            timezone,
            currency_code,
            currency_name,
            currency_symbol,
            flag_emoji,
            flag_unicode,
            region: None,
            region_code: None,
            city: None,
            postal_code: None,
            latitude: None,
            longitude: None,
            accuracy_radius: None,
            geoname_id: None,
            dma_code: None,
            last_changed: None,
        }
    }
}