-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(achievements): adds achievements to the API and adds support for …
…sanity as a source tested and working for getting all achievements as well as achievements by player name
- Loading branch information
Showing
19 changed files
with
315 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { BikeTagClient } from '../client' | ||
import { ACHIEVEMENTS_ENDPOINT } from '../common/endpoints' | ||
import { AvailableApis, HttpStatusCode } from '../common/enums' | ||
import { getAchievementsPayload } from '../common/payloads' | ||
import { Achievement } from '../common/schema' | ||
import { BikeTagApiResponse } from '../common/types' | ||
import { getApiUrl } from './helpers' | ||
|
||
export async function getAchievements( | ||
client: BikeTagClient, | ||
payload: getAchievementsPayload | ||
): Promise<BikeTagApiResponse<Achievement[]>> { | ||
delete payload.source | ||
const opts = { | ||
url: getApiUrl(payload.host, ACHIEVEMENTS_ENDPOINT, payload.game), | ||
data: payload, | ||
} | ||
|
||
/// TODO: allow getting achievements by Player | ||
const response = await (payload.cached | ||
? client.cachedRequest(opts) | ||
: client.request(opts)) | ||
|
||
const success = response.status === 200 | ||
|
||
return { | ||
data: response.data as unknown as Achievement[], | ||
success, | ||
error: !success ? response.statusText : undefined, | ||
source: AvailableApis[AvailableApis.biketag], | ||
status: success ? HttpStatusCode.Ok : response.status, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ export enum DataTypes { | |
setting, | ||
tag, | ||
queue, | ||
achievement, | ||
} | ||
|
||
export enum Errors { | ||
|
Oops, something went wrong.