Adds fleet status endpoint
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
Adds an endpoint to retrieve fleet status information. This endpoint uses a Tesla API proxy to fetch the fleet status based on provided VINs. It handles authentication using a bearer token and sends a POST request to the /api/1/vehicles/fleet_status endpoint. Also introduces new data models to properly serialize/deserialize the fleet status response.
This commit is contained in:
@@ -288,6 +288,22 @@ if (app.Environment.IsDevelopment())
|
||||
});
|
||||
}
|
||||
|
||||
app.MapGet("FleetStatus", async (IHttpClientFactory httpClientFactory) =>
|
||||
{
|
||||
string access_token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InFEc3NoM2FTV0cyT05YTTdLMzFWV0VVRW5BNCJ9.eyJpc3MiOiJodHRwczovL2ZsZWV0LWF1dGgudGVzbGEuY29tL29hdXRoMi92My9udHMiLCJhenAiOiJiMjI0MGVlNC0zMzJhLTQyNTItOTFhYS1iYmNjMjRmNzhmZGIiLCJzdWIiOiJkZDg3Mzc4OC00ZjliLTQyY2UtYmRkNi00YzdmMjQxOGMwN2UiLCJhdWQiOlsiaHR0cHM6Ly9mbGVldC1hcGkucHJkLm5hLnZuLmNsb3VkLnRlc2xhLmNvbSIsImh0dHBzOi8vZmxlZXQtYXBpLnByZC5ldS52bi5jbG91ZC50ZXNsYS5jb20iLCJodHRwczovL2ZsZWV0LWF1dGgudGVzbGEuY29tL29hdXRoMi92My91c2VyaW5mbyJdLCJzY3AiOlsib2ZmbGluZV9hY2Nlc3MiLCJvcGVuaWQiLCJ2ZWhpY2xlX2RldmljZV9kYXRhIiwidmVoaWNsZV9sb2NhdGlvbiJdLCJhbXIiOlsicHdkIl0sImV4cCI6MTc1NTU3NDk5NCwiaWF0IjoxNzU1NTQ2MTk0LCJvdV9jb2RlIjoiRVUiLCJsb2NhbGUiOiJodS1IVSIsImFjY291bnRfdHlwZSI6InBlcnNvbiIsIm9wZW5fc291cmNlIjpmYWxzZSwiYWNjb3VudF9pZCI6IjE5YTBhZjRmLTY1ZDgtNDc2MC1hYjVmLTZjMzk3ZTViMTI4ZiIsImF1dGhfdGltZSI6MTc1NTU0NjE5NCwibm9uY2UiOiI2Mzg5MTExNDkyNjE4ODc5MzUuWVdNMllUazNORFV0T1RSaVlTMDBZMlUyTFdFNU1USXRZVEUwTnpFd056WTFabU16TkRZeFpqRTJaRE10TlRjeFpDMDBaRGN3TFRrMlptVXROMk0xWTJNNU5ERmtNV1k0In0.iMODkOXyzt0_TJfuBrojbYSU7Cx_lb8DRZ_zMz-yQxZlPUA-pITfqgqgwQEqagCUJ3wlfOSxi1OSitmxPrxr9MOT8A9KUgTOSIrPxD36JHWnBmQpbkDNqNkM4MLEbbM-95p8YnFJ0VuB9_fzz0CbJyOm_oUelA2JnNhIQ5uGfJojYPM2UKN0rUx6uMAuFgc4CslPY1P43crAXrFlH6B3D2Yk47w9Xeh-Vg_ZiX-nJqMzph_ciqYRuiySJMjM3ez7EheGy50BR_esz4muit89H3nq0rURWBN3-weauu2bcWnuYp0Nk5-zFuO3O_FKuLt-1HqYH3CAeTF2JRBJHim-hA";
|
||||
|
||||
HttpClient client = httpClientFactory.CreateClient("InsecureClient");
|
||||
client.BaseAddress = new Uri("https://tesla_command_proxy");
|
||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {access_token}");
|
||||
|
||||
//Get fleet_status endpoint
|
||||
var requestObject = new { vins = new string[] { "5YJ3E7EB7KF291652" } };
|
||||
|
||||
HttpResponseMessage response = await client.PostAsJsonAsync("/api/1/vehicles/fleet_status", requestObject);
|
||||
|
||||
return Results.Ok(response.Content.ReadAsStringAsync());
|
||||
});
|
||||
|
||||
//Map static assets
|
||||
app.MapStaticAssets();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user