Skip to content

Commit

Permalink
Add Account V2
Browse files Browse the repository at this point in the history
  • Loading branch information
NavisGames authored and raimannma committed Jan 18, 2025
1 parent 7088f08 commit 57f7dff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/test_account_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@settings(deadline=None, max_examples=15)
@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
id=st.sampled_from(["ManuelHexe#5777", "jasminaxrose#7024"]),
force_update=st.booleans(),
)
Expand All @@ -34,7 +34,7 @@ async def test_get_account_details_by_name(version: str, id: str, force_update:

@settings(deadline=None, max_examples=15)
@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
puuid=st.sampled_from(
["ee89b4d9-13d0-5832-8dd7-eb5d8806d918", "930bb0d3-c914-5394-bcf6-0bc81f465bd7"]
),
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/endpoints/mock_responses/account_details_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"status": 200,
"data": {
"puuid": "ee89b4d9-13d0-5832-8dd7-eb5d8806d918",
"region": "eu",
"account_level": 137,
"name": "ManuelHexe",
"tag": "5777",
"card": "6f39b789-4318-f79e-14e9-0a872f6ba6a2",
"title": "bc6a30d8-4d83-82aa-dfe9-7389c776f312",
"platforms": [
"PC"
],
"updated_at": "2024-07-13T15:39:34.015Z"
}
}
8 changes: 4 additions & 4 deletions tests/unit/endpoints/test_account_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
name=st.text(),
tag=st.text(),
force_update=st.booleans(),
Expand Down Expand Up @@ -78,7 +78,7 @@ async def test_get_account_details_by_name(


@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
name=st.text(),
tag=st.text(),
force_update=st.booleans(),
Expand Down Expand Up @@ -149,7 +149,7 @@ async def test_get_account_details_by_name_error(


@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
puuid=st.uuids(),
force_update=st.booleans(),
)
Expand Down Expand Up @@ -208,7 +208,7 @@ async def test_get_account_details_by_puuid(


@given(
version=st.sampled_from(["v1"]),
version=st.sampled_from(["v1", "v2"]),
puuid=st.uuids(),
force_update=st.booleans(),
error_response=st.sampled_from(get_error_responses("account_details")),
Expand Down
8 changes: 5 additions & 3 deletions valo_api/endpoints_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PIL import Image

from valo_api.endpoint import Endpoint
from valo_api.responses.account_details import AccountDetailsV1
from valo_api.responses.account_details import AccountDetails
from valo_api.responses.competitive_updates_raw import CompetitiveUpdatesRawV1
from valo_api.responses.content import ContentV1
from valo_api.responses.leaderboard import LeaderboardPlayerV1, LeaderboardV2
Expand Down Expand Up @@ -187,7 +187,8 @@ class EndpointsConfig(Enum):
ACCOUNT_BY_NAME = Endpoint(
path="/valorant/{version}/account/{name}/{tag}",
f_name="get_account_details_by_name",
return_type=AccountDetailsV1,
versions=["v1", "v2"],
return_type=AccountDetails,
kwargs=OrderedDict(
[("version", str), ("name", str), ("tag", str), ("force_update", bool)]
),
Expand All @@ -196,7 +197,8 @@ class EndpointsConfig(Enum):
ACCOUNT_BY_PUUID = Endpoint(
path="/valorant/{version}/by-puuid/account/{puuid}",
f_name="get_account_details_by_puuid",
return_type=AccountDetailsV1,
versions=["v1", "v2"],
return_type=AccountDetails,
kwargs=OrderedDict([("version", str), ("puuid", str), ("force_update", bool)]),
query_args=OrderedDict([("force", "{force_update}")]),
)
Expand Down
6 changes: 4 additions & 2 deletions valo_api/responses/account_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class AccountCardV1(DictStruct):
wide: str


class AccountDetailsV1(DictStruct):
class AccountDetails(DictStruct):
puuid: str
region: str
account_level: int
name: str
tag: str
card: Optional[AccountCardV1] = None
card: Optional[AccountCardV1 | str] = None
title: Optional[str] = None
updated_at: Optional[str] = None
last_update: Optional[str] = None
last_update_raw: Optional[int] = None

0 comments on commit 57f7dff

Please sign in to comment.