billecta 1.14.0

Generated Billecta API
Documentation
//! # Payments
//!
//!
use crate::{
    Created, Date, EmptyResponse, IncomingPaymentRequest, IncomingPayments, OutgoingPayment,
    OutgoingPaymentStatus, OutgoingPaymentStatuses, PaymentMatch, PaymentMatchResult, Request,
    RequestBuilder, SwishPaymentStatus, UnhandledPayment, UnhandledPayments, Uuid,
};

///Gets all incoming payments that has been matched/connected to an
///invoice. Unhandled/Unknown payments that are not related to any
///invoice will not be retrieved in this method. Please refer to 'Get
///unhandled payments' endpoint.
pub fn get_incoming_payments(body: &IncomingPaymentRequest) -> Request<IncomingPayments> {
    RequestBuilder::new(http::Method::PUT, "/v1/payments/incomingpayments")
        .body(body)
        .build()
}
///Connects an unhandled payment that the system automatically couldn't
///connect.
pub fn match_unhandled_payments(
    id: Uuid,
    body: &Vec<PaymentMatch>,
) -> Request<Vec<PaymentMatchResult>> {
    RequestBuilder::new(http::Method::POST, "/v1/payments/matchpayments/")
        .path_param(id)
        .body(body)
        .build()
}
///Retrieves the status of all outgoing payments between two dates.
pub fn get_outgoing_payment_statuses_list_of_payments(
    id: Uuid,
    from: Date,
    to: Date,
) -> Request<OutgoingPaymentStatuses> {
    RequestBuilder::new(http::Method::GET, "/v1/payments/outgoingpayments/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .build()
}
///Retrieves the status of single outgoing payment.
pub fn get_outgoing_payment_status(id: Uuid) -> Request<OutgoingPaymentStatus> {
    RequestBuilder::new(http::Method::GET, "/v1/payments/outgoingpayments/")
        .path_param(id)
        .build()
}
///Sets the status of single outgoing payment. This endpoint is only
///available in test enviroment
pub fn only_for_test_enviroment_mark_outgoing_payment_as_succeded_failed(
    id: Uuid,
    wassuccessful: bool,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/payments/outgoingpayments/")
        .path_param(id)
        .query_param("wassuccessful", wassuccessful)
        .build()
}
pub fn create_an_outgoing_payment(body: &OutgoingPayment) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/payments/outgoingpayments")
        .body(body)
        .build()
}
///Cancel a standalone outgoing payment. This is a pure API feature.
///Status of the outgoing payment is made through a call to 'Get outgoing
///payment statuses'
pub fn delete_an_outgoing_payment(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/payments/outgoingpayments/")
        .path_param(id)
        .build()
}
///Gets the status for the Swish payment request. A payment request must
///first be created/initiated by the POST endpoint. Use the returned
///token in the POST endpoint to retrieve status.
pub fn get_swish_payment_status(id: &str) -> Request<SwishPaymentStatus> {
    RequestBuilder::new(http::Method::GET, "/v1/payments/swish/")
        .path_param(id)
        .build()
}
///Creates/Initiates a Swish payment request that will start a payment
///and initiate the payment request on the end users Swish app on their
///cell phone. Get the status of the payment by polling the GET endpoint.
///For more information see
pub fn create_swish_payment_request(
    id: &str,
    phone: &str,
    message: Option<&str>,
) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/payments/swish/")
        .path_param(id)
        .query_param("phone", phone)
        .query_param_opt("message", message)
        .build()
}
///Retrieve a specific unhandled payment by payment id. An unhandled
///payment is an incoming payment that can't be connected to any invoice
///due to that the reference (OCR/invoice number/sender/etc) is unknown
///and can't be found in the system. An unhandled payment can also be an
///overpayment connected to an invoice. Unhandled payments are handled
///through the MatchPayments endpoint.
pub fn get_unhandled_payment(id: Uuid) -> Request<UnhandledPayment> {
    RequestBuilder::new(http::Method::GET, "/v1/payments/unhandledpayment/")
        .path_param(id)
        .build()
}
///Retrieves all unhandled payments. An unhandled payment is an incoming
///payment that can't be connected to any invoice due to that the
///reference (OCR/invoice number/sender/etc) is unknown and can't be
///found in the system. Unhandled payments are handled through the
///MatchPayments endpoint.
pub fn get_unhandled_payments(id: Option<Uuid>) -> Request<UnhandledPayments> {
    RequestBuilder::new(http::Method::GET, "/v1/payments/unhandledpayments/")
        .path_param_opt(id)
        .build()
}
///Creates an unhandled or over payment. This endpoint is only available
///in test enviroment
pub fn only_for_test_enviroment_create_unhandled_over_payment(
    body: &UnhandledPayment,
) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/payments/unhandledpayments")
        .body(body)
        .build()
}
///Remove an unhandled payment from the system and book it if needed.
///This can be used if the unhandled payments are for an invoice that was
///not created or exists in Billecta
pub fn delete_unhandled_payment(
    paymentpublicid: Uuid,
    bookkeepingaccount: Option<&str>,
    transactiondate: Option<Date>,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/payments/unhandledpayments")
        .query_param("paymentpublicid", paymentpublicid)
        .query_param_opt("bookkeepingaccount", bookkeepingaccount)
        .query_param_opt("transactiondate", transactiondate)
        .build()
}