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 GetCreditNotesPreviewLinesRequest {
pub amount: Option<i64>,
pub credit_amount: Option<i64>,
pub effective_at: Option<i64>,
pub ending_before: Option<String>,
pub expand: Option<Vec<String>>,
pub invoice: String,
pub limit: Option<i64>,
pub lines: Option<Vec<CreditNoteLineItemParams>>,
pub memo: Option<String>,
pub metadata: Option<serde_json::Value>,
pub out_of_band_amount: Option<i64>,
pub reason: Option<String>,
pub refund: Option<String>,
pub refund_amount: Option<i64>,
pub shipping_cost: Option<CreditNoteShippingCost>,
pub starting_after: Option<String>,
}
impl GetCreditNotesPreviewLinesRequest {}
impl FluentRequest<'_, GetCreditNotesPreviewLinesRequest> {
pub fn amount(mut self, amount: i64) -> Self {
self.params.amount = Some(amount);
self
}
pub fn credit_amount(mut self, credit_amount: i64) -> Self {
self.params.credit_amount = Some(credit_amount);
self
}
pub fn effective_at(mut self, effective_at: i64) -> Self {
self.params.effective_at = Some(effective_at);
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 lines(mut self, lines: Vec<CreditNoteLineItemParams>) -> Self {
self.params.lines = Some(lines);
self
}
pub fn memo(mut self, memo: &str) -> Self {
self.params.memo = Some(memo.to_owned());
self
}
pub fn metadata(mut self, metadata: serde_json::Value) -> Self {
self.params.metadata = Some(metadata);
self
}
pub fn out_of_band_amount(mut self, out_of_band_amount: i64) -> Self {
self.params.out_of_band_amount = Some(out_of_band_amount);
self
}
pub fn reason(mut self, reason: &str) -> Self {
self.params.reason = Some(reason.to_owned());
self
}
pub fn refund(mut self, refund: &str) -> Self {
self.params.refund = Some(refund.to_owned());
self
}
pub fn refund_amount(mut self, refund_amount: i64) -> Self {
self.params.refund_amount = Some(refund_amount);
self
}
pub fn shipping_cost(mut self, shipping_cost: CreditNoteShippingCost) -> Self {
self.params.shipping_cost = Some(shipping_cost);
self
}
pub fn starting_after(mut self, starting_after: &str) -> Self {
self.params.starting_after = Some(starting_after.to_owned());
self
}
}
impl<'a> ::std::future::IntoFuture
for FluentRequest<'a, GetCreditNotesPreviewLinesRequest> {
type Output = httpclient::InMemoryResult<CreditNoteLinesList>;
type IntoFuture = ::futures::future::BoxFuture<'a, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async {
let url = "/v1/credit_notes/preview/lines";
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)
})
}
}