Skip to content

Commit

Permalink
request_update()-Send request to refresh data from the cars module (i…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian committed Dec 24, 2021
1 parent 53e17b7 commit 8c3eb16
Show file tree
Hide file tree
Showing 26 changed files with 6,220 additions and 1,929 deletions.
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
![Sync Connect Python SDK Logo](https://user-images.githubusercontent.com/35158392/111222780-4bf1bb80-85aa-11eb-8be2-271ae5f32936.png)
![ConnectedCar Python SDK Logo](https://user-images.githubusercontent.com/35158392/147300580-29723aab-ffae-46d3-ae60-72af59065daa.png)

The ConnectedCar Python SDK is an open-source, python package that provides the ability to send commands to your Ford Sync Connect connected vehicle.

# Installation [![PyPI version](https://badge.fury.io/py/connectedcar.svg)](https://badge.fury.io/py/connectedcar)

The Sync Connect Python SDK is an open-source, python package that provides the ability to send commands to your Ford Sync Connect connected vehicle.
# Installation [![PyPI version](https://badge.fury.io/py/syncconnect.svg)](https://badge.fury.io/py/syncconnect)
```sh
python3 -m pip install syncconnect
python3 -m pip install connectedcar
```

Requirements

- To make requests to a vehicle, the end user must have signed up for an account using [Ford Pass](https://owner.ford.com/fordpass/fordpass-sync-connect.html). These credentials will be used to authenticate your requests.

# Getting Started

Import the Sync Connect SDK
Import the ConnectedCar SDK

```python
import syncconnect
import connectedcar
```

Create a new connectedcar `client`

Create a new syncconnect `client`
- Note the default Sync Connect client_id is
`9fb503e0-715b-47e8-adfd-ad4b7770f73b`
- Note the default ConnectedCar client_id is
`9fb503e0-715b-47e8-adfd-ad4b7770f73b`

```python
client = syncconnect.AuthClient('9fb503e0-715b-47e8-adfd-ad4b7770f73b', None, None)
client = connectedcar.AuthClient('9fb503e0-715b-47e8-adfd-ad4b7770f73b', None, None)
```

Use `client.get_user_access_token()` to exchange your user credentials for an **access object**. To make any vehicle data request to the Ford Sync Connect API, you'll need to give the SDK a valid **access token**.
Use `client.get_user_access_token()` to exchange your user credentials for an **access object**. To make any vehicle data request to the Ford Sync Connect API, you'll need to give the SDK a valid **access token**.

```python
access = client.get_user_access_token('<username>', '<password>')
Expand All @@ -49,12 +54,14 @@ Access tokens will expire every 2 hours, so you'll need to constantly refresh th
refreshToken = client.exchange_refresh_token(access['refreshToke'])
```

With your access token in hand, use `syncconnect.User()` to get a User object representing the user.
With your access token in hand, use `connectedcar.User()` to get a User object representing the user.

```python
user = syncconnect.User(access['access_token'])
user = connectedcar.User(access['access_token'])
```

Use `user.vehicles()` to return an array of all the vehicles associated with a users account. The response will include the **vehicle vin**.

```python
vehicles = user.vehicles()

Expand All @@ -64,21 +71,26 @@ for userVehicle in vehicles: # For each user vehicle
vehicleList.append(userVehicle['vin'])
```

Now with a **vehicle vin** in hand, use `syncconnect.Vehicle()` to get a Vehicle object representing the user's vehicle.
Now with a **vehicle vin** in hand, use `connectedcar.Vehicle()` to get a Vehicle object representing the user's vehicle.

```python
currentVehicle = syncconnect.Vehicle(vehicleList[0], access['access_token']) # First Vehicle in vehicleList
currentVehicle = connectedcar.Vehicle(vehicleList[0], access['access_token']) # First Vehicle in vehicleList
```

Now you can ask the car to do things, or ask it for some data! For example:

```python
currentVehicle.start()
```

# Examples & Documentation

For more examples on what you can do with Sync Connected car, see the [examples](/examples) folder or take a peek at the [documentation](https://ianjwhite99.github.io/sync-connect-sdk/).

# Funding & Support
If you are interested in supporting the development of my projects check out my [patreon](https://www.patreon.com/ianjwhite99) or [buy me a coffee](https://www.buymeacoffee.com/ianjwhite9).

If you are interested in supporting the development of my projects check out my [patreon](https://www.patreon.com/ianjwhite99) or [buy me a coffee](https://www.buymeacoffee.com/ianjwhite9).

# Disclaimer

THIS CODEBASE IS NOT ENDORSED, AFFILIATED, OR ASSOCIATED WITH FORD, FOMOCO OR THE FORD MOTOR COMPANY.
4 changes: 2 additions & 2 deletions syncconnect/__init__.py → connectedcar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
The Python package `syncconnect` provides a SDK to interact with
The Python package `connectedcar` provides a SDK to interact with
Ford Sync Connect enabled vehicles. With this package you will
be able to make requests on behalf of a Ford Pass user to: authorize
new vehicles, edit current vehicles, return vehicle information, send
vehicle commands and return user information.
"""

from .syncconnect import (AuthClient)
from .connectedcar import (AuthClient)
from .user import User
from .vehicle import Vehicle
from .exceptions import (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions syncconnect/vehicle.py → connectedcar/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ def status(self):
return response.json()

def refresh_status(self):
""" GET Vehicle.refresh_status
""" PUT Vehicle.refresh_status
Returns:
Response: Refresh vehicle status
Response: Send request to refresh data from the cars module
Raises:
SyncException
"""

response = self.api.get(
response = self.api.put(
const.API_URL,
'vehicles/v3/' +
'vehicles/v2/' +
self.vehicle_id +
'/statusrefresh/ffe168a3-657f-4b74-9668-909c60e2379f')
'/status', None)
return response.json()

def send_auth(self):
Expand Down
Loading

0 comments on commit 8c3eb16

Please sign in to comment.