use serde_json::json;
use crate::model::*;
use crate::FluentRequest;
use serde::{Serialize, Deserialize};
use httpclient::InMemoryResponseExt;
use crate::StripeClient;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetCheckoutSessionsRequest {
pub customer: Option<String>,
pub customer_details: Option<CustomerDetailsParams>,
pub ending_before: Option<String>,
pub expand: Option<Vec<String>>,
pub limit: Option<i64>,
pub payment_intent: Option<String>,
pub payment_link: Option<String>,
pub starting_after: Option<String>,
pub status: Option<String>,
pub subscription: Option<String>,
}
impl GetCheckoutSessionsRequest {}
impl FluentRequest<'_, GetCheckoutSessionsRequest> {
pub fn customer(mut self, customer: &str) -> Self {
self.params.customer = Some(customer.to_owned());
self
}
pub fn customer_details(mut self, customer_details: CustomerDetailsParams) -> Self {
self.params.customer_details = Some(customer_details);
self
}
pub fn ending_before(mut self, ending_before: &str) -> Self {
self.params.ending_before = Some(ending_before.to_owned());
self
}
pub fn expand(mut self, expand: impl IntoIterator<Item = impl AsRef<str>>) -> Self {
self
.params
.expand = Some(expand.into_iter().map(|s| s.as_ref().to_owned()).collect());
self
}
pub fn limit(mut self, limit: i64) -> Self {
self.params.limit = Some(limit);
self
}
pub fn payment_intent(mut self, payment_intent: &str) -> Self {
self.params.payment_intent = Some(payment_intent.to_owned());
self
}
pub fn payment_link(mut self, payment_link: &str) -> Self {
self.params.payment_link = Some(payment_link.to_owned());
self
}
pub fn starting_after(mut self, starting_after: &str) -> Self {
self.params.starting_after = Some(starting_after.to_owned());
self
}
pub fn status(mut self, status: &str) -> Self {
self.params.status = Some(status.to_owned());
self
}
pub fn subscription(mut self, subscription: &str) -> Self {
self.params.subscription = Some(subscription.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture for FluentRequest<'a, GetCheckoutSessionsRequest> {
type Output = httpclient::InMemoryResult<PaymentPagesCheckoutSessionList>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async {
let url = "/v1/checkout/sessions";
let mut r = self.client.client.get(url);
r = r.set_query(self.params);
r = self.client.authenticate(r);
let res = r.await?;
res.json().map_err(Into::into)
})
}
}