Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query interface of driver_status now uses searchTerms instead of custId #89

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ async def test_member_subsession_id_from_session(self):
@async_test
async def test_driver_status(self):
response = await client.driver_status(499343)
self.assertIsInstance(response, iracing_data.DriverStatus)
for driver_status in response:
self.assertIsInstance(driver_status, iracing_data.DriverStatus)

@async_test
async def test_next_event(self):
Expand Down
7 changes: 2 additions & 5 deletions docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ friend=None<br>watched=None<br>recent=None | Accepts a `cust_id` to f
cust_id=None | Does not affect returned data

### driver_status()
Returns friends list for the person logged in. (gold star for least useful)
Returns a list of driver statuses determined by the provided search_terms argument.

| Args/Kwargs| Description |
|:---|:---|
cust_id=None| Returns the status info of the provided cust_id. If logged in while also providing **your** custid, it will also return the status info of your friends and studied/blacklisted drivers.
friends=1| Toggles display of friends in results.
studied=1| Toggles display of studied drivers in results.
blacklisted=1| Toggles display of blacklisted drivers in results.
search_terms='null'| Return status info of the provided search term. Can be used to search for status info of specific drivers using name ie. `'John Anderson5'`. You can also search for drivers with their cust_id ie. `111111`.

### event_results()
Returns a list of event results that the driver has participated in. This is the backend data for iRacing's [My Series Results](https://members.iracing.com/membersite/member/results.jsp). Contains the summary information about the results of the event. For detailed information about a specific session, see: [subsession_data()](#subsession_data).
Expand Down
7 changes: 4 additions & 3 deletions pyracing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,16 @@ async def member_subsession_id_from_session(self, cust_id, session_id):
response = await self._build_request(url, payload)
return response.json()

async def driver_status(self, cust_id):
async def driver_status(self, search_terms='null'):
""" Returns information about the member's current status. If logged
in while also providing your custid, it will return the same info for
your friends along with studied, and blacklisted drivers.
"""
payload = {'custId': cust_id}
payload = {'searchTerms': search_terms}
url = ct.URL_DRIVER_STATUS
response = await self._build_request(url, payload)
return iracing_data.DriverStatus(response.json())
return [iracing_data.DriverStatus(x) for
x in response.json()["searchRacers"]]

async def next_event(
self,
Expand Down
49 changes: 23 additions & 26 deletions pyracing/response_objects/iracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,28 @@ def __init__(self, data):

class DriverStatus:
def __init__(self, data):
status = data['status']

self.name = parse_encode(status.get('name'))
self.broadcast = data.get('broadcast')
self.driver_changes = data.get('driverChanges')
self.last_login = datetime_from_iracing_timestamp(
status.get('lastLogin'))
data.get('lastLogin'))
self.users_max = data.get('maxUsers')
self.track_id = data.get('trackId')
self.session_status = data.get('sessionStatus')
self.session_type_id = data.get('sessionTypeId')
self.private_session = data.get('privateSession')
self.series_id = data.get('seriesId')
self.reg_open = data.get('regOpen')
self.cat_id = data.get('catId')
self.event_type_id = data.get('eventTypeId')
self.spotter_access = data.get('spotterAccess')
self.last_seen = datetime_from_iracing_timestamp(
status.get('lastSeen'))
self.broadcast = status.get('broadcast')
self.driver_changes = status.get('driverChanges')
self.users_max = status.get('maxUsers')
self.has_grid = status.get('hasGrid')
self.private_session = status.get('privateSession')
self.series_id = status.get('seriesId')
self.reg_open = status.get('regOpen')
self.spotter_access = status.get('spotterAccess')
self.season_id = status.get('seasonId')
self.helmet = Helmet(status['helmet'])
self.in_grid = status.get('inGrid')
self.start_time = status.get('startTime')
self.subsession_status = status.get('subSessionStatus')
self.track_id = status.get('trackId')
self.session_status = status.get('sessionStatus')
self.session_type_id = status.get('sessionTypeId')
self.cat_id = status.get('catId')
self.event_type_id = status.get('eventTypeId')
self.private_session_id = status.get('privateSessionId')
self.cust_id = status.get('custid')
self.user_role = status.get('userRole')
data.get('lastSeen'))
self.season_id = data.get('seasonId')
self.helmet = Helmet(data['helmet'])
self.private_session_id = data.get('privateSessionId')
self.cust_id = data.get('custid')
self.name = parse_encode(data.get('name'))
self.trusted_as_spotter = data.get('trustedAsSpotter')
self.start_time = data.get('startTime')
self.user_role = data.get('userRole')
self.subsession_status = data.get('subSessionStatus')