macro_rules! device_service {
(
$(#[$meta:meta])*
$name:ident($service:literal) {
$(
$(#[$method_meta:meta])*
$method:ident => $action:literal
),* $(,)?
}
) => {
$(#[$meta])*
#[derive(Clone, Debug)]
pub struct $name {
base: $crate::services::DeviceProxyService,
}
impl $name {
pub const SERVICE: &'static str = $service;
pub(crate) fn new(client: ::std::sync::Arc<$crate::core::HttpClient>) -> Self {
Self {
base: $crate::services::DeviceProxyService::new(client, $service),
}
}
pub fn with_options(&self, options: $crate::core::RequestOptions) -> Self {
Self { base: self.base.with_options(options) }
}
$(
$(#[$method_meta])*
pub async fn $method(
&self,
body: impl $crate::core::IntoBody,
) -> $crate::core::Result<$crate::core::DeviceResponse> {
self.base.request($action, body).await
}
)*
}
impl ::std::ops::Deref for $name {
type Target = $crate::services::DeviceProxyService;
fn deref(&self) -> &Self::Target {
&self.base
}
}
};
}
macro_rules! credit_methods {
(
$name:ident {
$(
$(#[$method_meta:meta])*
$method:ident => $service:literal
),* $(,)?
}
) => {
impl $name {
$(
$(#[$method_meta])*
pub async fn $method(
&self,
body: impl $crate::core::IntoBody,
) -> $crate::core::Result<$crate::core::CreditResponse> {
self.base.request($service, body).await
}
)*
}
};
}
macro_rules! platform_service {
(
$(#[$meta:meta])*
$name:ident
) => {
$(#[$meta])*
#[derive(Clone, Debug)]
pub struct $name {
base: $crate::services::BaseService,
}
impl $name {
pub(crate) fn new(client: ::std::sync::Arc<$crate::core::HttpClient>) -> Self {
Self { base: $crate::services::BaseService::new(client) }
}
pub fn with_options(&self, options: $crate::core::RequestOptions) -> Self {
Self { base: self.base.with_options(options) }
}
}
impl ::std::ops::Deref for $name {
type Target = $crate::services::BaseService;
fn deref(&self) -> &Self::Target {
&self.base
}
}
};
}
macro_rules! json_get {
(
$name:ident {
$(
$(#[$method_meta:meta])*
$method:ident => $path:literal
),* $(,)?
}
) => {
impl $name {
$(
$(#[$method_meta])*
pub async fn $method(&self) -> $crate::core::Result<$crate::core::Json> {
self.base.get($path).await
}
)*
}
};
}
macro_rules! json_body {
(
$name:ident {
$(
$(#[$method_meta:meta])*
$method:ident => $verb:ident $path:literal
),* $(,)?
}
) => {
impl $name {
$(
$(#[$method_meta])*
pub async fn $method(
&self,
body: impl $crate::core::IntoBody,
) -> $crate::core::Result<$crate::core::Json> {
self.base.$verb($path, body).await
}
)*
}
};
}
macro_rules! json_empty {
(
$name:ident {
$(
$(#[$method_meta:meta])*
$method:ident => $verb:ident $path:literal
),* $(,)?
}
) => {
impl $name {
$(
$(#[$method_meta])*
pub async fn $method(&self) -> $crate::core::Result<$crate::core::Json> {
self.base.$verb($path, None).await
}
)*
}
};
}