Skip to content

🛠 validate all API interactions #1

@MayNiklas

Description

@MayNiklas

We should validate as many interactions with this library as we can!
As an example:

def get_player_json_by_puuid(puuid):
"""
Get the json data of a player by puuid.
"""
api_endpoint = "v2/by-puuid/mmr/eu/" + puuid
if (response := get_response(api_endpoint)) is None:
return False
if not get_name(response):
return False
if not get_tag(response):
return False
return response

def get_name(data: json):
"""
Get the name of a player.
"""
if not data:
return False
if (name := data["data"]["name"]) is None:
return False
return name

It would be best, to return real exceptions instead of False.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions