1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListFileLinkBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 created: Option<stripe_types::RangeQueryTs>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 ending_before: Option<String>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 expand: Option<Vec<String>>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 expired: Option<bool>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 file: Option<String>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 limit: Option<i64>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 starting_after: Option<String>,
21}
22impl ListFileLinkBuilder {
23 fn new() -> Self {
24 Self {
25 created: None,
26 ending_before: None,
27 expand: None,
28 expired: None,
29 file: None,
30 limit: None,
31 starting_after: None,
32 }
33 }
34}
35#[derive(Clone, Debug, serde::Serialize)]
37pub struct ListFileLink {
38 inner: ListFileLinkBuilder,
39}
40impl ListFileLink {
41 pub fn new() -> Self {
43 Self { inner: ListFileLinkBuilder::new() }
44 }
45 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
47 self.inner.created = Some(created.into());
48 self
49 }
50 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
54 self.inner.ending_before = Some(ending_before.into());
55 self
56 }
57 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
59 self.inner.expand = Some(expand.into());
60 self
61 }
62 pub fn expired(mut self, expired: impl Into<bool>) -> Self {
64 self.inner.expired = Some(expired.into());
65 self
66 }
67 pub fn file(mut self, file: impl Into<String>) -> Self {
69 self.inner.file = Some(file.into());
70 self
71 }
72 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
75 self.inner.limit = Some(limit.into());
76 self
77 }
78 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
82 self.inner.starting_after = Some(starting_after.into());
83 self
84 }
85}
86impl Default for ListFileLink {
87 fn default() -> Self {
88 Self::new()
89 }
90}
91impl ListFileLink {
92 pub async fn send<C: StripeClient>(
94 &self,
95 client: &C,
96 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
97 self.customize().send(client).await
98 }
99
100 pub fn send_blocking<C: StripeBlockingClient>(
102 &self,
103 client: &C,
104 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
105 self.customize().send_blocking(client)
106 }
107
108 pub fn paginate(
109 &self,
110 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::FileLink>> {
111 stripe_client_core::ListPaginator::new_list("/file_links", &self.inner)
112 }
113}
114
115impl StripeRequest for ListFileLink {
116 type Output = stripe_types::List<stripe_shared::FileLink>;
117
118 fn build(&self) -> RequestBuilder {
119 RequestBuilder::new(StripeMethod::Get, "/file_links").query(&self.inner)
120 }
121}
122#[derive(Clone, Debug, serde::Serialize)]
123struct RetrieveFileLinkBuilder {
124 #[serde(skip_serializing_if = "Option::is_none")]
125 expand: Option<Vec<String>>,
126}
127impl RetrieveFileLinkBuilder {
128 fn new() -> Self {
129 Self { expand: None }
130 }
131}
132#[derive(Clone, Debug, serde::Serialize)]
134pub struct RetrieveFileLink {
135 inner: RetrieveFileLinkBuilder,
136 link: stripe_shared::FileLinkId,
137}
138impl RetrieveFileLink {
139 pub fn new(link: impl Into<stripe_shared::FileLinkId>) -> Self {
141 Self { link: link.into(), inner: RetrieveFileLinkBuilder::new() }
142 }
143 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
145 self.inner.expand = Some(expand.into());
146 self
147 }
148}
149impl RetrieveFileLink {
150 pub async fn send<C: StripeClient>(
152 &self,
153 client: &C,
154 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
155 self.customize().send(client).await
156 }
157
158 pub fn send_blocking<C: StripeBlockingClient>(
160 &self,
161 client: &C,
162 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
163 self.customize().send_blocking(client)
164 }
165}
166
167impl StripeRequest for RetrieveFileLink {
168 type Output = stripe_shared::FileLink;
169
170 fn build(&self) -> RequestBuilder {
171 let link = &self.link;
172 RequestBuilder::new(StripeMethod::Get, format!("/file_links/{link}")).query(&self.inner)
173 }
174}
175#[derive(Clone, Debug, serde::Serialize)]
176struct CreateFileLinkBuilder {
177 #[serde(skip_serializing_if = "Option::is_none")]
178 expand: Option<Vec<String>>,
179 #[serde(skip_serializing_if = "Option::is_none")]
180 expires_at: Option<stripe_types::Timestamp>,
181 file: String,
182 #[serde(skip_serializing_if = "Option::is_none")]
183 metadata: Option<std::collections::HashMap<String, String>>,
184}
185impl CreateFileLinkBuilder {
186 fn new(file: impl Into<String>) -> Self {
187 Self { expand: None, expires_at: None, file: file.into(), metadata: None }
188 }
189}
190#[derive(Clone, Debug, serde::Serialize)]
192pub struct CreateFileLink {
193 inner: CreateFileLinkBuilder,
194}
195impl CreateFileLink {
196 pub fn new(file: impl Into<String>) -> Self {
198 Self { inner: CreateFileLinkBuilder::new(file.into()) }
199 }
200 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
202 self.inner.expand = Some(expand.into());
203 self
204 }
205 pub fn expires_at(mut self, expires_at: impl Into<stripe_types::Timestamp>) -> Self {
207 self.inner.expires_at = Some(expires_at.into());
208 self
209 }
210 pub fn metadata(
215 mut self,
216 metadata: impl Into<std::collections::HashMap<String, String>>,
217 ) -> Self {
218 self.inner.metadata = Some(metadata.into());
219 self
220 }
221}
222impl CreateFileLink {
223 pub async fn send<C: StripeClient>(
225 &self,
226 client: &C,
227 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
228 self.customize().send(client).await
229 }
230
231 pub fn send_blocking<C: StripeBlockingClient>(
233 &self,
234 client: &C,
235 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
236 self.customize().send_blocking(client)
237 }
238}
239
240impl StripeRequest for CreateFileLink {
241 type Output = stripe_shared::FileLink;
242
243 fn build(&self) -> RequestBuilder {
244 RequestBuilder::new(StripeMethod::Post, "/file_links").form(&self.inner)
245 }
246}
247#[derive(Clone, Debug, serde::Serialize)]
248struct UpdateFileLinkBuilder {
249 #[serde(skip_serializing_if = "Option::is_none")]
250 expand: Option<Vec<String>>,
251 #[serde(skip_serializing_if = "Option::is_none")]
252 expires_at: Option<UpdateFileLinkExpiresAt>,
253 #[serde(skip_serializing_if = "Option::is_none")]
254 metadata: Option<std::collections::HashMap<String, String>>,
255}
256impl UpdateFileLinkBuilder {
257 fn new() -> Self {
258 Self { expand: None, expires_at: None, metadata: None }
259 }
260}
261#[derive(Copy, Clone, Debug, serde::Serialize)]
263#[serde(rename_all = "snake_case")]
264pub enum UpdateFileLinkExpiresAt {
265 Now,
266 #[serde(untagged)]
267 Timestamp(stripe_types::Timestamp),
268}
269#[derive(Clone, Debug, serde::Serialize)]
271pub struct UpdateFileLink {
272 inner: UpdateFileLinkBuilder,
273 link: stripe_shared::FileLinkId,
274}
275impl UpdateFileLink {
276 pub fn new(link: impl Into<stripe_shared::FileLinkId>) -> Self {
278 Self { link: link.into(), inner: UpdateFileLinkBuilder::new() }
279 }
280 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
282 self.inner.expand = Some(expand.into());
283 self
284 }
285 pub fn expires_at(mut self, expires_at: impl Into<UpdateFileLinkExpiresAt>) -> Self {
287 self.inner.expires_at = Some(expires_at.into());
288 self
289 }
290 pub fn metadata(
295 mut self,
296 metadata: impl Into<std::collections::HashMap<String, String>>,
297 ) -> Self {
298 self.inner.metadata = Some(metadata.into());
299 self
300 }
301}
302impl UpdateFileLink {
303 pub async fn send<C: StripeClient>(
305 &self,
306 client: &C,
307 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
308 self.customize().send(client).await
309 }
310
311 pub fn send_blocking<C: StripeBlockingClient>(
313 &self,
314 client: &C,
315 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
316 self.customize().send_blocking(client)
317 }
318}
319
320impl StripeRequest for UpdateFileLink {
321 type Output = stripe_shared::FileLink;
322
323 fn build(&self) -> RequestBuilder {
324 let link = &self.link;
325 RequestBuilder::new(StripeMethod::Post, format!("/file_links/{link}")).form(&self.inner)
326 }
327}