yfpy.models.Transaction

class Transaction(extracted_data)[source]

Bases: YahooFantasyObject

Model class for “transaction” data key.

Instantiate the Transaction child class of YahooFantasyObject.

Parameters:

extracted_data (dict) – Parsed and cleaned JSON data retrieved from the Yahoo Fantasy Sports REST API.

players

A list of YFPY Player instances.

Type:

list[Player]

status

The transaction status (“successful”, etc.).

Type:

str

timestamp

The timestamp of when the transaction occurred.

Type:

int

tradee_team_key

The Yahoo team key for the team receiving the player (if applicable).

Type:

str

tradee_team_name

The team name of the team receiving the player (if applicable).

Type:

str

trader_team_key

The Yahoo team key for the team sending the player (if applicable).

Type:

str

trader_team_name

The team name for the team sending the player (if applicable).

Type:

str

transaction_id

The unique transaction ID number.

Type:

int

transaction_key

The Yahoo transaction key (Ex.: “406.l.413954.tr.555”).

Type:

str

type

The type of the transaction (“add”, “drop”, “trade”, etc.).

Type:

str

Methods

clean_data_dict

Recursive method to un-type custom class type objects for serialization.

from_json

Deserialize JSON to a class object.

serialized

Pack up all object content into nested dictionaries for JSON serialization.

subclass_dict

Derive snake case dictionary keys from custom object type camel case class names.

to_json

Serialize the class object to JSON.

clean_data_dict()

Recursive method to un-type custom class type objects for serialization.

Returns:

Dictionary that extracts serializable data from custom objects.

Return type:

dict

classmethod from_json(json_data)

Deserialize JSON to a class object.

Returns:

Class object derived from JSON data.

Return type:

object

serialized()

Pack up all object content into nested dictionaries for JSON serialization.

Returns:

Serializable dictionary.

Return type:

dict

subclass_dict()

Derive snake case dictionary keys from custom object type camel case class names.

Returns:

Dictionary with snake case strings of all subclasses of YahooFantasyObject as keys and subclasses as values.

Return type:

dict

to_json()

Serialize the class object to JSON.

Returns:

JSON string derived from the serializable version of the class object.

Return type:

str