use eiktyrner::{content, HttpClient};
use crate::{Param, PathAndQueryBuilder, Result};
use crate::Client;
use crate::models::{
Base64,
CommentActionView,
CommonActionEventsView,
CreatedView,
CreditCardPaymentIntentView,
CreditCardPaymentView,
DateTime,
DeliveryMethodTypeView,
Guid,
InterestTypeView,
InvoiceActionEntryView,
InvoiceActionRotRutProcessedsView,
InvoiceActionSubsView,
InvoiceActionView,
RegisterPaymentView,
ReminderInvoiceActionSubsView,
ReminderInvoiceActionView,
UpdateAddressActionView,
VerificationInvoiceActionEntryView,
};
impl Client {
pub async fn invoice_attest_an_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("attest"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_cancel_autogiro_withdrawal(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("autogiro"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_cancel_credit_card_payment(&self,id: Guid,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("creditcardpayment"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_cancel_invoice_dispute(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("canceldispute"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_cancel_reminder_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("cancelreminder"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_cancel_the_invoice_sales(&self,id: String,
comment: Option<String>,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("sellinvoice"))
.url(Param::value(id))
.query("comment", Param::opt(comment))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_comment_an_invoice(&self,body: CommentActionView,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("comment"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_create_rot_xml_file(&self,actionpublicid: String,
) -> Result<Base64> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("rotxml"))
.query("actionpublicid", Param::value(actionpublicid))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_create_rut_xml_file(&self,actionpublicid: String,
) -> Result<Base64> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("rutxml"))
.query("actionpublicid", Param::value(actionpublicid))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_create_a_verification_invoice(&self,body: VerificationInvoiceActionEntryView,
) -> Result<CreatedView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("verificationinvoice"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_create_an_invoice(&self,body: InvoiceActionEntryView,
) -> Result<CreatedView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("action"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_create_autogiro_withdrawal(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("autogiro"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_create_credit_card_payment_intent(&self,body: CreditCardPaymentIntentView,
) -> Result<CreditCardPaymentView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("creditcardpayment"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_create_interest_invoice(&self,id: String,
from: DateTime,
to: DateTime,
interesttype: InterestTypeView,
interest: f64,
interesttermsindays: i64,
) -> Result<CreatedView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("interestinvoice"))
.url(Param::value(id))
.query("from", Param::value(from))
.query("to", Param::value(to))
.query("interesttype", Param::value(interesttype))
.query("interest", Param::value(interest))
.query("interesttermsindays", Param::value(interesttermsindays))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_delete_address_override_for_an_invoice(&self,id: String,
body: UpdateAddressActionView,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("address"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_delete_an_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("action"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_dispute_an_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("dispute"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_get_all_closed_invoices(&self,id: Guid,
from: DateTime,
to: DateTime,
offset: Option<i64>,
limit: Option<i64>,
sortingfield: Option<String>,
asc: Option<bool>,
) -> Result<InvoiceActionSubsView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("closed"))
.url(Param::value(id))
.query("from", Param::value(from))
.query("to", Param::value(to))
.query("offset", Param::opt(offset))
.query("limit", Param::opt(limit))
.query("sortingfield", Param::opt(sortingfield))
.query("asc", Param::opt(asc))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_all_credit_card_payment_intents(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("creditcardpayments"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_get_all_events_for_all_invoices(&self,id: Guid,
from: String,
to: String,
) -> Result<CommonActionEventsView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("events"))
.url(Param::value(id))
.query("from", Param::value(from))
.query("to", Param::value(to))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_all_open_invoices(&self,id: Guid,
offset: Option<i64>,
limit: Option<i64>,
sortingfield: Option<String>,
asc: Option<bool>,
) -> Result<InvoiceActionSubsView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("open"))
.url(Param::value(id))
.query("offset", Param::opt(offset))
.query("limit", Param::opt(limit))
.query("sortingfield", Param::opt(sortingfield))
.query("asc", Param::opt(asc))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_all_open_reminder_invoices(&self,id: Guid,
offset: Option<i64>,
limit: Option<i64>,
sortingfield: Option<String>,
asc: Option<bool>,
) -> Result<ReminderInvoiceActionSubsView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("openreminders"))
.url(Param::value(id))
.query("offset", Param::opt(offset))
.query("limit", Param::opt(limit))
.query("sortingfield", Param::opt(sortingfield))
.query("asc", Param::opt(asc))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_an_invoice(&self,id: String,
) -> Result<InvoiceActionView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("action"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_invoices_that_are_processed_for_rot_rut_between_two_dates(&self,id: String,
createdfrom: Guid,
createdto: DateTime,
) -> Result<InvoiceActionRotRutProcessedsView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("rotrutprocessed"))
.url(Param::value(id))
.query("createdfrom", Param::value(createdfrom))
.query("createdto", Param::value(createdto))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_get_reminder_invoice(&self,id: String,
) -> Result<ReminderInvoiceActionView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("reminder"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_load_archived_events(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("loadarchivedevents"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_mark_invoices_are_processed_for_rot_rut(&self,actionpublicid: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("rotrutprocessed"))
.query("actionpublicid", Param::value(actionpublicid))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_merge_invoices(&self,actionpublicid: String,
invoicedate: Option<DateTime>,
duedate: Option<DateTime>,
deliverydate: Option<DateTime>,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("merge"))
.query("actionpublicid", Param::value(actionpublicid))
.query("invoicedate", Param::opt(invoicedate))
.query("duedate", Param::opt(duedate))
.query("deliverydate", Param::opt(deliverydate))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_pause_an_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("pause"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_postpone_next_event_by_days(&self,id: String,
days: i64,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("postpone"))
.url(Param::value(id))
.query("days", Param::value(days))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_postpone_next_event_until(&self,id: String,
date: DateTime,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("postpone"))
.url(Param::value(id))
.query("date", Param::value(date))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_preview_an_invoice_by_id(&self,id: String,
) -> Result<Base64> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("preview"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::GET,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_preview_an_invoice(&self,body: InvoiceActionEntryView,
) -> Result<Base64> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("preview"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_refund_credit_card_payment(&self,id: Guid,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("refundcreditcardpayment"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_refund_swish_payment(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("refundswishpayment"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_register_payment_on_an_invoice(&self,body: RegisterPaymentView,
) -> Result<CreatedView> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("registerpayment"))
.build();
let request = self.new_request(
http::method::Method::POST,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Json<_>>(request).await
}
pub async fn invoice_resume_a_paused_invoice(&self,id: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("resume"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_sell_the_invoice(&self,id: String,
salescontractpublicid: Option<Guid>,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("sellinvoice"))
.url(Param::value(id))
.query("salescontractpublicid", Param::opt(salescontractpublicid))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_send_the_invoice(&self,id: String,
method: Option<DeliveryMethodTypeView>,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("sendinvoice"))
.url(Param::value(id))
.query("method", Param::opt(method))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_unmark_invoices_are_processed_for_rot_rut(&self,actionpublicid: String,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("rotrutprocessed"))
.query("actionpublicid", Param::value(actionpublicid))
.build();
let request = self.new_request(
http::method::Method::DELETE,
path_and_query,
)
.body(content::Empty).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_update_address_on_an_invoice(&self,body: UpdateAddressActionView,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("address"))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
pub async fn invoice_update_an_invoice(&self,id: String,
body: InvoiceActionEntryView,
) -> Result<()> {
let path_and_query = PathAndQueryBuilder::new()
.url(Param::value("v1"))
.url(Param::value("invoice"))
.url(Param::value("action"))
.url(Param::value(id))
.build();
let request = self.new_request(
http::method::Method::PUT,
path_and_query,
)
.body(content::Json(body)).expect("setting json body");
self.client.send::<_, content::Empty>(request).await
}
}