darkstormgames / darkstormgames/mkcentral-api

Add Transfer History to Player

Open
#4 0 comments 0 reactions 1 assignee Claimed by @darkstormgames View on GitHub
enhancement
Dominant language
TypeScript
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Summary
- Add a PlayerHistory class (modeled after src/lib/player/Discord.ts) and a Player.LoadHistory method.
- Map snake_case API payload to PascalCase properties, cache on the Player instance, and support force refresh.

Motivation
- Commented test exists for a separate history endpoint.
- Consumers need a simple, typed, cached way to access a player’s team history.

Proposed changes
- New class: src/lib/player/PlayerHistory.ts
- Public PascalCase properties (e.g., TeamId, Game; extendable for TeamName, Role, StartAt, EndAt, ModeKey).
- Constructor accepts string | object and maps from snake_case, mirroring Discord.ts style.
- Player additions:
- LoadHistory(options?: { force?: boolean }): Promise
- History?: PlayerHistory[] and IsHistoryLoaded?: boolean
- Fetch GET /players/{id}/history (or confirmed route), map to PlayerHistory instances, cache, return [] when none.

Acceptance criteria
- LoadHistory returns PlayerHistory[]; no-throw on empty history (returns []).
- Caching works; force option bypasses cache.
- At least TeamId and Game are present on each entry.

Tests
- Unskip and update “load history separate endpoint” in src/__tests__/player.test.ts:
- Expect PascalCase properties (TeamId, Game).
- Add tests for empty history and caching/force behavior.

Open questions
- Confirm exact API route/shape and any pagination or filters.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.