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
47impl<T: Display> From<T> for TransactionID {
48    fn from(value: T) -> Self {
49        TransactionID(value.to_string())
50    }
51}
52
53impl AsRef<str> for TransactionID {
54    fn as_ref(&self) -> &str {
55        &self.0
56    }
57}
58/// Unique Paddle ID for this subscription entity, prefixed with `sub_`.
59#[derive(Clone, Debug, Serialize, Deserialize)]
60pub struct SubscriptionID(String);
61
62impl<T: Display> From<T> for SubscriptionID {
63    fn from(value: T) -> Self {
64        SubscriptionID(value.to_string())
65    }
66}
67
68impl AsRef<str> for SubscriptionID {
69    fn as_ref(&self) -> &str {
70        &self.0
71    }
72}
73
74/// Unique Paddle ID for this transaction item, prefixed with `txnitm_`. Used when working with [adjustments](https://developer.paddle.com/build/transactions/create-transaction-adjustments).
75#[derive(Clone, Debug, Serialize, Deserialize)]
76pub struct TransactionItemID(String);
77
78/// Unique Paddle ID for this adjustment item, prefixed with `adjitm_`.
79#[derive(Clone, Debug, Serialize, Deserialize)]
80pub struct AdjustmentItemID(String);
81
82/// Unique Paddle ID for this business entity, prefixed with `biz_`.
83#[derive(Clone, Debug, Serialize, Deserialize)]
84pub struct BusinessID(String);
85
86impl<T: Display> From<T> for BusinessID {
87    fn from(value: T) -> Self {
88        BusinessID(value.to_string())
89    }
90}
91
92impl AsRef<str> for BusinessID {
93    fn as_ref(&self) -> &str {
94        &self.0
95    }
96}
97
98/// Unique Paddle ID for this payment method entity, prefixed with `paymtd_`.
99#[derive(Clone, Debug, Serialize, Deserialize)]
100pub struct PaymentMethodID(String);
101
102impl<T: Display> From<T> for PaymentMethodID {
103    fn from(value: T) -> Self {
104        PaymentMethodID(value.to_string())
105    }
106}
107
108impl AsRef<str> for PaymentMethodID {
109    fn as_ref(&self) -> &str {
110        &self.0
111    }
112}
113
114/// Unique Paddle ID for this customer portal session entity, prefixed with `cpls_`.
115#[derive(Clone, Debug, Serialize, Deserialize)]
116pub struct CustomerPortalSessionID(String);
117
118/// Unique Paddle ID for this discount, prefixed with `dsc_`.
119#[derive(Clone, Debug, Serialize, Deserialize)]
120pub struct DiscountID(String);
121
122impl<T: Display> From<T> for DiscountID {
123    fn from(value: T) -> Self {
124        DiscountID(value.to_string())
125    }
126}
127
128impl AsRef<str> for DiscountID {
129    fn as_ref(&self) -> &str {
130        &self.0
131    }
132}
133
134/// Unique code that customers can use to apply this discount at checkout. Use letters and numbers only, up to 16 characters. Not case-sensitive.
135#[derive(Clone, Debug, Serialize, Deserialize)]
136pub struct DiscountCode(String);
137
138/// Unique Paddle ID for this event, prefixed with `evt_`.
139#[derive(Clone, Debug, Serialize, Deserialize)]
140pub struct EventID(String);
141
142/// Unique Paddle ID for this price, prefixed with `pri_`.
143#[derive(Clone, Debug, Serialize, Deserialize)]
144pub struct PriceID(String);
145
146impl<T: Display> From<T> for PriceID {
147    fn from(value: T) -> Self {
148        PriceID(value.to_string())
149    }
150}
151
152impl AsRef<str> for PriceID {
153    fn as_ref(&self) -> &str {
154        &self.0
155    }
156}
157
158/// Unique Paddle ID for this product, prefixed with `pro_`.
159#[derive(Clone, Debug, Serialize, Deserialize)]
160pub struct ProductID(pub String);
161
162impl<T: Display> From<T> for ProductID {
163    fn from(value: T) -> Self {
164        ProductID(value.to_string())
165    }
166}
167
168// Needed for serialization to comma separated values
169impl AsRef<str> for ProductID {
170    fn as_ref(&self) -> &str {
171        &self.0
172    }
173}
174
175/// Unique Paddle ID for this notification, prefixed with `ntf_`.
176#[derive(Clone, Debug, Serialize, Deserialize)]
177pub struct NotificationID(String);
178
179/// Unique Paddle ID for this notification setting, prefixed with `ntfset_`.
180#[derive(Clone, Debug, Serialize, Deserialize)]
181pub struct NotificationSettingID(String);
182
183/// Unique Paddle ID for this notification log, prefixed with `ntflog_`.
184#[derive(Clone, Debug, Serialize, Deserialize)]
185pub struct NotificationLogID(String);
186
187/// Webhook destination secret key, prefixed with `pdl_ntfset_`. Used for signature verification.
188#[derive(Clone, Debug, Serialize, Deserialize)]
189pub struct EndpointSecretKey(String);
190
191/// Unique Paddle ID for this entity.
192#[derive(Clone, Debug, Serialize, Deserialize)]
193pub struct PaddleID(String);
194
195/// Unique Paddle ID for this simulation event, prefixed with `ntfsimevt_`.
196#[derive(Clone, Debug, Serialize, Deserialize)]
197pub struct SimulationEventID(String);
198
199/// Unique Paddle ID for this simulation run, prefixed with `ntfsimrun_`.
200#[derive(Clone, Debug, Serialize, Deserialize)]
201pub struct SimulationRunID(String);
202
203/// Unique Paddle ID for this simulation, prefixed with `ntfsim_`.
204#[derive(Clone, Debug, Serialize, Deserialize)]
205pub struct SimulationID(String);
206
207/// 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.
208#[derive(Clone, Debug, Serialize, Deserialize)]
209pub struct InvoiceId(String);