#![allow(clippy::too_many_arguments)]
use crate::client::Ghl;
use crate::error::Result;
use ghl_models::v2::invoices as models;
#[derive(Debug, Clone)]
pub struct InvoicesService {
pub(crate) client: Ghl,
}
impl InvoicesService {
pub(crate) fn new(client: Ghl) -> Self {
Self { client }
}
}
#[derive(Debug, Clone, Default)]
pub struct ListInvoicesParams {
pub alt_id: String,
pub alt_type: String,
pub status: Option<String>,
pub start_at: Option<String>,
pub end_at: Option<String>,
pub search: Option<String>,
pub payment_mode: Option<String>,
pub contact_id: Option<String>,
pub limit: String,
pub offset: String,
pub sort_field: Option<String>,
pub sort_order: Option<String>,
}
impl ListInvoicesParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
limit: impl Into<String>,
offset: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
limit: limit.into(),
offset: offset.into(),
..Default::default()
}
}
pub fn status(mut self, v: impl Into<String>) -> Self {
self.status = Some(v.into());
self
}
pub fn start_at(mut self, v: impl Into<String>) -> Self {
self.start_at = Some(v.into());
self
}
pub fn end_at(mut self, v: impl Into<String>) -> Self {
self.end_at = Some(v.into());
self
}
pub fn search(mut self, v: impl Into<String>) -> Self {
self.search = Some(v.into());
self
}
pub fn payment_mode(mut self, v: impl Into<String>) -> Self {
self.payment_mode = Some(v.into());
self
}
pub fn contact_id(mut self, v: impl Into<String>) -> Self {
self.contact_id = Some(v.into());
self
}
pub fn sort_field(mut self, v: impl Into<String>) -> Self {
self.sort_field = Some(v.into());
self
}
pub fn sort_order(mut self, v: impl Into<String>) -> Self {
self.sort_order = Some(v.into());
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("limit".into(), self.limit.clone()),
("offset".into(), self.offset.clone()),
];
if let Some(v) = &self.status {
q.push(("status".into(), v.to_string()));
}
if let Some(v) = &self.start_at {
q.push(("startAt".into(), v.to_string()));
}
if let Some(v) = &self.end_at {
q.push(("endAt".into(), v.to_string()));
}
if let Some(v) = &self.search {
q.push(("search".into(), v.to_string()));
}
if let Some(v) = &self.payment_mode {
q.push(("paymentMode".into(), v.to_string()));
}
if let Some(v) = &self.contact_id {
q.push(("contactId".into(), v.to_string()));
}
if let Some(v) = &self.sort_field {
q.push(("sortField".into(), v.to_string()));
}
if let Some(v) = &self.sort_order {
q.push(("sortOrder".into(), v.to_string()));
}
q
}
}
#[derive(Debug, Clone, Default)]
pub struct ListEstimatesParams {
pub alt_id: String,
pub alt_type: String,
pub start_at: Option<String>,
pub end_at: Option<String>,
pub search: Option<String>,
pub status: Option<String>,
pub contact_id: Option<String>,
pub limit: String,
pub offset: String,
}
impl ListEstimatesParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
limit: impl Into<String>,
offset: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
limit: limit.into(),
offset: offset.into(),
..Default::default()
}
}
pub fn start_at(mut self, v: impl Into<String>) -> Self {
self.start_at = Some(v.into());
self
}
pub fn end_at(mut self, v: impl Into<String>) -> Self {
self.end_at = Some(v.into());
self
}
pub fn search(mut self, v: impl Into<String>) -> Self {
self.search = Some(v.into());
self
}
pub fn status(mut self, v: impl Into<String>) -> Self {
self.status = Some(v.into());
self
}
pub fn contact_id(mut self, v: impl Into<String>) -> Self {
self.contact_id = Some(v.into());
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("limit".into(), self.limit.clone()),
("offset".into(), self.offset.clone()),
];
if let Some(v) = &self.start_at {
q.push(("startAt".into(), v.to_string()));
}
if let Some(v) = &self.end_at {
q.push(("endAt".into(), v.to_string()));
}
if let Some(v) = &self.search {
q.push(("search".into(), v.to_string()));
}
if let Some(v) = &self.status {
q.push(("status".into(), v.to_string()));
}
if let Some(v) = &self.contact_id {
q.push(("contactId".into(), v.to_string()));
}
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GenerateEstimateNumberParams {
pub alt_id: String,
pub alt_type: String,
}
impl GenerateEstimateNumberParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct ListEstimateTemplatesParams {
pub alt_id: String,
pub alt_type: String,
pub search: Option<String>,
pub limit: String,
pub offset: String,
}
impl ListEstimateTemplatesParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
limit: impl Into<String>,
offset: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
limit: limit.into(),
offset: offset.into(),
..Default::default()
}
}
pub fn search(mut self, v: impl Into<String>) -> Self {
self.search = Some(v.into());
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("limit".into(), self.limit.clone()),
("offset".into(), self.offset.clone()),
];
if let Some(v) = &self.search {
q.push(("search".into(), v.to_string()));
}
q
}
}
#[derive(Debug, Clone, Default)]
pub struct PreviewEstimateTemplateParams {
pub alt_id: String,
pub alt_type: String,
pub template_id: String,
}
impl PreviewEstimateTemplateParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
template_id: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
template_id: template_id.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("templateId".into(), self.template_id.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GenerateInvoiceNumberParams {
pub alt_id: String,
pub alt_type: String,
}
impl GenerateInvoiceNumberParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct ListSchedulesParams {
pub alt_id: String,
pub alt_type: String,
pub status: Option<String>,
pub start_at: Option<String>,
pub end_at: Option<String>,
pub search: Option<String>,
pub payment_mode: Option<String>,
pub limit: String,
pub offset: String,
}
impl ListSchedulesParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
limit: impl Into<String>,
offset: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
limit: limit.into(),
offset: offset.into(),
..Default::default()
}
}
pub fn status(mut self, v: impl Into<String>) -> Self {
self.status = Some(v.into());
self
}
pub fn start_at(mut self, v: impl Into<String>) -> Self {
self.start_at = Some(v.into());
self
}
pub fn end_at(mut self, v: impl Into<String>) -> Self {
self.end_at = Some(v.into());
self
}
pub fn search(mut self, v: impl Into<String>) -> Self {
self.search = Some(v.into());
self
}
pub fn payment_mode(mut self, v: impl Into<String>) -> Self {
self.payment_mode = Some(v.into());
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("limit".into(), self.limit.clone()),
("offset".into(), self.offset.clone()),
];
if let Some(v) = &self.status {
q.push(("status".into(), v.to_string()));
}
if let Some(v) = &self.start_at {
q.push(("startAt".into(), v.to_string()));
}
if let Some(v) = &self.end_at {
q.push(("endAt".into(), v.to_string()));
}
if let Some(v) = &self.search {
q.push(("search".into(), v.to_string()));
}
if let Some(v) = &self.payment_mode {
q.push(("paymentMode".into(), v.to_string()));
}
q
}
}
#[derive(Debug, Clone, Default)]
pub struct DeleteScheduleParams {
pub alt_id: String,
pub alt_type: String,
}
impl DeleteScheduleParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GetAnScheduleParams {
pub alt_id: String,
pub alt_type: String,
}
impl GetAnScheduleParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GetInvoiceSettingsParams {
pub alt_id: String,
pub alt_type: String,
}
impl GetInvoiceSettingsParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct ListTemplatesParams {
pub alt_id: String,
pub alt_type: String,
pub status: Option<String>,
pub start_at: Option<String>,
pub end_at: Option<String>,
pub search: Option<String>,
pub payment_mode: Option<String>,
pub limit: String,
pub offset: String,
}
impl ListTemplatesParams {
pub fn new(
alt_id: impl Into<String>,
alt_type: impl Into<String>,
limit: impl Into<String>,
offset: impl Into<String>,
) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
limit: limit.into(),
offset: offset.into(),
..Default::default()
}
}
pub fn status(mut self, v: impl Into<String>) -> Self {
self.status = Some(v.into());
self
}
pub fn start_at(mut self, v: impl Into<String>) -> Self {
self.start_at = Some(v.into());
self
}
pub fn end_at(mut self, v: impl Into<String>) -> Self {
self.end_at = Some(v.into());
self
}
pub fn search(mut self, v: impl Into<String>) -> Self {
self.search = Some(v.into());
self
}
pub fn payment_mode(mut self, v: impl Into<String>) -> Self {
self.payment_mode = Some(v.into());
self
}
fn to_query(&self) -> Vec<(String, String)> {
let mut q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
("limit".into(), self.limit.clone()),
("offset".into(), self.offset.clone()),
];
if let Some(v) = &self.status {
q.push(("status".into(), v.to_string()));
}
if let Some(v) = &self.start_at {
q.push(("startAt".into(), v.to_string()));
}
if let Some(v) = &self.end_at {
q.push(("endAt".into(), v.to_string()));
}
if let Some(v) = &self.search {
q.push(("search".into(), v.to_string()));
}
if let Some(v) = &self.payment_mode {
q.push(("paymentMode".into(), v.to_string()));
}
q
}
}
#[derive(Debug, Clone, Default)]
pub struct DeleteTemplateParams {
pub alt_id: String,
pub alt_type: String,
}
impl DeleteTemplateParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GetAnTemplateParams {
pub alt_id: String,
pub alt_type: String,
}
impl GetAnTemplateParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct DeleteInvoiceParams {
pub alt_id: String,
pub alt_type: String,
}
impl DeleteInvoiceParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
#[derive(Debug, Clone, Default)]
pub struct GetInvoiceParams {
pub alt_id: String,
pub alt_type: String,
}
impl GetInvoiceParams {
pub fn new(alt_id: impl Into<String>, alt_type: impl Into<String>) -> Self {
Self {
alt_id: alt_id.into(),
alt_type: alt_type.into(),
}
}
fn to_query(&self) -> Vec<(String, String)> {
let q: Vec<(String, String)> = vec![
("altId".into(), self.alt_id.clone()),
("altType".into(), self.alt_type.clone()),
];
q
}
}
impl InvoicesService {
pub async fn list_invoices(
&self,
params: &ListInvoicesParams,
) -> Result<models::ListInvoicesResponseDto> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn create_invoice(
&self,
body: &models::CreateInvoiceDto,
) -> Result<models::CreateInvoiceResponseDto> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn create_new_estimate(
&self,
body: &models::CreateEstimatesDto,
) -> Result<models::EstimateResponseDto> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/estimate",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn list_estimates(
&self,
params: &ListEstimatesParams,
) -> Result<models::ListEstimatesResponseDTO> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/estimate/list",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn generate_estimate_number(
&self,
params: &GenerateEstimateNumberParams,
) -> Result<models::GenerateEstimateNumberResponse> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/estimate/number/generate",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn update_estimate_last_visited_at(
&self,
body: &models::EstimateIdParam,
) -> Result<serde_json::Value> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PATCH,
"/invoices/estimate/stats/last-visited-at",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn list_estimate_templates(
&self,
params: &ListEstimateTemplatesParams,
) -> Result<models::ListEstimateTemplateResponseDTO> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/estimate/template",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn create_estimate_template(
&self,
body: &models::EstimateTemplatesDto,
) -> Result<models::EstimateTemplateResponseDTO> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/estimate/template",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn preview_estimate_template(
&self,
params: &PreviewEstimateTemplateParams,
) -> Result<models::EstimateTemplateResponseDTO> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/estimate/template/preview",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn delete_estimate_template(
&self,
template_id: &str,
body: &models::AltDto,
) -> Result<models::EstimateTemplateResponseDTO> {
let path = format!(
"/invoices/estimate/template/{}",
crate::services::encode(template_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_estimate_template(
&self,
template_id: &str,
body: &models::EstimateTemplatesDto,
) -> Result<models::EstimateTemplateResponseDTO> {
let path = format!(
"/invoices/estimate/template/{}",
crate::services::encode(template_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PUT,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn delete_estimate(
&self,
estimate_id: &str,
body: &models::AltDto,
) -> Result<models::EstimateResponseDto> {
let path = format!(
"/invoices/estimate/{}",
crate::services::encode(estimate_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_estimate(
&self,
estimate_id: &str,
body: &models::UpdateEstimateDto,
) -> Result<models::EstimateResponseDto> {
let path = format!(
"/invoices/estimate/{}",
crate::services::encode(estimate_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PUT,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn create_invoice_from_estimate(
&self,
estimate_id: &str,
body: &models::CreateInvoiceFromEstimateDto,
) -> Result<models::CreateInvoiceFromEstimateResponseDTO> {
let path = format!(
"/invoices/estimate/{}/invoice",
crate::services::encode(estimate_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn send_estimate(
&self,
estimate_id: &str,
body: &models::SendEstimateDto,
) -> Result<models::EstimateResponseDto> {
let path = format!(
"/invoices/estimate/{}/send",
crate::services::encode(estimate_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn generate_invoice_number(
&self,
params: &GenerateInvoiceNumberParams,
) -> Result<models::GenerateInvoiceNumberResponseDto> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/generate-invoice-number",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn list_schedules(
&self,
params: &ListSchedulesParams,
) -> Result<models::ListSchedulesResponseDto> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/schedule",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn create_invoice_schedule(
&self,
body: &models::CreateInvoiceScheduleDto,
) -> Result<models::CreateInvoiceScheduleResponseDto> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/schedule",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn delete_schedule(
&self,
schedule_id: &str,
params: &DeleteScheduleParams,
) -> Result<models::DeleteInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}",
crate::services::encode(schedule_id)
);
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn get_an_schedule(
&self,
schedule_id: &str,
params: &GetAnScheduleParams,
) -> Result<models::GetScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}",
crate::services::encode(schedule_id)
);
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn update_schedule(
&self,
schedule_id: &str,
body: &models::UpdateInvoiceScheduleDto,
) -> Result<models::UpdateInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}",
crate::services::encode(schedule_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PUT,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn manage_auto_payment_for_an_schedule_invoice(
&self,
schedule_id: &str,
body: &models::AutoPaymentScheduleDto,
) -> Result<models::AutoPaymentInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}/auto-payment",
crate::services::encode(schedule_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn cancel_an_scheduled_invoice(
&self,
schedule_id: &str,
body: &models::CancelInvoiceScheduleDto,
) -> Result<models::CancelInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}/cancel",
crate::services::encode(schedule_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn schedule_an_schedule_invoice(
&self,
schedule_id: &str,
body: &models::ScheduleInvoiceScheduleDto,
) -> Result<models::ScheduleInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}/schedule",
crate::services::encode(schedule_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_scheduled_recurring_invoice(
&self,
schedule_id: &str,
) -> Result<models::UpdateAndScheduleInvoiceScheduleResponseDto> {
let path = format!(
"/invoices/schedule/{}/updateAndSchedule",
crate::services::encode(schedule_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn get_invoice_settings(
&self,
params: &GetInvoiceSettingsParams,
) -> Result<models::GetInvoiceSettingsResponseDto> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/settings",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn update_invoice_last_visited_at(
&self,
body: &models::PatchInvoiceStatsLastViewedDto,
) -> Result<serde_json::Value> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PATCH,
"/invoices/stats/last-visited-at",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn list_templates(
&self,
params: &ListTemplatesParams,
) -> Result<models::ListTemplatesResponseDto> {
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
"/invoices/template",
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn create_template(
&self,
body: &models::CreateInvoiceTemplateDto,
) -> Result<models::CreateInvoiceTemplateResponseDto> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/template",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn delete_template(
&self,
template_id: &str,
params: &DeleteTemplateParams,
) -> Result<models::DeleteInvoiceTemplateResponseDto> {
let path = format!(
"/invoices/template/{}",
crate::services::encode(template_id)
);
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn get_an_template(
&self,
template_id: &str,
params: &GetAnTemplateParams,
) -> Result<models::GetTemplateResponseDto> {
let path = format!(
"/invoices/template/{}",
crate::services::encode(template_id)
);
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn update_template(
&self,
template_id: &str,
body: &models::UpdateInvoiceTemplateDto,
) -> Result<models::UpdateInvoiceTemplateResponseDto> {
let path = format!(
"/invoices/template/{}",
crate::services::encode(template_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PUT,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_template_late_fees_configuration(
&self,
template_id: &str,
body: &models::UpdateInvoiceLateFeesConfigurationDto,
) -> Result<models::UpdateInvoiceTemplateResponseDto> {
let path = format!(
"/invoices/template/{}/late-fees-configuration",
crate::services::encode(template_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PATCH,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_template_late_fees_configuration_op(
&self,
template_id: &str,
body: &models::UpdatePaymentMethodsConfigurationDto,
) -> Result<models::UpdateInvoiceTemplateResponseDto> {
let path = format!(
"/invoices/template/{}/payment-methods-configuration",
crate::services::encode(template_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PATCH,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn create_send(
&self,
body: &models::Text2PayDto,
) -> Result<models::Text2PayInvoiceResponseDto> {
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
"/invoices/text2pay",
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn delete_invoice(
&self,
invoice_id: &str,
params: &DeleteInvoiceParams,
) -> Result<models::DeleteInvoiceResponseDto> {
let path = format!("/invoices/{}", crate::services::encode(invoice_id));
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::DELETE,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn get_invoice(
&self,
invoice_id: &str,
params: &GetInvoiceParams,
) -> Result<models::GetInvoiceResponseDto> {
let path = format!("/invoices/{}", crate::services::encode(invoice_id));
let query = params.to_query();
self.client
.send_versioned(
reqwest::Method::GET,
&path,
&query,
None::<&()>,
Some("2021-07-28"),
)
.await
}
pub async fn update_invoice(
&self,
invoice_id: &str,
body: &models::UpdateInvoiceDto,
) -> Result<models::UpdateInvoiceResponseDto> {
let path = format!("/invoices/{}", crate::services::encode(invoice_id));
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PUT,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn update_invoice_late_fees_configuration(
&self,
invoice_id: &str,
body: &models::UpdateInvoiceLateFeesConfigurationDto,
) -> Result<models::UpdateInvoiceResponseDto> {
let path = format!(
"/invoices/{}/late-fees-configuration",
crate::services::encode(invoice_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::PATCH,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn record_a_manual_payment_for_an_invoice(
&self,
invoice_id: &str,
body: &models::RecordPaymentDto,
) -> Result<models::RecordPaymentResponseDto> {
let path = format!(
"/invoices/{}/record-payment",
crate::services::encode(invoice_id)
);
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn send_invoice(
&self,
invoice_id: &str,
body: &models::SendInvoiceDto,
) -> Result<models::SendInvoicesResponseDto> {
let path = format!("/invoices/{}/send", crate::services::encode(invoice_id));
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
pub async fn void_invoice(
&self,
invoice_id: &str,
body: &models::VoidInvoiceDto,
) -> Result<models::VoidInvoiceResponseDto> {
let path = format!("/invoices/{}/void", crate::services::encode(invoice_id));
let query = Vec::new();
self.client
.send_versioned(
reqwest::Method::POST,
&path,
&query,
Some(body),
Some("2021-07-28"),
)
.await
}
}