#[macro_export]
macro_rules! client_api {
(
$(#[$struct_meta:meta])*
$vis:vis struct $Name:ident;
$(
$(#[$method_meta:meta])*
$method_name:ident => $Endpoint:ty;
)*
) => {
$(#[$struct_meta])*
$vis struct $Name {
inner: $crate::Client,
}
impl $Name {
$vis fn new(base_url: &str) -> ::core::result::Result<Self, $crate::ClientError> {
::core::result::Result::Ok(Self {
inner: $crate::Client::new(base_url)?,
})
}
$vis fn with_config(
base_url: &str,
config: $crate::ClientConfig,
) -> ::core::result::Result<Self, $crate::ClientError> {
::core::result::Result::Ok(Self {
inner: $crate::Client::with_config(base_url, config)?,
})
}
$vis fn from_client(client: $crate::Client) -> Self {
Self { inner: client }
}
$vis fn inner(&self) -> &$crate::Client {
&self.inner
}
$(
$(#[$method_meta])*
$vis async fn $method_name(
&self,
args: <$Endpoint as $crate::CallEndpoint>::Args,
) -> ::core::result::Result<
<$Endpoint as $crate::CallEndpoint>::Response,
$crate::ClientError,
> {
self.inner.call::<$Endpoint>(args).await
}
)*
}
};
}