Skip to content

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Jan 27, 2024
1 parent a52336f commit 0f7c35a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test.py
register.py
*.pyc
__pycache__
auth.json
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="tesla_fleet_api",
version="0.2.0",
version="0.2.1",
author="Brett Adams",
author_email="[email protected]",
description="Tesla Fleet API library for Python",
Expand Down
2 changes: 1 addition & 1 deletion tesla_fleet_api/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ async def public_key(self, domain: str | None = None) -> dict[str, Any]:
async def register(self, domain: str) -> dict[str, Any]:
"""Registers an existing account before it can be used for general API access. Each application from developer.tesla.com must complete this step."""
return await self._request(
Methods.POST, "api/1/partner_accounts", data={"domain": domain}
Methods.POST, "api/1/partner_accounts", json={"domain": domain}
)
10 changes: 6 additions & 4 deletions tesla_fleet_api/teslafleetoauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ async def refresh_access_token(self) -> str:
},
) as resp:
data = await resp.json()
self.access_token = data["access_token"]
self.refresh_token = data["refresh_token"]
self.expires = int(time.time()) + data["expires_in"]
return {"refresh_token": self.refresh_token, "expires": self.expires}
if resp.ok:
self.access_token = data["access_token"]
self.refresh_token = data["refresh_token"]
self.expires = int(time.time()) + data["expires_in"]
return {"refresh_token": self.refresh_token, "expires": self.expires}
raise ValueError(data)

async def _request(
self,
Expand Down
2 changes: 1 addition & 1 deletion tesla_fleet_api/teslemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(
super().__init__(
session,
access_token,
server="https://teslemetry.com",
server="https://api.teslemetry.com",
raise_for_status=raise_for_status,
partner_scope=False,
user_scope=False,
Expand Down
8 changes: 0 additions & 8 deletions tesla_fleet_api/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class Vehicle:
def __init__(self, parent):
self._parent = parent
self._request = parent._request
self.use_command_protocol = parent.use_command_protocol

async def create(self) -> [VehicleSpecific]:
"""Creates a class for each vehicle."""
if vehicles := (await self.list()).get("response"):
self._parent.vehicles = [VehicleSpecific(self, x["vin"]) for x in vehicles]
return self._parent.vehicles
return []

def specific(self, vehicle_tag: str | int) -> VehicleSpecific:
"""Creates a class for each vehicle."""
Expand Down

0 comments on commit 0f7c35a

Please sign in to comment.