use crate::{
Created, Date, EmptyResponse, IncomingPaymentRequest, IncomingPayments, OutgoingPayment,
OutgoingPaymentStatus, OutgoingPaymentStatuses, PaymentMatch, PaymentMatchResult, Request,
RequestBuilder, SwishPaymentStatus, UnhandledPayment, UnhandledPayments, Uuid,
};
pub fn get_incoming_payments(body: &IncomingPaymentRequest) -> Request<IncomingPayments> {
RequestBuilder::new(http::Method::PUT, "/v1/payments/incomingpayments")
.body(body)
.build()
}
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()
}
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()
}
pub fn get_outgoing_payment_status(id: Uuid) -> Request<OutgoingPaymentStatus> {
RequestBuilder::new(http::Method::GET, "/v1/payments/outgoingpayments/")
.path_param(id)
.build()
}
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()
}
pub fn delete_an_outgoing_payment(id: Uuid) -> Request<EmptyResponse> {
RequestBuilder::new(http::Method::DELETE, "/v1/payments/outgoingpayments/")
.path_param(id)
.build()
}
pub fn get_swish_payment_status(id: &str) -> Request<SwishPaymentStatus> {
RequestBuilder::new(http::Method::GET, "/v1/payments/swish/")
.path_param(id)
.build()
}
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()
}
pub fn get_unhandled_payment(id: Uuid) -> Request<UnhandledPayment> {
RequestBuilder::new(http::Method::GET, "/v1/payments/unhandledpayment/")
.path_param(id)
.build()
}
pub fn get_unhandled_payments(id: Option<Uuid>) -> Request<UnhandledPayments> {
RequestBuilder::new(http::Method::GET, "/v1/payments/unhandledpayments/")
.path_param_opt(id)
.build()
}
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()
}
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()
}