1pub mod client;
2pub mod error;
3
4use opennode::account::{Balance};
5use opennode::charge;
6use opennode::charge::Charge;
7use opennode::withdrawal;
8use opennode::withdrawal::Withdrawal;
9use opennode::refund;
10use opennode::refund::Refund;
11use opennode::currency::Currency;
12use opennode::rate::Rates;
13
14use crate::client::Client;
15use crate::error::Error;
16
17pub async fn create_charge(client: &Client, payload: charge::Payload) -> Result<Charge, Error> {
19 client.post("/v1/charges", Some(payload)).await
20}
21
22pub async fn get_charge(client: &Client, id: &str) -> Result< Charge, Error> {
24 let path = format!("/v1/charge/{}", id);
25 client.get(&path, None as Option<String>).await
26}
27
28pub async fn list_charges(client: &Client) -> Result<Vec<Charge>, Error> {
30 client.get("/v1/charges", None as Option<String>).await
31}
32
33pub async fn create_withdrawal(client: &Client, payload: withdrawal::Payload) -> Result< Withdrawal, Error> {
35 client.post("/v2/withdrawals", Some(payload)).await
36}
37
38pub async fn get_withdrawal(client: &Client, id: &str) -> Result<Withdrawal, Error> {
40 let path = format!("/v1/withdrawal/{}", id);
41 client.get(&path, None as Option<String>).await
42}
43
44pub async fn list_withdrawals(client: &Client) -> Result<Vec<Withdrawal>, Error> {
46 client.get("/v1/withdrawals", None as Option<String>).await
47}
48
49pub async fn create_refund(client: &Client, payload: refund::Payload) -> Result<Refund, Error> {
51 client.post("/v1/refunds", Some(payload)).await
52}
53
54pub async fn get_refund(client: &Client, id: &str) -> Result<Refund, Error> {
56 let path = format!("/v1/refund/{}", id);
57 client.get(&path, None as Option<String>).await
58}
59
60pub async fn list_refunds(client: &Client) -> Result<Vec<Refund>, Error> {
62 client.get("/v1/refunds", None as Option<String>).await
63}
64
65pub async fn list_currencies(client: &Client) -> Result<Vec<Currency>, Error> {
67 client.get("/v1/currencies", None as Option<String>).await
68}
69
70pub async fn get_account_balance(client: &Client) -> Result<Balance, Error> {
72 client.get("/v1/account/balance", None as Option<String>).await
73}
74
75pub async fn list_rates(client: &Client) -> Result<Rates, Error> {
77 client.get("/v1/rates", None as Option<String>).await
78}