scrapebadger 0.2.0

Async Rust SDK and CLI for the ScrapeBadger web-scraping API (Amazon, Google, Twitter/X, Reddit, Vinted, Web Scraping).
Documentation
// @generated by `cargo run -p xtask -- gen` from specs/account.json — do not edit by hand.
#![allow(clippy::all)]
#![allow(
    dead_code,
    unused_imports,
    unused_variables,
    non_snake_case,
    rustdoc::all
)]

use crate::core::{Client, Error, Method, QueryParams, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

/// Handle for the `account` platform. Obtain via [`crate::ScrapeBadger::account`].
#[derive(Clone)]
pub struct Account {
    client: Client,
}

impl Account {
    pub(crate) fn new(client: Client) -> Self {
        Self { client }
    }

    /// Access the underlying transport client.
    pub fn client(&self) -> &Client {
        &self.client
    }

    /// Get Account Info
    ///
    /// Check your credit balances, subscription details, plan tier, and rate limits. No credits are deducted for this call.
    /// `GET /v1/account/me`
    pub async fn get_account_info(
        &self,
        params: GetAccountInfoParams,
    ) -> Result<GetAccountInfoResponse> {
        let path = "/v1/account/me".to_string();
        let query: Vec<(String, String)> = Vec::new();
        let body = None;
        self.client.send(Method::GET, &path, &query, body).await
    }
}

// ===== Models =====

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetAccountInfoResponse {
    /// PAYG (pay-as-you-go) credit balance — never expires
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub credits_balance: Option<i64>,
    /// Maximum API requests allowed per minute
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub rate_limit_per_minute: Option<i64>,
    /// Active subscription details, or null if PAYG-only
    pub subscription: Option<GetAccountInfoResponseSubscription>,
    /// Subscription wallet — current period's monthly allowance (0 if no subscription)
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub subscription_credits_balance: Option<i64>,
    /// Account tier (free, basic, pro, enterprise)
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub tier: Option<String>,
    /// Sum of PAYG + subscription credits
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub total_credits_balance: Option<i64>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Active subscription details, or null if PAYG-only
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GetAccountInfoResponseSubscription {
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub billing_cadence: Option<String>,
    /// Whether the subscription is set to cancel at period end
    #[serde(default, deserialize_with = "crate::core::flex::opt_bool")]
    pub cancel_at_period_end: Option<bool>,
    /// When the cancellation takes effect
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub cancel_effective_at: Option<String>,
    /// Next renewal date
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub current_period_end: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub current_period_start: Option<String>,
    /// Credits included per month in this plan
    #[serde(default, deserialize_with = "crate::core::flex::opt_i64")]
    pub monthly_credits: Option<i64>,
    /// When the pending plan change takes effect
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub pending_change_effective_at: Option<String>,
    /// Scheduled downgrade plan code
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub pending_plan_code: Option<String>,
    /// Scheduled downgrade plan title
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub pending_plan_title: Option<String>,
    /// Plan identifier (e.g., starter, growth, pro)
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub plan_code: Option<String>,
    /// Display name of the plan
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub plan_title: Option<String>,
    #[serde(default, deserialize_with = "crate::core::flex::opt_string")]
    pub status: Option<String>,
    /// Fields present in the response but not in the spec.
    #[serde(flatten)]
    pub extra: HashMap<String, Value>,
}

/// Parameters for [`GetAccountInfoParams`]. All fields optional; required ones are noted per method.
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetAccountInfoParams {}