refactor: reuse POST request structs for cli
This commit is contained in:
parent
68b835124f
commit
844583a6b1
|
@ -15,10 +15,10 @@ pub enum VehicleCommand {
|
||||||
ChargePortDoorClose,
|
ChargePortDoorClose,
|
||||||
|
|
||||||
/// Set charge limit.
|
/// Set charge limit.
|
||||||
SetChargeLimit { percent: u8 },
|
SetChargeLimit(SetChargeLimit),
|
||||||
|
|
||||||
/// Set charge amps.
|
/// Set charge amps.
|
||||||
SetChargingAmps { charging_amps: i64 },
|
SetChargingAmps(SetChargingAmps),
|
||||||
|
|
||||||
/// Set the charge limit to the standard %.
|
/// Set the charge limit to the standard %.
|
||||||
ChargeStandard,
|
ChargeStandard,
|
||||||
|
@ -47,17 +47,11 @@ impl VehicleArgs {
|
||||||
VehicleCommand::VehicleData => {
|
VehicleCommand::VehicleData => {
|
||||||
print_json(api.vehicle_data(&self.id).await);
|
print_json(api.vehicle_data(&self.id).await);
|
||||||
}
|
}
|
||||||
VehicleCommand::SetChargeLimit { percent } => {
|
VehicleCommand::SetChargeLimit(limit) => {
|
||||||
print_json(
|
print_json(api.set_charge_limit(&self.id, &limit).await);
|
||||||
api.set_charge_limit(&self.id, &SetChargeLimit { percent })
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
VehicleCommand::SetChargingAmps { charging_amps } => {
|
VehicleCommand::SetChargingAmps(charging_amps) => {
|
||||||
print_json(
|
print_json(api.set_charging_amps(&self.id, &charging_amps).await);
|
||||||
api.set_charging_amps(&self.id, &SetChargingAmps { charging_amps })
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
VehicleCommand::ChargeStart => {
|
VehicleCommand::ChargeStart => {
|
||||||
print_json(api.charge_start(&self.id).await);
|
print_json(api.charge_start(&self.id).await);
|
||||||
|
|
|
@ -314,13 +314,15 @@ pub struct Vehicle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||||
pub struct SetChargingAmps {
|
pub struct SetChargingAmps {
|
||||||
pub charging_amps: i64,
|
pub charging_amps: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||||
pub struct SetChargeLimit {
|
pub struct SetChargeLimit {
|
||||||
// pub percent: Percentage,
|
// TODO: percent: Percentage,
|
||||||
pub percent: u8,
|
pub percent: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue