Skip to main content

dna_rs/
lib.rs

1//! # dna-rs
2//!
3//! Async Rust client for the [Domain Name API](https://www.domainnameapi.com/) REST gateway.
4//!
5//! ## Quick start
6//!
7//! ```rust,no_run
8//! use dna_rs::DnaClient;
9//!
10//! #[tokio::main]
11//! async fn main() -> Result<(), dna_rs::DnaError> {
12//!     let client = DnaClient::new("YOUR-RESELLER-UUID", "YOUR-API-TOKEN")?;
13//!     let balance = client.get_current_balance("USD").await?;
14//!     println!("Balance: {} {}", balance.balance, balance.currency_name);
15//!     Ok(())
16//! }
17//! ```
18//!
19//! ## Module layout
20//!
21//! | Path | Contents |
22//! |---|---|
23//! | [`models`] | All request / response types, grouped by domain |
24//! | `ops/` (private) | `impl DnaClient` blocks, one file per API domain |
25//! | [`error`] | [`DnaError`] and [`DnaResult`] |
26//! | `http` (private) | Low-level reqwest transport |
27//!
28//!
29//! ## Environments
30//!
31//! | Constructor | Endpoint |
32//! |---|---|
33//! | [`DnaClient::new`] | Production |
34//! | [`DnaClient::new_ote`] | OTE / sandbox |
35//! | [`DnaClient::with_url`] | Custom URL |
36//!
37//! ## Error Handling
38//!
39//! All methods return [`DnaResult<T>`] which is [`Result<T, DnaError>`].
40//!
41//! ```rust,no_run
42//! use dna_rs::{DnaClient, DnaError};
43//!
44//! # async fn example() -> Result<(), DnaError> {
45//! # let client = DnaClient::new("id", "token")?;
46//! match client.get_reseller_details().await {
47//!     Ok(d)                                    => println!("{}", d.name),
48//!     Err(DnaError::Api { code, message, .. }) => eprintln!("[{code}] {message}"),
49//!     Err(e)                                   => eprintln!("{e}"),
50//! }
51//! # Ok(())
52//! # }
53//! ```
54
55pub mod error;
56pub mod models;
57
58mod client;
59mod http;
60mod ops;
61
62pub use client::DnaClient;
63pub use error::{DnaError, DnaResult};
64
65/// Production API base URL.
66pub const URL_PROD: &str = "https://api.domainresellerapi.com/api/v1";
67/// OTE (test/sandbox) API base URL.
68pub const URL_OTE: &str = "https://ote.domainresellerapi.com/api/v1";