use wecomx_transport::Transport;
pub struct WecomClient {
inner: wecomx::Client,
}
impl WecomClient {
pub fn from_transport(transport: Transport) -> Result<Self, wecomx::Error> {
Ok(Self {
inner: wecomx::Client::builder()
.transport(transport)
.endpoint_catalog(crate::endpoint_catalog())
.build()?,
})
}
#[must_use]
pub fn from_client(inner: wecomx::Client) -> Self {
Self { inner }
}
#[must_use]
pub fn inner(&self) -> &wecomx::Client {
&self.inner
}
#[must_use]
pub fn into_inner(self) -> wecomx::Client {
self.inner
}
#[must_use]
pub fn transport(&self) -> &Transport {
self.inner.transport()
}
pub async fn list_services(&self) -> Result<Vec<wecomx::ServiceInfo>, wecomx::Error> {
self.inner.list_services().await
}
pub async fn service(&self, name: &str) -> Result<wecomx::ServiceHandle<'_>, wecomx::Error> {
self.inner.service(name).await
}
pub async fn method(&self, path: &[&str]) -> Result<wecomx::MethodHandle<'_>, wecomx::Error> {
self.inner.method(path).await
}
#[must_use]
pub fn run(&self, argv: Vec<String>) -> wecomx::CliRun<'_> {
self.inner.run(argv)
}
}