Skip to content

Commit

Permalink
API: Updating BungieAccount constructor to stringify bungieCode
Browse files Browse the repository at this point in the history
  • Loading branch information
0Nom4D committed Jan 10, 2024
1 parent 189cc25 commit 61e8a4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 6 additions & 2 deletions lib/api/models/bungie_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ class BungieAccountData {

BungieAccountData({
required this.bungieGlobalDisplayName,
required this.bungieGlobalDisplayNameCode,
required int bungieGlobalDisplayNameCode,
String? bungieMembershipId,
List<DestinyMembership>? memberships
}) : bungieNetMembershipId = bungieMembershipId ?? "", memberships = memberships ?? [];
}) :
bungieGlobalDisplayNameCode = bungieGlobalDisplayNameCode.toString().padLeft(4, '0'),
bungieNetMembershipId = bungieMembershipId ?? "",
memberships = memberships ?? []
;

String get fullBungieId => "$bungieGlobalDisplayName#$bungieGlobalDisplayNameCode";

Expand Down
22 changes: 11 additions & 11 deletions test/models/bungie_account_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() {

final accountData = BungieAccountData.fromJson(json);
expect(accountData.bungieGlobalDisplayName, "ALED");
expect(accountData.bungieGlobalDisplayNameCode, 3064);
expect(accountData.bungieGlobalDisplayNameCode, "3064");
expect(accountData.bungieNetMembershipId, "31142636");

expect(accountData.fullBungieId, "ALED#3064");
Expand Down Expand Up @@ -58,10 +58,10 @@ void main() {

final accountData = BungieAccountData.fromJson(json);
expect(accountData.bungieGlobalDisplayName, "A");
expect(accountData.bungieGlobalDisplayNameCode, 206);
expect(accountData.bungieGlobalDisplayNameCode, "0206");
expect(accountData.bungieNetMembershipId, "31841225");

expect(accountData.fullBungieId, "A#206");
expect(accountData.fullBungieId, "A#0206");
expect(accountData.isCrossSavedAccount, false);
expect(accountData.isNotCrossSavedAccount, false);
expect(accountData.isSinglePlatformAccount, false);
Expand Down Expand Up @@ -93,10 +93,10 @@ void main() {

final accountData = BungieAccountData.fromJson(json);
expect(accountData.bungieGlobalDisplayName, "A");
expect(accountData.bungieGlobalDisplayNameCode, 196);
expect(accountData.bungieGlobalDisplayNameCode, "0196");
expect(accountData.bungieNetMembershipId, "");

expect(accountData.fullBungieId, "A#196");
expect(accountData.fullBungieId, "A#0196");
expect(accountData.isCrossSavedAccount, false);
expect(accountData.isNotCrossSavedAccount, false);
expect(accountData.isSinglePlatformAccount, true);
Expand All @@ -114,10 +114,10 @@ void main() {

final accountData = BungieAccountData.fromJson(json);
expect(accountData.bungieGlobalDisplayName, "A");
expect(accountData.bungieGlobalDisplayNameCode, 206);
expect(accountData.bungieGlobalDisplayNameCode, "0206");
expect(accountData.bungieNetMembershipId, "");

expect(accountData.fullBungieId, "A#206");
expect(accountData.fullBungieId, "A#0206");
expect(accountData.isCrossSavedAccount, false);
expect(accountData.isNotCrossSavedAccount, false);
expect(accountData.isSinglePlatformAccount, false);
Expand All @@ -134,10 +134,10 @@ void main() {

final accountData = BungieAccountData.fromJson(json);
expect(accountData.bungieGlobalDisplayName, "A");
expect(accountData.bungieGlobalDisplayNameCode, 206);
expect(accountData.bungieGlobalDisplayNameCode, "0206");
expect(accountData.bungieNetMembershipId, "");

expect(accountData.fullBungieId, "A#206");
expect(accountData.fullBungieId, "A#0206");
expect(accountData.isCrossSavedAccount, false);
expect(accountData.isNotCrossSavedAccount, false);
expect(accountData.isSinglePlatformAccount, false);
Expand All @@ -152,10 +152,10 @@ void main() {
bungieGlobalDisplayNameCode: 206
);
expect(accountData.bungieGlobalDisplayName, "A");
expect(accountData.bungieGlobalDisplayNameCode, 206);
expect(accountData.bungieGlobalDisplayNameCode, "0206");
expect(accountData.bungieNetMembershipId, "");

expect(accountData.fullBungieId, "A#206");
expect(accountData.fullBungieId, "A#0206");
expect(accountData.isCrossSavedAccount, false);
expect(accountData.isNotCrossSavedAccount, false);
expect(accountData.isSinglePlatformAccount, false);
Expand Down

0 comments on commit 61e8a4b

Please sign in to comment.