Skip to main content

scrapfly_sdk/result/
account.rs

1//! Account result — port of `sdk/go/result_account.go`.
2
3use serde::Deserialize;
4
5/// `GET /account` response.
6#[derive(Debug, Clone, Deserialize, Default)]
7pub struct AccountData {
8    /// Account-level info.
9    #[serde(default)]
10    pub account: serde_json::Value,
11    /// Active project info.
12    #[serde(default)]
13    pub project: serde_json::Value,
14    /// Subscription info (includes usage counters).
15    #[serde(default)]
16    pub subscription: serde_json::Value,
17}
18
19impl AccountData {
20    /// Extract `subscription.usage.scrape.concurrent_limit`, best-effort.
21    /// Returns 0 if the field is missing or not an integer.
22    pub fn concurrent_limit(&self) -> u32 {
23        self.subscription
24            .pointer("/usage/scrape/concurrent_limit")
25            .and_then(|v| v.as_u64())
26            .map(|v| v as u32)
27            .unwrap_or(0)
28    }
29}
30
31/// Response from API-key verification calls.
32#[derive(Debug, Clone, Deserialize, Default)]
33pub struct VerifyApiKeyResult {
34    /// Whether the key is valid.
35    #[serde(default)]
36    pub valid: bool,
37}