gamesheet_sdk.admin.shared¶
Admin-specific shared utilities.
Functions
Build invitation code lookup from JSON:API included resources. |
|
|
Safely extract ID from JSON:API relationship. |
|
Extract invitation code from team's invitation relationship. |
|
Parse a JSON:API resource into a flat dictionary. |
- gamesheet_sdk.admin.shared.build_invitation_code_lookup(body)[source]¶
Build invitation code lookup from JSON:API included resources.
Parses the included section of a JSON:API response to extract invitation codes keyed by invitation ID.
- gamesheet_sdk.admin.shared.extract_relationship_id(item, relationship_name, default='')[source]¶
Safely extract ID from JSON:API relationship.
JSON:API relationships follow the structure:
{ "relationships": { "parent": { "data": {"id": "123", "type": "associations"} } } }
- gamesheet_sdk.admin.shared.get_invitation_code_from_relationship(item, invitation_codes)[source]¶
Extract invitation code from team’s invitation relationship.
The invitations relationship can be either a single object or an array of objects.
- gamesheet_sdk.admin.shared.parse_jsonapi_resource(item, relationship_map=None)[source]¶
Parse a JSON:API resource into a flat dictionary.
Flattens a JSON:API resource object into a simple dict by merging the id, attributes, and optionally extracting relationship IDs.
JSON:API structure:
{ "id": "123", "type": "leagues", "attributes": {"title": "NHL", ...}, "relationships": {"association": {"data": {"id": "456"}}} }
Result:
{"id": "123", "title": "NHL", "association_id": "456"}