/*
* img-src API
*
* Image processing and delivery API. A serverless image processing and delivery API built on Cloudflare Workers with parameter-driven image transformation and on-demand transcoding. ## Features - **Image Upload**: Store original images in R2 with SHA256-based deduplication - **On-Demand Transformation**: Resize, crop, and convert images via URL parameters - **Format Conversion**: WebP, AVIF, JPEG, PNG output formats - **Path Organization**: Organize images into folders with multiple paths per image - **CDN Caching**: Automatic edge caching for transformed images ## Authentication Authenticate using API Keys with `imgsrc_` prefix. Create your API key at https://img-src.io/settings ## Rate Limiting - **Free Plan**: 100 requests/minute - **Pro Plan**: 500 requests/minute Rate limit headers are included in all responses.
*
* The version of the OpenAPI document: 1.0.0
* Contact: taehun@taehun.dev
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UsageResponse {
/// User's plan ID
#[serde(rename = "plan")]
pub plan: String,
/// Human-readable plan name
#[serde(rename = "plan_name")]
pub plan_name: String,
/// Current plan status
#[serde(rename = "plan_status")]
pub plan_status: PlanStatus,
/// Unix timestamp when subscription ends (for cancelling plans)
#[serde(rename = "subscription_ends_at")]
pub subscription_ends_at: Option<i64>,
#[serde(rename = "plan_limits")]
pub plan_limits: Box<models::PlanLimits>,
/// Total images (lifetime)
#[serde(rename = "total_images")]
pub total_images: i32,
/// Total storage used in bytes
#[serde(rename = "storage_used_bytes")]
pub storage_used_bytes: i64,
/// Total storage used in MB
#[serde(rename = "storage_used_mb")]
pub storage_used_mb: f64,
/// Total storage used in GB
#[serde(rename = "storage_used_gb")]
pub storage_used_gb: f64,
#[serde(rename = "current_period")]
pub current_period: Box<models::CurrentPeriod>,
#[serde(rename = "credits")]
pub credits: Box<models::Credits>,
}
impl UsageResponse {
pub fn new(
plan: String,
plan_name: String,
plan_status: PlanStatus,
plan_limits: models::PlanLimits,
total_images: i32,
storage_used_bytes: i64,
storage_used_mb: f64,
storage_used_gb: f64,
current_period: models::CurrentPeriod,
credits: models::Credits,
) -> UsageResponse {
UsageResponse {
plan,
plan_name,
plan_status,
subscription_ends_at: None,
plan_limits: Box::new(plan_limits),
total_images,
storage_used_bytes,
storage_used_mb,
storage_used_gb,
current_period: Box::new(current_period),
credits: Box::new(credits),
}
}
}
/// Current plan status
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum PlanStatus {
#[serde(rename = "active")]
Active,
#[serde(rename = "cancelling")]
Cancelling,
#[serde(rename = "expired")]
Expired,
}
impl Default for PlanStatus {
fn default() -> PlanStatus {
Self::Active
}
}