use reqwest::Method;

use super::{urlencode, Client};
use crate::devices::DevicesPage;
use crate::error::Error;

impl Client {
    /// GET /api/me/devices/{product} - registered devices plus slot usage.
    pub async fn list_devices(&self, product: &str) -> Result<DevicesPage, Error> {
        let path = format!("/api/me/devices/{}", urlencode(product));
        self.do_request::<(), DevicesPage>(Method::GET, &path, None)
            .await
    }

    /// DELETE /api/me/devices/{device} - revoke a device to free a slot.
    pub async fn revoke_device(&self, device_id: &str) -> Result<(), Error> {
        let path = format!("/api/me/devices/{}", urlencode(device_id));
        self.do_request::<(), ()>(Method::DELETE, &path, None).await
    }
}
