paddle_rust_sdk/
ids.rs

1//! Unique Paddle IDs
2
3use std::fmt::Display;
4
5use serde::{Deserialize, Serialize};
6
7/// Unique Paddle ID for this address entity, prefixed with `add_`.
8#[derive(Clone, Debug, Serialize, Deserialize)]
9pub struct AddressID(String);
10
11impl<T: Display> From<T> for AddressID {
12    fn from(value: T) -> Self {
13        AddressID(value.to_string())
14    }
15}
16
17impl AsRef<str> for AddressID {
18    fn as_ref(&self) -> &str {
19        &self.0
20    }
21}
22
23/// Unique Paddle ID for this customer entity, prefixed with `ctm_`.
24#[derive(Clone, Debug, Serialize, Deserialize)]
25pub struct CustomerID(String);
26
27impl<T: Display> From<T> for CustomerID {
28    fn from(value: T) -> Self {
29        CustomerID(value.to_string())
30    }
31}
32
33impl AsRef<str> for CustomerID {
34    fn as_ref(&self) -> &str {
35        &self.0
36    }
37}
38
39/// Unique Paddle ID for this adjustment entity, prefixed with `adj_`.
40#[derive(Clone, Debug, Serialize, Deserialize)]
41pub struct AdjustmentID(String);
42
43/// Unique Paddle ID for this transaction entity, prefixed with `txn_`.
44#[derive(Clone, Debug, Serialize, Deserialize)]
45pub struct TransactionID(String);
46
47/// Unique Paddle ID for this subscription entity, prefixed with `sub_`.
48#[derive(Clone, Debug, Serialize, Deserialize)]
49pub struct SubscriptionID(String);
50
51/// Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments).
52#[derive(Clone, Debug, Serialize, Deserialize)]
53pub struct TransactionItemID(String);
54
55/// Unique Paddle ID for this adjustment item, prefixed with `adjitm_`.
56#[derive(Clone, Debug, Serialize, Deserialize)]
57pub struct AdjustmentItemID(String);
58
59/// Unique Paddle ID for this business entity, prefixed with `biz_`.
60#[derive(Clone, Debug, Serialize, Deserialize)]
61pub struct BusinessID(String);
62
63/// Unique Paddle ID for this payment method entity, prefixed with `paymtd_`.
64#[derive(Clone, Debug, Serialize, Deserialize)]
65pub struct PaymentMethodID(String);
66
67/// Unique Paddle ID for this customer portal session entity, prefixed with `cpls_`.
68#[derive(Clone, Debug, Serialize, Deserialize)]
69pub struct CustomerPortalSessionID(String);
70
71/// Unique Paddle ID for this discount, prefixed with `dsc_`.
72#[derive(Clone, Debug, Serialize, Deserialize)]
73pub struct DiscountID(String);
74
75impl<T: Display> From<T> for DiscountID {
76    fn from(value: T) -> Self {
77        DiscountID(value.to_string())
78    }
79}
80
81impl AsRef<str> for DiscountID {
82    fn as_ref(&self) -> &str {
83        &self.0
84    }
85}
86
87/// Unique code that customers can use to apply this discount at checkout. Use letters and numbers only, up to 16 characters. Not case-sensitive.
88#[derive(Clone, Debug, Serialize, Deserialize)]
89pub struct DiscountCode(String);
90
91/// Unique Paddle ID for this event, prefixed with `evt_`.
92#[derive(Clone, Debug, Serialize, Deserialize)]
93pub struct EventID(String);
94
95/// Unique Paddle ID for this price, prefixed with `pri_`.
96#[derive(Clone, Debug, Serialize, Deserialize)]
97pub struct PriceID(String);
98
99impl<T: Display> From<T> for PriceID {
100    fn from(value: T) -> Self {
101        PriceID(value.to_string())
102    }
103}
104
105impl AsRef<str> for PriceID {
106    fn as_ref(&self) -> &str {
107        &self.0
108    }
109}
110
111/// Unique Paddle ID for this product, prefixed with `pro_`.
112#[derive(Clone, Debug, Serialize, Deserialize)]
113pub struct ProductID(pub String);
114
115impl<T: Display> From<T> for ProductID {
116    fn from(value: T) -> Self {
117        ProductID(value.to_string())
118    }
119}
120
121// Needed for serialization to comma separated values
122impl AsRef<str> for ProductID {
123    fn as_ref(&self) -> &str {
124        &self.0
125    }
126}
127
128/// Unique Paddle ID for this notification, prefixed with `ntf_`.
129#[derive(Clone, Debug, Serialize, Deserialize)]
130pub struct NotificationID(String);
131
132/// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
133#[derive(Clone, Debug, Serialize, Deserialize)]
134pub struct NotificationSettingID(String);
135
136/// Unique Paddle ID for this notification log, prefixed with `ntflog_`.
137#[derive(Clone, Debug, Serialize, Deserialize)]
138pub struct NotificationLogID(String);
139
140/// Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
141#[derive(Clone, Debug, Serialize, Deserialize)]
142pub struct EndpointSecretKey(String);
143
144/// Unique Paddle ID for this entity.
145#[derive(Clone, Debug, Serialize, Deserialize)]
146pub struct PaddleID(String);
147
148/// Unique Paddle ID for this simulation event, prefixed with `ntfsimevt_`.
149#[derive(Clone, Debug, Serialize, Deserialize)]
150pub struct SimulationEventID(String);
151
152/// Unique Paddle ID for this simulation run, prefixed with `ntfsimrun_`.
153#[derive(Clone, Debug, Serialize, Deserialize)]
154pub struct SimulationRunID(String);
155
156/// Unique Paddle ID for this simulation, prefixed with `ntfsim_`.
157#[derive(Clone, Debug, Serialize, Deserialize)]
158pub struct SimulationID(String);
159
160/// Paddle ID of the invoice that this transaction is related to, prefixed with `inv_`. Used for compatibility with the Paddle Invoice API, which is now deprecated. This field is scheduled to be removed in the next version of the Paddle API.
161#[derive(Clone, Debug, Serialize, Deserialize)]
162pub struct InvoiceId(String);