stripe_misc/entitlements_feature/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListEntitlementsFeatureBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    archived: Option<bool>,
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    lookup_key: Option<String>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    starting_after: Option<String>,
19}
20impl ListEntitlementsFeatureBuilder {
21    fn new() -> Self {
22        Self {
23            archived: None,
24            ending_before: None,
25            expand: None,
26            limit: None,
27            lookup_key: None,
28            starting_after: None,
29        }
30    }
31}
32/// Retrieve a list of features
33#[derive(Clone, Debug, serde::Serialize)]
34pub struct ListEntitlementsFeature {
35    inner: ListEntitlementsFeatureBuilder,
36}
37impl ListEntitlementsFeature {
38    /// Construct a new `ListEntitlementsFeature`.
39    pub fn new() -> Self {
40        Self { inner: ListEntitlementsFeatureBuilder::new() }
41    }
42    /// If set, filter results to only include features with the given archive status.
43    pub fn archived(mut self, archived: impl Into<bool>) -> Self {
44        self.inner.archived = Some(archived.into());
45        self
46    }
47    /// A cursor for use in pagination.
48    /// `ending_before` is an object ID that defines your place in the list.
49    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
50    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
51        self.inner.ending_before = Some(ending_before.into());
52        self
53    }
54    /// Specifies which fields in the response should be expanded.
55    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
56        self.inner.expand = Some(expand.into());
57        self
58    }
59    /// A limit on the number of objects to be returned.
60    /// Limit can range between 1 and 100, and the default is 10.
61    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
62        self.inner.limit = Some(limit.into());
63        self
64    }
65    /// If set, filter results to only include features with the given lookup_key.
66    pub fn lookup_key(mut self, lookup_key: impl Into<String>) -> Self {
67        self.inner.lookup_key = Some(lookup_key.into());
68        self
69    }
70    /// A cursor for use in pagination.
71    /// `starting_after` is an object ID that defines your place in the list.
72    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
73    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
74        self.inner.starting_after = Some(starting_after.into());
75        self
76    }
77}
78impl Default for ListEntitlementsFeature {
79    fn default() -> Self {
80        Self::new()
81    }
82}
83impl ListEntitlementsFeature {
84    /// Send the request and return the deserialized response.
85    pub async fn send<C: StripeClient>(
86        &self,
87        client: &C,
88    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
89        self.customize().send(client).await
90    }
91
92    /// Send the request and return the deserialized response, blocking until completion.
93    pub fn send_blocking<C: StripeBlockingClient>(
94        &self,
95        client: &C,
96    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
97        self.customize().send_blocking(client)
98    }
99
100    pub fn paginate(
101        &self,
102    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::EntitlementsFeature>>
103    {
104        stripe_client_core::ListPaginator::new_list("/entitlements/features", &self.inner)
105    }
106}
107
108impl StripeRequest for ListEntitlementsFeature {
109    type Output = stripe_types::List<stripe_shared::EntitlementsFeature>;
110
111    fn build(&self) -> RequestBuilder {
112        RequestBuilder::new(StripeMethod::Get, "/entitlements/features").query(&self.inner)
113    }
114}
115#[derive(Clone, Debug, serde::Serialize)]
116struct RetrieveEntitlementsFeatureBuilder {
117    #[serde(skip_serializing_if = "Option::is_none")]
118    expand: Option<Vec<String>>,
119}
120impl RetrieveEntitlementsFeatureBuilder {
121    fn new() -> Self {
122        Self { expand: None }
123    }
124}
125/// Retrieves a feature
126#[derive(Clone, Debug, serde::Serialize)]
127pub struct RetrieveEntitlementsFeature {
128    inner: RetrieveEntitlementsFeatureBuilder,
129    id: stripe_shared::EntitlementsFeatureId,
130}
131impl RetrieveEntitlementsFeature {
132    /// Construct a new `RetrieveEntitlementsFeature`.
133    pub fn new(id: impl Into<stripe_shared::EntitlementsFeatureId>) -> Self {
134        Self { id: id.into(), inner: RetrieveEntitlementsFeatureBuilder::new() }
135    }
136    /// Specifies which fields in the response should be expanded.
137    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
138        self.inner.expand = Some(expand.into());
139        self
140    }
141}
142impl RetrieveEntitlementsFeature {
143    /// Send the request and return the deserialized response.
144    pub async fn send<C: StripeClient>(
145        &self,
146        client: &C,
147    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
148        self.customize().send(client).await
149    }
150
151    /// Send the request and return the deserialized response, blocking until completion.
152    pub fn send_blocking<C: StripeBlockingClient>(
153        &self,
154        client: &C,
155    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
156        self.customize().send_blocking(client)
157    }
158}
159
160impl StripeRequest for RetrieveEntitlementsFeature {
161    type Output = stripe_shared::EntitlementsFeature;
162
163    fn build(&self) -> RequestBuilder {
164        let id = &self.id;
165        RequestBuilder::new(StripeMethod::Get, format!("/entitlements/features/{id}"))
166            .query(&self.inner)
167    }
168}
169#[derive(Clone, Debug, serde::Serialize)]
170struct CreateEntitlementsFeatureBuilder {
171    #[serde(skip_serializing_if = "Option::is_none")]
172    expand: Option<Vec<String>>,
173    lookup_key: String,
174    #[serde(skip_serializing_if = "Option::is_none")]
175    metadata: Option<std::collections::HashMap<String, String>>,
176    name: String,
177}
178impl CreateEntitlementsFeatureBuilder {
179    fn new(lookup_key: impl Into<String>, name: impl Into<String>) -> Self {
180        Self { expand: None, lookup_key: lookup_key.into(), metadata: None, name: name.into() }
181    }
182}
183/// Creates a feature
184#[derive(Clone, Debug, serde::Serialize)]
185pub struct CreateEntitlementsFeature {
186    inner: CreateEntitlementsFeatureBuilder,
187}
188impl CreateEntitlementsFeature {
189    /// Construct a new `CreateEntitlementsFeature`.
190    pub fn new(lookup_key: impl Into<String>, name: impl Into<String>) -> Self {
191        Self { inner: CreateEntitlementsFeatureBuilder::new(lookup_key.into(), name.into()) }
192    }
193    /// Specifies which fields in the response should be expanded.
194    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
195        self.inner.expand = Some(expand.into());
196        self
197    }
198    /// Set of key-value pairs that you can attach to an object.
199    /// This can be useful for storing additional information about the object in a structured format.
200    pub fn metadata(
201        mut self,
202        metadata: impl Into<std::collections::HashMap<String, String>>,
203    ) -> Self {
204        self.inner.metadata = Some(metadata.into());
205        self
206    }
207}
208impl CreateEntitlementsFeature {
209    /// Send the request and return the deserialized response.
210    pub async fn send<C: StripeClient>(
211        &self,
212        client: &C,
213    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
214        self.customize().send(client).await
215    }
216
217    /// Send the request and return the deserialized response, blocking until completion.
218    pub fn send_blocking<C: StripeBlockingClient>(
219        &self,
220        client: &C,
221    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
222        self.customize().send_blocking(client)
223    }
224}
225
226impl StripeRequest for CreateEntitlementsFeature {
227    type Output = stripe_shared::EntitlementsFeature;
228
229    fn build(&self) -> RequestBuilder {
230        RequestBuilder::new(StripeMethod::Post, "/entitlements/features").form(&self.inner)
231    }
232}
233#[derive(Clone, Debug, serde::Serialize)]
234struct UpdateEntitlementsFeatureBuilder {
235    #[serde(skip_serializing_if = "Option::is_none")]
236    active: Option<bool>,
237    #[serde(skip_serializing_if = "Option::is_none")]
238    expand: Option<Vec<String>>,
239    #[serde(skip_serializing_if = "Option::is_none")]
240    metadata: Option<std::collections::HashMap<String, String>>,
241    #[serde(skip_serializing_if = "Option::is_none")]
242    name: Option<String>,
243}
244impl UpdateEntitlementsFeatureBuilder {
245    fn new() -> Self {
246        Self { active: None, expand: None, metadata: None, name: None }
247    }
248}
249/// Update a feature’s metadata or permanently deactivate it.
250#[derive(Clone, Debug, serde::Serialize)]
251pub struct UpdateEntitlementsFeature {
252    inner: UpdateEntitlementsFeatureBuilder,
253    id: stripe_shared::EntitlementsFeatureId,
254}
255impl UpdateEntitlementsFeature {
256    /// Construct a new `UpdateEntitlementsFeature`.
257    pub fn new(id: impl Into<stripe_shared::EntitlementsFeatureId>) -> Self {
258        Self { id: id.into(), inner: UpdateEntitlementsFeatureBuilder::new() }
259    }
260    /// Inactive features cannot be attached to new products and will not be returned from the features list endpoint.
261    pub fn active(mut self, active: impl Into<bool>) -> Self {
262        self.inner.active = Some(active.into());
263        self
264    }
265    /// Specifies which fields in the response should be expanded.
266    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
267        self.inner.expand = Some(expand.into());
268        self
269    }
270    /// Set of key-value pairs that you can attach to an object.
271    /// This can be useful for storing additional information about the object in a structured format.
272    pub fn metadata(
273        mut self,
274        metadata: impl Into<std::collections::HashMap<String, String>>,
275    ) -> Self {
276        self.inner.metadata = Some(metadata.into());
277        self
278    }
279    /// The feature's name, for your own purpose, not meant to be displayable to the customer.
280    pub fn name(mut self, name: impl Into<String>) -> Self {
281        self.inner.name = Some(name.into());
282        self
283    }
284}
285impl UpdateEntitlementsFeature {
286    /// Send the request and return the deserialized response.
287    pub async fn send<C: StripeClient>(
288        &self,
289        client: &C,
290    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
291        self.customize().send(client).await
292    }
293
294    /// Send the request and return the deserialized response, blocking until completion.
295    pub fn send_blocking<C: StripeBlockingClient>(
296        &self,
297        client: &C,
298    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
299        self.customize().send_blocking(client)
300    }
301}
302
303impl StripeRequest for UpdateEntitlementsFeature {
304    type Output = stripe_shared::EntitlementsFeature;
305
306    fn build(&self) -> RequestBuilder {
307        let id = &self.id;
308        RequestBuilder::new(StripeMethod::Post, format!("/entitlements/features/{id}"))
309            .form(&self.inner)
310    }
311}