Skip to main content

stakpak_shared/models/
billing.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Serialize, Deserialize, Clone)]
5pub struct CreditSchema {
6    pub credit_amount: Option<f64>,
7    pub credit_cost: Option<f64>,
8    pub feature_id: Option<String>,
9    pub metered_feature_id: Option<String>,
10}
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
13pub struct Feature {
14    pub balance: Option<f64>,
15    pub credit_schema: Option<Vec<CreditSchema>>,
16    pub id: String,
17    pub included_usage: Option<f64>,
18    pub interval: Option<String>,
19    pub interval_count: Option<u32>,
20    pub name: Option<String>,
21    pub next_reset_at: Option<f64>,
22    pub overage_allowed: Option<bool>,
23    pub type_: Option<String>,
24    pub unlimited: Option<bool>,
25    pub usage: Option<f64>,
26    // For product items
27    pub archived: Option<bool>,
28    pub display: Option<HashMap<String, String>>,
29}
30
31#[derive(Debug, Serialize, Deserialize, Clone)]
32pub struct ProductItem {
33    pub feature: Feature,
34    pub feature_id: String,
35    pub feature_type: String,
36    pub included_usage: Option<f64>,
37    pub interval: Option<String>,
38    pub interval_count: Option<u32>,
39    pub reset_usage_when_enabled: Option<bool>,
40    pub type_: Option<String>,
41}
42
43#[derive(Debug, Serialize, Deserialize, Clone)]
44pub struct Product {
45    pub id: String,
46    pub is_add_on: bool,
47    pub is_default: bool,
48    pub items: Vec<ProductItem>,
49    pub name: String,
50    pub quantity: u32,
51    pub started_at: u64,
52    pub status: String,
53    pub version: u32,
54}
55
56#[derive(Debug, Serialize, Deserialize, Clone)]
57pub struct BillingResponse {
58    pub created_at: u64,
59    pub env: String,
60    pub features: HashMap<String, Feature>,
61    pub id: String,
62    pub name: String,
63    pub products: Vec<Product>,
64    pub stripe_id: Option<String>,
65}