stripe/resources/generated/
review.rs1use crate::client::{Client, Response};
6use crate::ids::ReviewId;
7use crate::params::{Expand, Expandable, List, Object, Paginable, RangeQuery, Timestamp};
8use crate::resources::{Charge, PaymentIntent, ReviewReason};
9use serde::{Deserialize, Serialize};
10
11#[derive(Clone, Debug, Default, Deserialize, Serialize)]
15pub struct Review {
16 pub id: ReviewId,
18
19 pub billing_zip: Option<String>,
21
22 pub charge: Option<Expandable<Charge>>,
24
25 pub closed_reason: Option<ReviewClosedReason>,
29
30 pub created: Timestamp,
34
35 pub ip_address: Option<String>,
37
38 pub ip_address_location: Option<RadarReviewResourceLocation>,
42
43 pub livemode: bool,
45
46 pub open: bool,
48
49 pub opened_reason: ReviewOpenedReason,
53
54 #[serde(skip_serializing_if = "Option::is_none")]
56 pub payment_intent: Option<Expandable<PaymentIntent>>,
57
58 pub reason: ReviewReason,
62
63 pub session: Option<RadarReviewResourceSession>,
65}
66
67impl Review {
68 pub fn list(client: &Client, params: &ListReviews<'_>) -> Response<List<Review>> {
72 client.get_query("/reviews", params)
73 }
74
75 pub fn retrieve(client: &Client, id: &ReviewId, expand: &[&str]) -> Response<Review> {
77 client.get_query(&format!("/reviews/{}", id), Expand { expand })
78 }
79}
80
81impl Object for Review {
82 type Id = ReviewId;
83 fn id(&self) -> Self::Id {
84 self.id.clone()
85 }
86 fn object(&self) -> &'static str {
87 "review"
88 }
89}
90
91#[derive(Clone, Debug, Default, Deserialize, Serialize)]
92pub struct RadarReviewResourceLocation {
93 pub city: Option<String>,
95
96 pub country: Option<String>,
98
99 pub latitude: Option<f64>,
101
102 pub longitude: Option<f64>,
104
105 pub region: Option<String>,
107}
108
109#[derive(Clone, Debug, Default, Deserialize, Serialize)]
110pub struct RadarReviewResourceSession {
111 pub browser: Option<String>,
113
114 pub device: Option<String>,
116
117 pub platform: Option<String>,
119
120 pub version: Option<String>,
122}
123
124#[derive(Clone, Debug, Serialize, Default)]
126pub struct ListReviews<'a> {
127 #[serde(skip_serializing_if = "Option::is_none")]
128 pub created: Option<RangeQuery<Timestamp>>,
129
130 #[serde(skip_serializing_if = "Option::is_none")]
135 pub ending_before: Option<ReviewId>,
136
137 #[serde(skip_serializing_if = "Expand::is_empty")]
139 pub expand: &'a [&'a str],
140
141 #[serde(skip_serializing_if = "Option::is_none")]
145 pub limit: Option<u64>,
146
147 #[serde(skip_serializing_if = "Option::is_none")]
152 pub starting_after: Option<ReviewId>,
153}
154
155impl<'a> ListReviews<'a> {
156 pub fn new() -> Self {
157 ListReviews {
158 created: Default::default(),
159 ending_before: Default::default(),
160 expand: Default::default(),
161 limit: Default::default(),
162 starting_after: Default::default(),
163 }
164 }
165}
166impl Paginable for ListReviews<'_> {
167 type O = Review;
168 fn set_last(&mut self, item: Self::O) {
169 self.starting_after = Some(item.id());
170 }
171}
172#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
174#[serde(rename_all = "snake_case")]
175pub enum ReviewClosedReason {
176 Approved,
177 Disputed,
178 Redacted,
179 Refunded,
180 RefundedAsFraud,
181}
182
183impl ReviewClosedReason {
184 pub fn as_str(self) -> &'static str {
185 match self {
186 ReviewClosedReason::Approved => "approved",
187 ReviewClosedReason::Disputed => "disputed",
188 ReviewClosedReason::Redacted => "redacted",
189 ReviewClosedReason::Refunded => "refunded",
190 ReviewClosedReason::RefundedAsFraud => "refunded_as_fraud",
191 }
192 }
193}
194
195impl AsRef<str> for ReviewClosedReason {
196 fn as_ref(&self) -> &str {
197 self.as_str()
198 }
199}
200
201impl std::fmt::Display for ReviewClosedReason {
202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
203 self.as_str().fmt(f)
204 }
205}
206impl std::default::Default for ReviewClosedReason {
207 fn default() -> Self {
208 Self::Approved
209 }
210}
211
212#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
214#[serde(rename_all = "snake_case")]
215pub enum ReviewOpenedReason {
216 Manual,
217 Rule,
218}
219
220impl ReviewOpenedReason {
221 pub fn as_str(self) -> &'static str {
222 match self {
223 ReviewOpenedReason::Manual => "manual",
224 ReviewOpenedReason::Rule => "rule",
225 }
226 }
227}
228
229impl AsRef<str> for ReviewOpenedReason {
230 fn as_ref(&self) -> &str {
231 self.as_str()
232 }
233}
234
235impl std::fmt::Display for ReviewOpenedReason {
236 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
237 self.as_str().fmt(f)
238 }
239}
240impl std::default::Default for ReviewOpenedReason {
241 fn default() -> Self {
242 Self::Manual
243 }
244}