From f43b7c25d0fff7ecf51906a2da68bed00b5c4995 Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Wed, 21 Aug 2024 21:08:38 +0000 Subject: [PATCH] Football Player Transactions --- espn_api/football/player.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/espn_api/football/player.py b/espn_api/football/player.py index fb7c08f8..60bbc718 100644 --- a/espn_api/football/player.py +++ b/espn_api/football/player.py @@ -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'): @@ -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})