crypto_pay_api/lib.rs
1//! crypto-pay-api
2//!
3//! A Rust client library for interacting with the CryptoPay API.
4//!
5//! # Example with tokio
6//!
7//! ```no_run
8//! use crypto_pay_api::prelude::*;
9//!
10//! #[tokio::main]
11//! async fn main() -> Result<(), CryptoBotError> {
12//! let client = CryptoBot::builder().api_token("YOUR_API_TOKEN").build()?;
13//! let params = CreateInvoiceParamsBuilder::new().amount(dec!(10.0)).asset(CryptoCurrencyCode::Ton).build(&client).await?;
14//! let invoice = client.create_invoice(¶ms).await?;
15//! println!("Invoice created: {}", invoice.invoice_id);
16//! Ok(())
17//! }
18//! ```
19//!
20//! # Webhook Handling with axum
21//!
22//! ```no_run
23//! use crypto_pay_api::prelude::*;
24//!
25//! #[tokio::main]
26//! async fn main() -> Result<(), CryptoBotError> {
27//! let client = CryptoBot::builder().api_token("YOUR_API_TOKEN").build()?;
28//! let mut handler = client.webhook_handler(WebhookHandlerConfigBuilder::new().build());
29//! handler.on_update(|update| async move {
30//! println!("Invoice paid: {:?}", update.payload);
31//! Ok(())
32//! });
33//! Ok(())
34//! }
35//! ```
36//!
37//! For issues and contributions, please refer to the [GitHub repository](https://github.com/escwxyz/crypto-pay-api).
38
39mod api;
40mod client;
41mod error;
42mod models;
43mod utils;
44mod validation;
45mod webhook;
46
47pub mod prelude {
48 // Third-party crates re-exports
49 pub use crate::utils::types::*;
50
51 // Local crates re-exports
52 pub use crate::api::*;
53 pub use crate::client::CryptoBot;
54 pub use crate::error::*;
55 pub use crate::models::*;
56 pub use crate::webhook::*;
57}