use async_trait::async_trait;
use fantoccini::error::CmdError;
use http::Method;
use serde_json::json;
use crate::{AndroidClient, AppiumClientTrait, IOSClient};
use crate::commands::AppiumCommand;
#[async_trait]
pub trait HasDeviceTime : AppiumClientTrait {
async fn device_time(&self) -> Result<String, CmdError> {
let value = self.issue_cmd(AppiumCommand::Custom(
Method::GET,
"appium/device/system_time".to_string(),
None
)).await?;
Ok(serde_json::from_value(value)?)
}
async fn device_time_with_format(&self, format: &str) -> Result<String, CmdError> {
let value = self.execute("mobile: getDeviceTime", vec![
json!({"format": format})
]).await?;
Ok(serde_json::from_value(value)?)
}
}
#[async_trait]
impl HasDeviceTime for AndroidClient {}
#[async_trait]
impl HasDeviceTime for IOSClient {}