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

Football Player Transactions #557

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
14 changes: 14 additions & 0 deletions espn_api/football/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def __init__(self, data, year):
self.onTeamId = json_parsing(data, 'onTeamId')
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId'), '')
self.stats = {}
self.transactions = []

if 'transactions' in data:
self._set_transaction_data(data)

# Get players main position
for pos in json_parsing(data, 'eligibleSlots'):
Expand Down Expand Up @@ -58,3 +62,13 @@ def __init__(self, data, year):

def __repr__(self):
return f'Player({self.name})'

def _set_transaction_data(self, data):
transactions = data.get('transactions', [])
for transaction in transactions:
bid_amount = transaction.get('bidAmount', 0)
type = transaction.get('type', '')
team = transaction.get('teamId', 0)
date = transaction.get('proposedDate')
items = transaction.get('items', [])
self.transactions.append({'bid_amount': bid_amount, 'type': type, 'team': team, 'date': date, 'items': items})
Loading