billecta 1.14.0

Generated Billecta API
Documentation
//! # Reconciliation invoice
//!
//! The following section describes the reconciliation invoice api calls. A reconciliation
//! invoice differs from an ordinary invoice in the way that is it more light weight and
//! faster since a subset of all data is sent to Billecta and no PDF is generated in Billecta.
//! Bookkeeping is not possible in reconciliation invoices  while all other features like
//! swish, autogiro, credit card, e-faktura etc are supported (based on the amount of metadata
//! available on the reconciliation invoice).
//!
use crate::{
    CardRefundPayment, CommentAction, CommonActionEvents, Created, CreditCardPayment,
    CreditCardPaymentIntent, Date, DeliveryMethodType, EmptyResponse, ReconciliationInvoiceAction,
    ReconciliationInvoiceActionEntry, ReconciliationInvoiceActionSubs,
    RegisterReconciliationPayment, Request, RequestBuilder, SendReconciliationInvoiceReminder,
    SwishRefundPayment, Uuid,
};

///Returns a reconciliation invoice based on the ActionPublicId. All
///reconciliation invoices have a unique ActionPublicId that is generated
///on creation.
pub fn get_reconciliation_invoice(id: Uuid) -> Request<ReconciliationInvoiceAction> {
    RequestBuilder::new(http::Method::GET, "/v1/reconciliationinvoice/action/")
        .path_param(id)
        .build()
}
///Unlike invoices (Invoice endpoints) a reconciliation invoices can be
///updated all the time. Please note, by changing the amounts all payment
///history is deleted.
pub fn update_reconciliation_invoice(
    id: Uuid,
    body: &ReconciliationInvoiceActionEntry,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/reconciliationinvoice/action/")
        .path_param(id)
        .body(body)
        .build()
}
///Unlike invoices (Invoice endpoints) the reconciliation invoices are
///not created as drafts. Once a reconciliation invoice is created it is
///considered as attested and any automatic operations (such as
///delivering the invoice) is executed.
pub fn create_reconciliation_invoice(body: &ReconciliationInvoiceActionEntry) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/reconciliationinvoice/action")
        .body(body)
        .build()
}
///Unlike invoices (Invoice endpoints) a reconciliation invoices can be
///delete all the time. Set Amount to 0 if you want to close it but not
///delete it.
pub fn delete_a_reconciliation_invoice(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/reconciliationinvoice/action/")
        .path_param(id)
        .build()
}
///The autogiro withdrawal can be cancelled using this endpoint. Note
///that this can't be done up to the day before the autogiro withdrawal
///date
pub fn cancel_autogiro_withdrawal(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/reconciliationinvoice/autogiro/")
        .path_param(id)
        .build()
}
///Retrieves all reconciliation invoices that have a closed/full payment
///date between the specified from and to dates.
pub fn get_all_closed_reconciliation_invoices(
    id: Uuid,
    from: Date,
    to: Date,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<ReconciliationInvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/reconciliationinvoice/closed/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Writes a comment to the self invoice events log.
pub fn comment_a_reconciliation_invoice(body: &CommentAction) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::POST, "/v1/reconciliationinvoice/comment")
        .body(body)
        .build()
}
///Make a credit card payment intent with the amount on the invoice.
pub fn create_credit_card_payment_intent(
    body: &CreditCardPaymentIntent,
) -> Request<CreditCardPayment> {
    RequestBuilder::new(
        http::Method::POST,
        "/v1/reconciliationinvoice/creditcardpayment",
    )
    .body(body)
    .build()
}
///The credit card payment can be cancelled if payment has not been
///completed yet.
pub fn cancel_credit_card_payment(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(
        http::Method::DELETE,
        "/v1/reconciliationinvoice/creditcardpayment/",
    )
    .path_param(id)
    .build()
}
pub fn get_all_events_for_all_reconciliation_invoices(
    id: Uuid,
    from: Date,
    to: Date,
) -> Request<CommonActionEvents> {
    RequestBuilder::new(http::Method::GET, "/v1/reconciliationinvoice/events/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .build()
}
///Retrieves all unpaid reconciliation invoices.
pub fn get_all_open_reconciliation_invoices(
    id: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<ReconciliationInvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/reconciliationinvoice/open/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///The credit card payment can be refunded if payment has been completed.
pub fn refund_credit_card_payment(body: &CardRefundPayment) -> Request<EmptyResponse> {
    RequestBuilder::new(
        http::Method::PUT,
        "/v1/reconciliationinvoice/refundcreditcardpayment",
    )
    .body(body)
    .build()
}
///The swish payment can be refunded if payment has been completed.
pub fn refund_swish_payment(body: &SwishRefundPayment) -> Request<EmptyResponse> {
    RequestBuilder::new(
        http::Method::PUT,
        "/v1/reconciliationinvoice/refundswishpayment",
    )
    .body(body)
    .build()
}
///Register a payment on the reconciliation invoice. This endpoint is
///preferred before updating the reconciliation invoice with new amount.
///Registering payment through this endpoint will keep history of the
///payment and creditation log.
pub fn register_payment_on_a_reconciliation_invoice(
    body: &RegisterReconciliationPayment,
) -> Request<Created> {
    RequestBuilder::new(
        http::Method::POST,
        "/v1/reconciliationinvoice/registerpayment",
    )
    .body(body)
    .build()
}
///Sends the reconciliation invoice with the preferred delivery method.
///Note that omitting optional parameters will use pre-stored values on
///the invoice.
pub fn send_the_reconciliation_invoice(
    id: Uuid,
    method: &DeliveryMethodType,
    isprioritymail: Option<bool>,
    iscolorized: Option<bool>,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/reconciliationinvoice/sendinvoice/")
        .path_param(id)
        .query_param("method", *method)
        .query_param_opt("isprioritymail", isprioritymail)
        .query_param_opt("iscolorized", iscolorized)
        .build()
}
///Send the reminder invoice for the reconciliation invoice. Reminder
///fees and PDF:s will be added to the reconcilation invoice
pub fn send_the_reminder_invoice_with_pregenerated_pdf(
    body: &SendReconciliationInvoiceReminder,
) -> Request<EmptyResponse> {
    RequestBuilder::new(
        http::Method::PUT,
        "/v1/reconciliationinvoice/sendreminderinvoice",
    )
    .body(body)
    .build()
}