docs/migrating/v1.md
# Migrating to V1
When upgrading from a pre `v1` version to `v1.*.*` there are some breaking
changes to take into account.
If you use any of the below methods you will want to change your usage to
match the **After** example.
## Enums
All skills, bosses, activities, and computed metrics were added to the
[`Metric`][wom.Metric] enum for ease of access from a single source.
The following enums were converted into frozen sets containing the various
[`Metrics`][wom.Metric] they encompass so that you can still easily check
if a metric is a skill, or boss, etc.
- [`Skills`][wom.Skills]
- [`Bosses`][wom.Bosses]
- [`Activities`][wom.Activities]
- [`ComputedMetrics`][wom.ComputedMetrics]
This is probably the most wide-spread change of the release and may
affect you in many places like if statements etc. The fix is very easy though,
just convert most if not all of the places you used the old enums to
[`Metric`][wom.Metric].
The `from_str` and `from_str_maybe` methods were removed from the [`Metric`][wom.Metric] enum.
**Before**
```py
print(wom.Skills.Attack)
print(wom.Bosses.Zulrah)
print(wom.Activities.LastManStanding)
print(wom.ComputedMetrics.Ehp)
slayer = wom.Skills.Slayer
assert slayer in wom.Skills
```
**After**
```py
print(wom.Metric.Attack)
print(wom.Metric.Zulrah)
print(wom.Metric.LastManStanding)
print(wom.Metric.Ehp)
slayer = wom.Metric.Slayer
assert slayer in wom.Skills
```
## Players
### PlayerDetail
The [`PlayerDetail`][wom.PlayerDetail] model now inherits from
[`Player`][wom.Player] and so the `player` property was removed.
**Methods affected**
- [`PlayerService.update_player`][wom.PlayerService.update_player]
- [`PlayerService.get_details`][wom.PlayerService.get_details]
- [`PlayerService.get_details_by_id`][wom.PlayerService.get_details_by_id]
**Before**
```py
result = await client.players.get_details("jonxslays")
player = result.unwrap()
print(player.player.username)
```
**After**
```py
result = await client.players.get_details("jonxslays")
player = result.unwrap()
print(player.username)
```
---
### PlayerAchievementProgress
[`PlayerAchievementProgress`][wom.PlayerAchievementProgress] now inherits from
[`AchievementProgress`][wom.AchievementProgress] and so the `achievement` property was removed.
**Methods affected**
- [`PlayerService.get_achievement_progress`][wom.PlayerService.get_achievement_progress]
**Before**
```py
result = await client.players.get_achievement_progress("Jonxslays")
achievements = result.unwrap()
for achievement in achievements:
print(achievement.achievement.metric)
```
**After**
```py
result = await client.players.get_achievement_progress("Jonxslays")
achievements = result.unwrap()
for achievement in achievements:
print(achievement.metric)
```
---
### PlayerCompetitionStanding
[`PlayerCompetitionStanding`][wom.PlayerCompetitionStanding] now inherits from
[`PlayerParticipation`][wom.PlayerParticipation] and so the `participation` property was removed.
**Methods affected**
- [`PlayerService.get_competition_standings`][wom.PlayerService.get_competition_standings]
**Before**
```py
result = await client.players.get_competition_standings(
"Jonxslays", wom.CompetitionStatus.Ongoing
)
standings = result.unwrap()
for standing in standings:
print(standing.participation.competition.title)
```
**After**
```py
result = await client.players.get_competition_standings(
"Jonxslays", wom.CompetitionStatus.Ongoing
)
standings = result.unwrap()
for standing in standings:
print(standing.competition.title)
```
---
### PlayerArchive
[`PlayerArchive`][wom.PlayerArchive] now inherits from
[`Archive`][wom.Archive] and so the `archive` property was removed.
**Methods affected**
- [`PlayerService.get_archives`][wom.PlayerService.get_archives]
**Before**
```py
result = await client.players.get_archives("Jonxslays")
archives = result.unwrap()
for archive in archives:
print(archive.archive.previous_username)
```
**After**
```py
result = await client.players.get_archives("Jonxslays")
archives = result.unwrap()
for archive in archives:
print(archive.previous_username)
```
---
### PlayerMembership
[`PlayerMembership`][wom.PlayerMembership] now inherits from [`Membership`][wom.Membership]
and so the `membership` property was removed.
**Methods affected**
- [`PlayerService.get_group_memberships`][wom.PlayerService.get_group_memberships]
**Before**
```py
result = await client.players.get_group_memberships("Jonxslays")
memberships = result.unwrap()
for membership in memberships:
print(membership.membership.role)
```
**After**
```py
result = await client.players.get_group_memberships("Jonxslays")
memberships = result.unwrap()
for membership in memberships:
print(membership.role)
```
## Groups
### GroupMembership
`GroupMembership` now inherits from `Membership` and so the `membership`
property was removed.
**Methods affected**
- [`GroupService.change_member_role`][wom.GroupService.change_member_role]
- [`GroupService.get_details`][wom.GroupService.get_details]
- [`GroupService.edit_group`][wom.GroupService.edit_group]
- [`GroupService.create_group`][wom.GroupService.create_group]
**Before**
```py
result = await client.groups.change_member_role(
123, "111-111-111", "Jonxslays", wom.GroupRole.Admiral
)
memberships = result.unwrap()
for membership in memberships:
print(membership.membership.role)
```
**After**
```py
result = await client.groups.change_member_role(
123, "111-111-111", "Jonxslays", wom.GroupRole.Admiral
)
memberships = result.unwrap()
for membership in memberships:
print(membership.role)
```
---
### GroupDetail
[`GroupDetail`][wom.GroupDetail] now inherits from [`Group`][wom.Group]
and so the `group` property was removed.
**Methods affected**
- [`GroupService.get_details`][wom.GroupService.get_details]
- [`GroupService.edit_group`][wom.GroupService.edit_group]
- [`GroupService.create_group`][wom.GroupService.create_group]
**Before**
```py
result = await client.groups.get_details(1234)
group = result.unwrap()
print(group.group.homeworld)
```
**After**
```py
result = await client.groups.get_details(1234)
group = result.unwrap()
print(group.homeworld)
```
## Efficiency
### get_global_leaderboard
The `get_global_leaderboard` method was renamed to
[`get_global_leaderboards`][wom.EfficiencyService.get_global_leaderboards]
to be in more line with the other leaderboard method names.
**Methods affected**
- [`EfficiencyService.get_global_leaderboards`][wom.EfficiencyService.get_global_leaderboards]
**Before**
```py
result = await client.efficiency.get_global_leaderboard(
player_type=wom.PlayerType.Ironman
)
```
**After**
```py
result = await client.efficiency.get_global_leaderboards(
player_type=wom.PlayerType.Ironman
)
```
## Records
### get_global_record_leaderboards
The `get_global_record_leaderboards` method was renamed to
[`get_global_leaderboards`][wom.RecordService.get_global_leaderboards] to
be more in line with the other leaderboard method names.
**Methods affected**
- [`RecordService.get_global_record_leaderboards`][wom.RecordService.get_global_leaderboards]
**Before**
```py
await client.records.get_global_record_leaderboards(
wom.Metric.Attack,
wom.Period.Day,
country=wom.Country.Us,
)
```
**After**
```py
await client.records.get_global_leaderboards(
wom.Metric.Attack,
wom.Period.Day,
country=wom.Country.Us,
)
```
---
### RecordLeaderboardEntry
[`RecordLeaderboardEntry`][wom.RecordLeaderboardEntry] now inherits from
[`Record`][wom.Record] and so the `record` property was removed.
**Methods affected**
- [`RecordService.get_global_leaderboards`][wom.RecordService.get_global_leaderboards]
- [`GroupService.get_records`][wom.GroupService.get_records]
**Before**
```py
result = await client.records.get_global_leaderboards(
wom.Metric.Attack,
wom.Period.Day,
country=wom.Country.Us,
)
leaderboard = result.unwrap()
for record in leaderboard:
print(record.record.value)
```
**After**
```py
result = await client.records.get_global_leaderboards(
wom.Metric.Attack,
wom.Period.Day,
country=wom.Country.Us,
)
leaderboard = result.unwrap()
for record in leaderboard:
print(record.value)
```
## Competitions
### CompetitionParticipationDetail
[`CompetitionParticipationDetail`][wom.CompetitionParticipationDetail] now inherits
from [`CompetitionParticipation`][wom.CompetitionParticipation] and so the
`participation` property was removed.
**Methods affected**
- [`CompetitionService.get_details`][wom.CompetitionService.get_details]
**Before**
```py
result = await client.competitions.get_details(123)
detail = result.unwrap()
for participation in detail.participations:
print(participation.participation.team_name)
```
**After**
```py
result = await client.competitions.get_details(123)
detail = result.unwrap()
for participation in detail.participations:
print(participation.team_name)
```
---
### CompetitionDetail
[`CompetitionDetail`][wom.CompetitionDetail] now inherits from
[`Competition`][wom.Competition] and so the `competition` property was removed.
**Methods affected**
- [`CompetitionService.get_details`][wom.CompetitionService.get_details]
**Before**
```py
result = await client.competitions.get_details(123)
competition = result.unwrap()
print(competition.competition.metric)
```
**After**
```py
result = await client.competitions.get_details(123)
competition = result.unwrap()
print(competition.metric)
```
---
### CompetitionWithParticipations
`CompetitionWithParticipations` was renamed to
[`CreatedCompetitionDetail`][wom.CreatedCompetitionDetail] because the
`participations` property was removed and added to [`Competition`][wom.Competition]
and the name was no longer an accurate representation of the object.
This means the `verification_code` on
[`CreatedCompetitionDetail`][wom.CreatedCompetitionDetail] no longer has
to be optional.
**Methods affected**
- [`CompetitionService.create_competition`][wom.CompetitionService.create_competition]
**Before**
```py
result = await client.competitions.create_competition(
"Slayer week",
wom.Metric.Slayer,
starts_at=datetime.now() + timedelta(days=7),
ends_at=datetime.now() + timedelta(days=14),
teams=[
wom.Team("The good team", ["jonxslays", "rro"]),
wom.Team("The suspicious team", ["psikoi", "aluminoti"]),
],
)
detail = result.unwrap()
# We cant make this assertion with the previous model.
# assert isinstance(detail.verification_code, str)
for participation in detail.participations:
print(participation)
```
**After**
```py
result = await client.competitions.create_competition(
"Slayer week",
wom.Metric.Slayer,
starts_at=datetime.now() + timedelta(days=7),
ends_at=datetime.now() + timedelta(days=14),
teams=[
wom.Team("The good team", ["jonxslays", "rro"]),
wom.Team("The suspicious team", ["psikoi", "aluminoti"]),
],
)
detail = result.unwrap()
assert isinstance(detail.verification_code, str)
for participation in detail.competition.participations:
print(participation)
```
---
### edit_competition
The [`edit_competition`][wom.CompetitionService.edit_competition] method
now returns a [`Competition`][wom.Competition] instead of a
`CompetitionWithParticipations` (which was removed).
**Methods affected**
- [`CompetitionService.edit_competition`][wom.CompetitionService.edit_competition]
**Before**
```py
result = await client.competitions.edit_competition(
123, "111-111-111", title="Skill of the month - Ranged"
)
competition = result.unwrap()
print(competition.competition.title)
```
**After**
```py
result = await client.competitions.edit_competition(
123, "111-111-111", title="Skill of the month - Ranged"
)
competition = result.unwrap()
print(competition.title)
```