stripe_core/file/
requests.rs1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListFileBuilder {
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 limit: Option<i64>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 purpose: Option<stripe_shared::FilePurpose>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 starting_after: Option<String>,
19}
20impl ListFileBuilder {
21 fn new() -> Self {
22 Self {
23 created: None,
24 ending_before: None,
25 expand: None,
26 limit: None,
27 purpose: None,
28 starting_after: None,
29 }
30 }
31}
32#[derive(Clone, Debug, serde::Serialize)]
35pub struct ListFile {
36 inner: ListFileBuilder,
37}
38impl ListFile {
39 pub fn new() -> Self {
41 Self { inner: ListFileBuilder::new() }
42 }
43 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
45 self.inner.created = Some(created.into());
46 self
47 }
48 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
52 self.inner.ending_before = Some(ending_before.into());
53 self
54 }
55 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
57 self.inner.expand = Some(expand.into());
58 self
59 }
60 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
63 self.inner.limit = Some(limit.into());
64 self
65 }
66 pub fn purpose(mut self, purpose: impl Into<stripe_shared::FilePurpose>) -> Self {
69 self.inner.purpose = Some(purpose.into());
70 self
71 }
72 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
76 self.inner.starting_after = Some(starting_after.into());
77 self
78 }
79}
80impl Default for ListFile {
81 fn default() -> Self {
82 Self::new()
83 }
84}
85impl ListFile {
86 pub async fn send<C: StripeClient>(
88 &self,
89 client: &C,
90 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
91 self.customize().send(client).await
92 }
93
94 pub fn send_blocking<C: StripeBlockingClient>(
96 &self,
97 client: &C,
98 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
99 self.customize().send_blocking(client)
100 }
101
102 pub fn paginate(
103 &self,
104 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::File>> {
105 stripe_client_core::ListPaginator::new_list("/files", &self.inner)
106 }
107}
108
109impl StripeRequest for ListFile {
110 type Output = stripe_types::List<stripe_shared::File>;
111
112 fn build(&self) -> RequestBuilder {
113 RequestBuilder::new(StripeMethod::Get, "/files").query(&self.inner)
114 }
115}
116#[derive(Clone, Debug, serde::Serialize)]
117struct RetrieveFileBuilder {
118 #[serde(skip_serializing_if = "Option::is_none")]
119 expand: Option<Vec<String>>,
120}
121impl RetrieveFileBuilder {
122 fn new() -> Self {
123 Self { expand: None }
124 }
125}
126#[derive(Clone, Debug, serde::Serialize)]
130pub struct RetrieveFile {
131 inner: RetrieveFileBuilder,
132 file: stripe_shared::FileId,
133}
134impl RetrieveFile {
135 pub fn new(file: impl Into<stripe_shared::FileId>) -> Self {
137 Self { file: file.into(), inner: RetrieveFileBuilder::new() }
138 }
139 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
141 self.inner.expand = Some(expand.into());
142 self
143 }
144}
145impl RetrieveFile {
146 pub async fn send<C: StripeClient>(
148 &self,
149 client: &C,
150 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
151 self.customize().send(client).await
152 }
153
154 pub fn send_blocking<C: StripeBlockingClient>(
156 &self,
157 client: &C,
158 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
159 self.customize().send_blocking(client)
160 }
161}
162
163impl StripeRequest for RetrieveFile {
164 type Output = stripe_shared::File;
165
166 fn build(&self) -> RequestBuilder {
167 let file = &self.file;
168 RequestBuilder::new(StripeMethod::Get, format!("/files/{file}")).query(&self.inner)
169 }
170}