Add Riot account lookup by PUUID

This commit is contained in:
dahyeon committed 2026-07-03 00:50:36 -07:00
1 parent 67b4032ff0
commit e24bb60627
2 files changed
+34

No files matched your search

@@ -87,6 +87,29 @@ describe('RiotApiClient', () => {
);
});
it('fetches account data through the regional PUUID endpoint', async () => {
const fetchMock = createFetchMock().mockResolvedValue(
jsonResponse({
puuid: 'puuid/1',
gameName: 'Seed Player',
tagLine: 'KR1',
}),
);
const { client, waitForSlot } = createClient(fetchMock);
await expect(client.getAccountByPuuid('puuid/1', 'asia')).resolves.toEqual({
puuid: 'puuid/1',
gameName: 'Seed Player',
tagLine: 'KR1',
});
expect(waitForSlot).toHaveBeenCalledWith('asia');
expect(fetchMock).toHaveBeenCalledWith(
'https://asia.api.riotgames.com/riot/account/v1/accounts/by-puuid/puuid%2F1',
expect.any(Object),
);
});
it('fetches platform and regional League endpoints with encoded parameters and query filters', async () => {
const fetchMock = createFetchMock()
.mockResolvedValueOnce(
@@ -253,6 +253,17 @@ export class RiotApiClient {
return this.parseAccount(response);
}
public async getAccountByPuuid(
puuid: string,
regionalRoute: RiotRegionalRoute = 'asia',
): Promise<RiotAccountDto> {
const response = await this.requestJson(
regionalRoute,
`${regionalBaseUrl(regionalRoute)}/riot/account/v1/accounts/by-puuid/${encodePathValue(puuid)}`,
);
return this.parseAccount(response);
}
public async getSummonerByPuuid(
puuid: string,
platformRoute: RiotPlatformRoute = 'kr',