stripe/resources/generated/application_fee.rs
1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::client::{Client, Response};
6use crate::ids::{ApplicationFeeId, ChargeId};
7use crate::params::{Expand, Expandable, List, Object, Paginable, RangeQuery, Timestamp};
8use crate::resources::{
9 Account, Application, ApplicationFeeRefund, BalanceTransaction, Charge, Currency,
10};
11use serde::{Deserialize, Serialize};
12
13/// The resource representing a Stripe "PlatformFee".
14///
15/// For more details see <https://stripe.com/docs/api/application_fees/object>
16#[derive(Clone, Debug, Default, Deserialize, Serialize)]
17pub struct ApplicationFee {
18 /// Unique identifier for the object.
19 pub id: ApplicationFeeId,
20
21 /// ID of the Stripe account this fee was taken from.
22 pub account: Expandable<Account>,
23
24 /// Amount earned, in cents (or local equivalent).
25 pub amount: i64,
26
27 /// Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued).
28 pub amount_refunded: i64,
29
30 /// ID of the Connect application that earned the fee.
31 pub application: Expandable<Application>,
32
33 /// Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
34 pub balance_transaction: Option<Expandable<BalanceTransaction>>,
35
36 /// ID of the charge that the application fee was taken from.
37 pub charge: Expandable<Charge>,
38
39 /// Time at which the object was created.
40 ///
41 /// Measured in seconds since the Unix epoch.
42 pub created: Timestamp,
43
44 /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
45 ///
46 /// Must be a [supported currency](https://stripe.com/docs/currencies).
47 pub currency: Currency,
48
49 /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
50 pub livemode: bool,
51
52 /// ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter.
53 pub originating_transaction: Option<Expandable<Charge>>,
54
55 /// Whether the fee has been fully refunded.
56 ///
57 /// If the fee is only partially refunded, this attribute will still be false.
58 pub refunded: bool,
59
60 /// A list of refunds that have been applied to the fee.
61 pub refunds: List<ApplicationFeeRefund>,
62}
63
64impl ApplicationFee {
65 /// Returns a list of application fees you’ve previously collected.
66 ///
67 /// The application fees are returned in sorted order, with the most recent fees appearing first.
68 pub fn list(
69 client: &Client,
70 params: &ListApplicationFees<'_>,
71 ) -> Response<List<ApplicationFee>> {
72 client.get_query("/application_fees", params)
73 }
74
75 /// Retrieves the details of an application fee that your account has collected.
76 ///
77 /// The same information is returned when refunding the application fee.
78 pub fn retrieve(
79 client: &Client,
80 id: &ApplicationFeeId,
81 expand: &[&str],
82 ) -> Response<ApplicationFee> {
83 client.get_query(&format!("/application_fees/{}", id), Expand { expand })
84 }
85}
86
87impl Object for ApplicationFee {
88 type Id = ApplicationFeeId;
89 fn id(&self) -> Self::Id {
90 self.id.clone()
91 }
92 fn object(&self) -> &'static str {
93 "application_fee"
94 }
95}
96
97/// The parameters for `ApplicationFee::list`.
98#[derive(Clone, Debug, Serialize, Default)]
99pub struct ListApplicationFees<'a> {
100 /// Only return application fees for the charge specified by this charge ID.
101 #[serde(skip_serializing_if = "Option::is_none")]
102 pub charge: Option<ChargeId>,
103
104 #[serde(skip_serializing_if = "Option::is_none")]
105 pub created: Option<RangeQuery<Timestamp>>,
106
107 /// A cursor for use in pagination.
108 ///
109 /// `ending_before` is an object ID that defines your place in the list.
110 /// 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.
111 #[serde(skip_serializing_if = "Option::is_none")]
112 pub ending_before: Option<ApplicationFeeId>,
113
114 /// Specifies which fields in the response should be expanded.
115 #[serde(skip_serializing_if = "Expand::is_empty")]
116 pub expand: &'a [&'a str],
117
118 /// A limit on the number of objects to be returned.
119 ///
120 /// Limit can range between 1 and 100, and the default is 10.
121 #[serde(skip_serializing_if = "Option::is_none")]
122 pub limit: Option<u64>,
123
124 /// A cursor for use in pagination.
125 ///
126 /// `starting_after` is an object ID that defines your place in the list.
127 /// 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.
128 #[serde(skip_serializing_if = "Option::is_none")]
129 pub starting_after: Option<ApplicationFeeId>,
130}
131
132impl<'a> ListApplicationFees<'a> {
133 pub fn new() -> Self {
134 ListApplicationFees {
135 charge: Default::default(),
136 created: Default::default(),
137 ending_before: Default::default(),
138 expand: Default::default(),
139 limit: Default::default(),
140 starting_after: Default::default(),
141 }
142 }
143}
144impl Paginable for ListApplicationFees<'_> {
145 type O = ApplicationFee;
146 fn set_last(&mut self, item: Self::O) {
147 self.starting_after = Some(item.id());
148 }
149}