fix: remove vehicles list (#13)
This commit is contained in:
parent
c8b45d5c3e
commit
796c09c17a
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.1.13] - 2023-01-24
|
||||
|
||||
### Changed
|
||||
|
||||
- Vehicles list is gone from the API. Use `products` instead. (#13)
|
||||
|
||||
## [0.1.12] - 2023-01-20
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use std::env;
|
||||
use teslatte::auth::AccessToken;
|
||||
use teslatte::products::Product;
|
||||
use teslatte::vehicles::GetVehicleData;
|
||||
use teslatte::{OwnerApi, VehicleApi};
|
||||
use teslatte::OwnerApi;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
@ -17,19 +16,8 @@ async fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
let vehicles = api.vehicles().await.unwrap();
|
||||
dbg!(&*vehicles);
|
||||
|
||||
if !vehicles.is_empty() {
|
||||
let get_vehicle_data = GetVehicleData::new(vehicles[0].id.clone());
|
||||
let vehicle_data = api.vehicle_data(&get_vehicle_data).await.unwrap();
|
||||
dbg!(&vehicle_data);
|
||||
} else {
|
||||
println!("No vehicles found!");
|
||||
}
|
||||
|
||||
let products = api.products().await.unwrap();
|
||||
dbg!(&*products);
|
||||
dbg!(&products);
|
||||
|
||||
if !products.is_empty() {
|
||||
for product in &*products {
|
||||
|
|
3
justfile
3
justfile
|
@ -7,9 +7,8 @@ no_token_test:
|
|||
|
||||
# Require an access token from "cli.json". Use `just auth` to generate.
|
||||
token_tests:
|
||||
cargo run -- api vehicles
|
||||
cargo run --no-default-features --features cli -- api vehicles
|
||||
cargo run -- api products
|
||||
cargo run --no-default-features --features cli -- api products
|
||||
|
||||
publish version:
|
||||
git diff-index --quiet HEAD
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::auth::{AccessToken, RefreshToken};
|
|||
use crate::error::TeslatteError;
|
||||
use crate::vehicles::{
|
||||
GetVehicleData, SetChargeLimit, SetChargingAmps, SetScheduledCharging, SetScheduledDeparture,
|
||||
SetTemperatures, Vehicle, VehicleData,
|
||||
SetTemperatures, VehicleData,
|
||||
};
|
||||
use chrono::{DateTime, SecondsFormat, TimeZone};
|
||||
use derive_more::{Deref, Display, From, FromStr};
|
||||
|
@ -28,7 +28,6 @@ pub mod cli;
|
|||
const API_URL: &str = "https://owner-api.teslamotors.com/api/1";
|
||||
|
||||
pub trait VehicleApi {
|
||||
async fn vehicles(&self) -> Result<Vec<Vehicle>, TeslatteError>;
|
||||
async fn vehicle_data(
|
||||
&self,
|
||||
get_vehicle_data: &GetVehicleData,
|
||||
|
@ -314,6 +313,7 @@ struct ResponseError {
|
|||
struct Empty {}
|
||||
|
||||
/// GET /api/1/[url]
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! get {
|
||||
($name:ident, $return_type:ty, $url:expr) => {
|
||||
async fn $name(&self) -> Result<$return_type, crate::error::TeslatteError> {
|
||||
|
@ -324,6 +324,7 @@ macro_rules! get {
|
|||
}
|
||||
};
|
||||
}
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use get;
|
||||
|
||||
/// Same as get, but public.
|
||||
|
|
|
@ -4,7 +4,7 @@ use teslatte::auth::{AccessToken, RefreshToken};
|
|||
use teslatte::cli::energy::EnergySiteArgs;
|
||||
use teslatte::cli::powerwall::PowerwallArgs;
|
||||
use teslatte::cli::vehicle::VehicleArgs;
|
||||
use teslatte::{OwnerApi, PrintResponses, VehicleApi};
|
||||
use teslatte::{OwnerApi, PrintResponses};
|
||||
|
||||
/// Teslatte
|
||||
///
|
||||
|
@ -106,7 +106,7 @@ async fn main() -> miette::Result<()> {
|
|||
api.print_responses = PrintResponses::Pretty;
|
||||
match api_args.command {
|
||||
ApiCommand::Vehicles => {
|
||||
api.vehicles().await?;
|
||||
panic!("Tesla API has changed. This command is no longer works with the Owners API.");
|
||||
}
|
||||
ApiCommand::Vehicle(v) => {
|
||||
v.run(&api).await?;
|
||||
|
|
|
@ -4,15 +4,14 @@ use derive_more::{Deref, DerefMut, From};
|
|||
// Sometimes the API will return a null for a field where I've put in a non Option type, which
|
||||
// will cause the deserializer to fail. Please log an issue to fix these if you come across it.
|
||||
use crate::{
|
||||
get, get_args, post_arg, post_arg_empty, ApiValues, Empty, ExternalVehicleId, OwnerApi,
|
||||
VehicleApi, VehicleId,
|
||||
get_args, post_arg, post_arg_empty, ApiValues, Empty, ExternalVehicleId, OwnerApi, VehicleApi,
|
||||
VehicleId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
#[rustfmt::skip]
|
||||
impl VehicleApi for OwnerApi {
|
||||
get!(vehicles, Vec<Vehicle>, "/vehicles");
|
||||
get_args!(vehicle_data, VehicleData, "/vehicles/{}/vehicle_data", GetVehicleData);
|
||||
post_arg_empty!(wake_up, "/vehicles/{}/command/wake_up", VehicleId);
|
||||
|
||||
|
|
Loading…
Reference in a new issue