pub struct Client { /* private fields */ }Expand description
An asynchronous client for the Namecheap API.
A Client bundles your API credentials, the whitelisted client IP, and the
chosen Environment, and exposes the supported commands through grouped
accessors: domains() and users().
The client is cheap to clone and is safe to share across tasks; it wraps a
connection-pooling reqwest::Client internally.
§Example
use namecheap_client::{Client, Environment};
let client = Client::builder()
.api_user("your-api-user")
.api_key("your-api-key")
.client_ip("203.0.113.10") // your whitelisted public IPv4
.environment(Environment::Sandbox)
.build()?;
let balances = client.users().get_balances().await?;
println!("available: {} {}", balances.available_balance, balances.currency);Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Starts building a client. See ClientBuilder.
Sourcepub fn new(
api_user: impl Into<String>,
api_key: impl Into<String>,
client_ip: impl Into<String>,
) -> Result<Self>
pub fn new( api_user: impl Into<String>, api_key: impl Into<String>, client_ip: impl Into<String>, ) -> Result<Self>
Creates a production client with the minimum required fields.
user_name defaults to api_user. To target the sandbox or to set a
distinct username, use Client::builder instead.
§Errors
Returns Error::Configuration if the underlying HTTP client cannot be
constructed.
Sourcepub fn environment(&self) -> Environment
pub fn environment(&self) -> Environment
The environment this client targets.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more