Skip to main content

tauri_plugin_pliap/
models.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Deserialize, Serialize)]
4#[serde(rename_all = "camelCase")]
5pub struct PingRequest {
6    pub value: Option<String>,
7}
8
9#[derive(Debug, Clone, Default, Deserialize, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct PingResponse {
12    pub value: Option<String>,
13}
14
15#[derive(Debug, Clone, Default, Deserialize, Serialize)]
16#[serde(rename_all = "camelCase")]
17pub struct PurchaseRequest {
18    /// The product id of the product to purchase.
19    pub product_id: String,
20}
21
22#[derive(Debug, Clone, Default, Deserialize, Serialize)]
23#[serde(rename_all = "camelCase")]
24pub struct SubscriptionPurchaseRequest {
25    /// The product id of the subscription to purchase.
26    pub product_id: String,
27    /// The base plan ID for the subscription (e.g., "monthly", "weekly", "yearly")
28    pub base_plan_id: Option<String>,
29    /// The offer token for the subscription (optional)
30    pub offer_token: Option<String>,
31}
32
33#[derive(Debug, Clone, Default, Deserialize, Serialize)]
34#[serde(rename_all = "camelCase")]
35pub struct ConsumeRequest {
36    /// The purchase token used for consume request
37    pub purchase_token: String,
38}
39
40#[derive(Debug, Clone, Default, Deserialize, Serialize)]
41#[serde(rename_all = "camelCase")]
42pub struct SubscriptionListRequest {
43    /// List of subscription product IDs to query
44    pub product_ids: Vec<String>,
45}
46
47#[derive(Debug, Clone, Default, Deserialize, Serialize)]
48#[serde(rename_all = "camelCase")]
49pub struct PurchaseResponse {
50    /// Wether the purchase was succesful or not
51    pub success: bool,
52}
53
54#[derive(Debug, Clone, Default, Deserialize, Serialize)]
55#[serde(rename_all = "camelCase")]
56pub struct SubscriptionPurchaseResponse {
57    /// Whether the subscription purchase was successful or not
58    pub success: bool,
59    /// The purchase token for the subscription
60    pub purchase_token: Option<String>,
61    /// The order ID for the subscription
62    pub order_id: Option<String>,
63    /// Whether the subscription is auto-renewing
64    pub is_auto_renewing: Option<bool>,
65    /// Whether the purchase is pending (for subscriptions)
66    pub pending: Option<bool>,
67    /// The base plan ID for the subscription (e.g., "monthly", "weekly", "yearly")
68    pub base_plan_id: Option<String>,
69    /// The offer token for the subscription
70    pub offer_token: Option<String>,
71    /// The product ID of the purchased subscription
72    pub product_id: Option<String>,
73    /// The price of the subscription
74    pub price: Option<String>,
75}
76
77#[derive(Debug, Clone, Default, Deserialize, Serialize)]
78#[serde(rename_all = "camelCase")]
79pub struct Product {
80    pub description: String,
81    pub name: String,
82    pub product_id: String,
83    pub product_type: String,
84    pub title: String,
85    pub price: String,
86}
87
88#[derive(Debug, Clone, Default, Deserialize, Serialize)]
89#[serde(rename_all = "camelCase")]
90pub struct SubscriptionProduct {
91    pub description: String,
92    pub name: String,
93    pub product_id: String,
94    pub product_type: String,
95    pub title: String,
96    pub price: String,
97    /// Available base plans for this subscription
98    pub base_plans: Option<Vec<BasePlan>>,
99}
100
101#[derive(Debug, Clone, Default, Deserialize, Serialize)]
102#[serde(rename_all = "camelCase")]
103pub struct BasePlan {
104    /// The base plan ID (e.g., "monthly", "weekly", "yearly")
105    pub base_plan_id: String,
106    /// The display name of the base plan
107    pub name: String,
108    /// The price of the base plan
109    pub price: String,
110    /// The billing period (e.g., "P1M" for monthly, "P1W" for weekly)
111    pub billing_period: String,
112    /// Whether this is the default base plan
113    pub is_default: Option<bool>,
114}
115
116#[derive(Debug, Clone, Default, Deserialize, Serialize)]
117#[serde(rename_all = "camelCase")]
118pub struct Purchase {
119    pub developer_payload: String,
120    pub order_id: Option<String>,
121    pub original_json: String,
122    pub package_name: String,
123    pub products: Vec<String>,
124    pub purchase_state: i32,
125    pub purchase_time: i128,
126    pub purchase_token: String,
127    pub quantity: i32,
128    pub signature: String,
129    pub is_acknowledged: bool,
130    pub is_auto_renewing: bool,
131}
132
133#[derive(Debug, Clone, Default, Deserialize, Serialize)]
134#[serde(rename_all = "camelCase")]
135pub struct ProductsResponse {
136    /// A list of products
137    pub products: Vec<Product>,
138}
139
140#[derive(Debug, Clone, Default, Deserialize, Serialize)]
141#[serde(rename_all = "camelCase")]
142pub struct PurchasesResponse {
143    /// A list of purchases
144    pub purchases: Vec<Purchase>,
145}
146
147#[derive(Debug, Clone, Default, Deserialize, Serialize)]
148#[serde(rename_all = "camelCase")]
149pub struct SubscriptionListResponse {
150    /// A list of subscription products
151    pub subscriptions: Vec<SubscriptionProduct>,
152}