#[allow(unused_imports)]
use crate::{error::Result, models::*, Configuration};
#[derive(Default)]
pub struct CreditNotesListCreditNotesOptions {
pub customer_id: Option<CustomerId>,
pub invoice_id: Option<InvoiceId>,
pub status: Option<CreditNoteStatus>,
pub search: Option<String>,
pub order_by: Option<String>,
pub page: Option<i32>,
pub per_page: Option<i32>,
}
pub struct CreditNotes<'a> {
cfg: &'a Configuration,
}
impl<'a> CreditNotes<'a> {
pub(super) fn new(cfg: &'a Configuration) -> Self {
Self { cfg }
}
pub async fn list_credit_notes(
&self,
options: Option<CreditNotesListCreditNotesOptions>,
) -> Result<crate::models::CreditNoteListResponse> {
let CreditNotesListCreditNotesOptions {
customer_id,
invoice_id,
status,
search,
order_by,
page,
per_page,
} = options.unwrap_or_default();
crate::request::Request::new(http1::Method::GET, "/api/v1/credit-notes")
.with_optional_query_param("customer_id", customer_id)
.with_optional_query_param("invoice_id", invoice_id)
.with_optional_query_param("status", status)
.with_optional_query_param("search", search)
.with_optional_query_param("order_by", order_by)
.with_optional_query_param("page", page)
.with_optional_query_param("per_page", per_page)
.execute(self.cfg)
.await
}
pub async fn get_credit_note_by_id(
&self,
credit_note_id: String,
) -> Result<crate::models::CreditNote> {
crate::request::Request::new(http1::Method::GET, "/api/v1/credit-notes/{credit_note_id}")
.with_path_param("credit_note_id", credit_note_id)
.execute(self.cfg)
.await
}
pub async fn patch_credit_note_custom_properties(
&self,
credit_note_id: String,
credit_note_custom_properties_request: crate::models::CreditNoteCustomPropertiesRequest,
) -> Result<crate::models::CreditNote> {
crate::request::Request::new(
http1::Method::PATCH,
"/api/v1/credit-notes/{credit_note_id}/custom-properties",
)
.with_path_param("credit_note_id", credit_note_id)
.with_body_param(credit_note_custom_properties_request)
.execute(self.cfg)
.await
}
pub async fn download_credit_note_pdf(&self, credit_note_id: String) -> Result<bytes::Bytes> {
crate::request::Request::new(
http1::Method::GET,
"/api/v1/credit-notes/{credit_note_id}/download",
)
.with_path_param("credit_note_id", credit_note_id)
.execute_binary(self.cfg)
.await
}
}