use crate::client::LnBot;
use crate::errors::LnBotError;
use crate::types::*;
pub struct WalletKeyResource<'a> {
pub(crate) client: &'a LnBot,
pub(crate) prefix: &'a str,
}
impl WalletKeyResource<'_> {
pub async fn create(&self) -> Result<WalletKeyResponse, LnBotError> {
self.client
.post::<WalletKeyResponse>(&format!("{}/key", self.prefix), None::<&()>)
.await
}
pub async fn get(&self) -> Result<WalletKeyInfoResponse, LnBotError> {
self.client.get(&format!("{}/key", self.prefix)).await
}
pub async fn delete(&self) -> Result<(), LnBotError> {
self.client.delete(&format!("{}/key", self.prefix)).await
}
pub async fn rotate(&self) -> Result<WalletKeyResponse, LnBotError> {
self.client
.post::<WalletKeyResponse>(&format!("{}/key/rotate", self.prefix), None::<&()>)
.await
}
}