Skip to content

Commit

Permalink
Added a separate retrieval of location data
Browse files Browse the repository at this point in the history
  • Loading branch information
jsight committed Oct 20, 2023
1 parent 56a6aa3 commit 5058a6f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/tesla_api/vehicle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,21 @@ defmodule TeslaApi.Vehicle do
_global -> "https://owner-api.teslamotors.com"
end

TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data",
vehicle_location_data = TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data?endpoints=location_data",
opts: [access_token: auth.token]
)
|> handle_response(transform: &result/1)

vehicle_data = TeslaApi.get(endpoint_url <> "/api/1/vehicles/#{id}/vehicle_data",
opts: [access_token: auth.token]
)
|> handle_response(transform: &result/1)

{
elem(vehicle_data, 0),
%TeslaApi.Vehicle{elem(vehicle_data, 1) | drive_state: elem(vehicle_location_data, 1).drive_state}
}

end

def result(v) do
Expand Down

0 comments on commit 5058a6f

Please sign in to comment.