diff --git a/.env b/.env index 55ed1c6..23db603 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ CLASHBOT_SERVICE_URL=http://localhost:8080 MOCK_DISCORD_SERVICE=false -discordClientId=1234567890 \ No newline at end of file +discordClientId=1234567890 +clashbotEventUrl=ws://localhost:8000/ws diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 076a32f..b6fa2a1 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -40,7 +40,8 @@ jobs: ./ciScripts/build-env-file.sh \ CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \ MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \ - discordClientId ${DISCORD_CLIENT_ID} + discordClientId ${DISCORD_CLIENT_ID} \ + clashbotEventUrl http://localhost:8080/api/v2/ws - name: Unit Tests run: flutter test "test/unit/" >> $GITHUB_STEP_SUMMARY @@ -73,7 +74,8 @@ jobs: ./ciScripts/build-env-file.sh \ CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \ MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \ - discordClientId ${DISCORD_CLIENT_ID} + discordClientId ${DISCORD_CLIENT_ID} \ + clashbotEventUrl http://localhost:8080/api/v2/ws - name: Generate Envied Files run: flutter pub run build_runner build --delete-conflicting-outputs @@ -119,7 +121,8 @@ jobs: ./ciScripts/build-env-file.sh \ CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \ MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \ - discordClientId ${DISCORD_CLIENT_ID} + discordClientId ${DISCORD_CLIENT_ID} \ + clashbotEventUrl http://localhost:8080/api/v2/ws - name: Generate Envied Files run: flutter pub run build_runner build --delete-conflicting-outputs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48eb185..cf0f3e2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,7 +35,8 @@ jobs: CLASHBOT_SERVICE_URL: ${{ vars.CLASHBOT_SERVICE_URL }} MOCK_DISCORD_SERVICE: false DISCORD_CLIENT_ID: ${{ vars.DISCORD_CLIENT_ID }} - run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} discordClientId ${DISCORD_CLIENT_ID} + CLASHBOT_EVENT_URL: ${{ vars.CLASHBOT_EVENT_URL }} + run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} discordClientId ${DISCORD_CLIENT_ID} clashbotEventUrl ${CLASHBOT_EVENT_URL} - name: Generate Envied Files run: | diff --git a/.gitignore b/.gitignore index 98474b1..1c006b4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related @@ -31,6 +33,7 @@ migrate_working_dir/ .pub-cache/ .pub/ /build/ +/widgetbook/build/ # Symbolication related app.*.symbols diff --git a/clash-bot-api/.gitignore b/clash-bot-api/.gitignore index 1be28ce..0f74d29 100644 --- a/clash-bot-api/.gitignore +++ b/clash-bot-api/.gitignore @@ -3,7 +3,9 @@ .dart_tool/ .packages build/ -pubspec.lock # Except for application packages + +# Except for application packages +pubspec.lock doc/api/ diff --git a/clash-bot-api/.openapi-generator/FILES b/clash-bot-api/.openapi-generator/FILES index 7339af2..19586e6 100644 --- a/clash-bot-api/.openapi-generator/FILES +++ b/clash-bot-api/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore .travis.yml README.md analysis_options.yaml diff --git a/clash-bot-api/.openapi-generator/VERSION b/clash-bot-api/.openapi-generator/VERSION index 6d54bbd..5f84a81 100644 --- a/clash-bot-api/.openapi-generator/VERSION +++ b/clash-bot-api/.openapi-generator/VERSION @@ -1 +1 @@ -6.0.1 \ No newline at end of file +7.12.0 diff --git a/clash-bot-api/README.md b/clash-bot-api/README.md index ec37ad3..45dc70a 100644 --- a/clash-bot-api/README.md +++ b/clash-bot-api/README.md @@ -1,4 +1,4 @@ -# clash_bot_api +# openapi # Welcome to Clash Bot! Where all of your League of Legends Clash scheduling needs are met! @@ -17,6 +17,7 @@ are trademarks or registered trademarks of Riot Games, Inc. League of Legends © This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: 2.0.0 +- Generator version: 7.12.0 - Build package: org.openapitools.codegen.languages.DartClientCodegen ## Requirements @@ -29,7 +30,7 @@ Dart 2.12 or later If this Dart package is published to Github, add the following dependency to your pubspec.yaml ``` dependencies: - clash_bot_api: + openapi: git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git ``` @@ -37,8 +38,8 @@ dependencies: To use the package in your local drive, add the following dependency to your pubspec.yaml ``` dependencies: - clash_bot_api: - path: /path/to/clash_bot_api + openapi: + path: /path/to/openapi ``` ## Tests @@ -50,7 +51,7 @@ TODO Please follow the [installation procedure](#installation--usage) and then run the following: ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = ChampionsApi(); @@ -94,6 +95,7 @@ Class | Method | HTTP request | Description *TentativeApi* | [**retrieveTentativeQueues**](doc//TentativeApi.md#retrievetentativequeues) | **GET** /tentatives | *TournamentApi* | [**createTournament**](doc//TournamentApi.md#createtournament) | **POST** /tournaments | *TournamentApi* | [**getTournaments**](doc//TournamentApi.md#gettournaments) | **GET** /tournaments | +*TournamentApi* | [**retrieveRiotClashTournaments**](doc//TournamentApi.md#retrieveriotclashtournaments) | **PATCH** /tournaments/riot | *UserApi* | [**addUsersSelectedServers**](doc//UserApi.md#addusersselectedservers) | **PATCH** /users/{discordId}/servers | *UserApi* | [**createUser**](doc//UserApi.md#createuser) | **POST** /users | *UserApi* | [**createUsersSelectedServers**](doc//UserApi.md#createusersselectedservers) | **POST** /users/{discordId}/servers | @@ -139,7 +141,7 @@ Class | Method | HTTP request | Description ## Documentation For Authorization - All endpoints do not require authorization. +Endpoints do not require authorization. ## Author diff --git a/clash-bot-api/doc/ArchiveMetadata.md b/clash-bot-api/doc/ArchiveMetadata.md index a150a02..5eb079e 100644 --- a/clash-bot-api/doc/ArchiveMetadata.md +++ b/clash-bot-api/doc/ArchiveMetadata.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.ArchiveMetadata +# openapi.model.ArchiveMetadata ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/BaseTournament.md b/clash-bot-api/doc/BaseTournament.md index 7bbea01..40789fa 100644 --- a/clash-bot-api/doc/BaseTournament.md +++ b/clash-bot-api/doc/BaseTournament.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.BaseTournament +# openapi.model.BaseTournament ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Champion.md b/clash-bot-api/doc/Champion.md index ea8e2fe..66eb5d2 100644 --- a/clash-bot-api/doc/Champion.md +++ b/clash-bot-api/doc/Champion.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Champion +# openapi.model.Champion ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Champions.md b/clash-bot-api/doc/Champions.md index 4083e99..cdf237f 100644 --- a/clash-bot-api/doc/Champions.md +++ b/clash-bot-api/doc/Champions.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Champions +# openapi.model.Champions ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/ChampionsApi.md b/clash-bot-api/doc/ChampionsApi.md index 6d8a32f..dd56c19 100644 --- a/clash-bot-api/doc/ChampionsApi.md +++ b/clash-bot-api/doc/ChampionsApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.ChampionsApi +# openapi.api.ChampionsApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -24,7 +24,7 @@ Adds the requested champion to the users preferred champions. Cannot be greater ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = ChampionsApi(); final xCausedBy = xCausedBy_example; // String | @@ -71,7 +71,7 @@ Updates the users preferred champions with an entirely new list. Cannot be great ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = ChampionsApi(); final xCausedBy = xCausedBy_example; // String | @@ -118,7 +118,7 @@ Removes the requested champion to the users preferred champions. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = ChampionsApi(); final xCausedBy = xCausedBy_example; // String | @@ -165,7 +165,7 @@ Returns a list of preferred champions that the User has. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = ChampionsApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/doc/CreateUserRequest.md b/clash-bot-api/doc/CreateUserRequest.md index 811ab6a..2f9a129 100644 --- a/clash-bot-api/doc/CreateUserRequest.md +++ b/clash-bot-api/doc/CreateUserRequest.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.CreateUserRequest +# openapi.model.CreateUserRequest ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/DetailedTournament.md b/clash-bot-api/doc/DetailedTournament.md index 65cd6cc..b8e95c0 100644 --- a/clash-bot-api/doc/DetailedTournament.md +++ b/clash-bot-api/doc/DetailedTournament.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.DetailedTournament +# openapi.model.DetailedTournament ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Error.md b/clash-bot-api/doc/Error.md index 527538c..446a3fd 100644 --- a/clash-bot-api/doc/Error.md +++ b/clash-bot-api/doc/Error.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Error +# openapi.model.Error ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Event.md b/clash-bot-api/doc/Event.md index 21f9475..d6b6b9b 100644 --- a/clash-bot-api/doc/Event.md +++ b/clash-bot-api/doc/Event.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Event +# openapi.model.Event ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/EventType.md b/clash-bot-api/doc/EventType.md index 5f2a579..244f15c 100644 --- a/clash-bot-api/doc/EventType.md +++ b/clash-bot-api/doc/EventType.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.EventType +# openapi.model.EventType ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/MaintenanceApi.md b/clash-bot-api/doc/MaintenanceApi.md index fe90007..26e32dc 100644 --- a/clash-bot-api/doc/MaintenanceApi.md +++ b/clash-bot-api/doc/MaintenanceApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.MaintenanceApi +# openapi.api.MaintenanceApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -21,7 +21,7 @@ Will move all Teams and Tentative Queues that are now inactive into an archive t ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = MaintenanceApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/doc/Player.md b/clash-bot-api/doc/Player.md index d865d70..5624f72 100644 --- a/clash-bot-api/doc/Player.md +++ b/clash-bot-api/doc/Player.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Player +# openapi.model.Player ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/PositionDetails.md b/clash-bot-api/doc/PositionDetails.md index 5f1a08e..716d78e 100644 --- a/clash-bot-api/doc/PositionDetails.md +++ b/clash-bot-api/doc/PositionDetails.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.PositionDetails +# openapi.model.PositionDetails ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Role.md b/clash-bot-api/doc/Role.md index 044c705..e477596 100644 --- a/clash-bot-api/doc/Role.md +++ b/clash-bot-api/doc/Role.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Role +# openapi.model.Role ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Server.md b/clash-bot-api/doc/Server.md index 96c9034..3310683 100644 --- a/clash-bot-api/doc/Server.md +++ b/clash-bot-api/doc/Server.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Server +# openapi.model.Server ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Servers.md b/clash-bot-api/doc/Servers.md index de2e914..8dc8ef6 100644 --- a/clash-bot-api/doc/Servers.md +++ b/clash-bot-api/doc/Servers.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Servers +# openapi.model.Servers ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Subscription.md b/clash-bot-api/doc/Subscription.md index 157d54d..d08bb2c 100644 --- a/clash-bot-api/doc/Subscription.md +++ b/clash-bot-api/doc/Subscription.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Subscription +# openapi.model.Subscription ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/SubscriptionApi.md b/clash-bot-api/doc/SubscriptionApi.md index b1c658c..165e9b0 100644 --- a/clash-bot-api/doc/SubscriptionApi.md +++ b/clash-bot-api/doc/SubscriptionApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.SubscriptionApi +# openapi.api.SubscriptionApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -23,7 +23,7 @@ Retrieve details on a user's subscription. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = SubscriptionApi(); final xCausedBy = xCausedBy_example; // String | @@ -70,7 +70,7 @@ Subscribes the User to the specified subscription. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = SubscriptionApi(); final xCausedBy = xCausedBy_example; // String | @@ -117,7 +117,7 @@ Unsubscribes the User from the specified subscription. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = SubscriptionApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/doc/SubscriptionType.md b/clash-bot-api/doc/SubscriptionType.md index 5f20a50..8eaf4f1 100644 --- a/clash-bot-api/doc/SubscriptionType.md +++ b/clash-bot-api/doc/SubscriptionType.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.SubscriptionType +# openapi.model.SubscriptionType ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Team.md b/clash-bot-api/doc/Team.md index aa3f005..f0ad096 100644 --- a/clash-bot-api/doc/Team.md +++ b/clash-bot-api/doc/Team.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Team +# openapi.model.Team ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TeamApi.md b/clash-bot-api/doc/TeamApi.md index 8044996..b877162 100644 --- a/clash-bot-api/doc/TeamApi.md +++ b/clash-bot-api/doc/TeamApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.TeamApi +# openapi.api.TeamApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -26,7 +26,7 @@ Assign's a User to the specified Team based on the role provided. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | @@ -75,7 +75,7 @@ Creates a Team with the defined details ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | @@ -120,7 +120,7 @@ Removes a User from the specified Team. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | @@ -167,7 +167,7 @@ Returns a single Clash Bot Team based on the id provided. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | @@ -212,7 +212,7 @@ Returns a list of Teams. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | @@ -265,7 +265,7 @@ Updates an existing Clash Bot Team's metadata. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TeamApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/doc/TeamEvent.md b/clash-bot-api/doc/TeamEvent.md index 64be490..0033f93 100644 --- a/clash-bot-api/doc/TeamEvent.md +++ b/clash-bot-api/doc/TeamEvent.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TeamEvent +# openapi.model.TeamEvent ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TeamPlayer.md b/clash-bot-api/doc/TeamPlayer.md index c3b4e36..d63cff5 100644 --- a/clash-bot-api/doc/TeamPlayer.md +++ b/clash-bot-api/doc/TeamPlayer.md @@ -1,15 +1,14 @@ -# clash_bot_api.model.TeamPlayer +# openapi.model.TeamPlayer ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **discordId** | **String** | Discord Id for the Player | [optional] -**name** | **String** | The Players discord name | [optional] **champions** | [**List**](Champion.md) | A list of the Users preferred champions. | [optional] [default to const []] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/clash-bot-api/doc/TeamPlayerDetails.md b/clash-bot-api/doc/TeamPlayerDetails.md index 159cb47..804b374 100644 --- a/clash-bot-api/doc/TeamPlayerDetails.md +++ b/clash-bot-api/doc/TeamPlayerDetails.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TeamPlayerDetails +# openapi.model.TeamPlayerDetails ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TeamRequired.md b/clash-bot-api/doc/TeamRequired.md index ea89c76..5c99ba6 100644 --- a/clash-bot-api/doc/TeamRequired.md +++ b/clash-bot-api/doc/TeamRequired.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TeamRequired +# openapi.model.TeamRequired ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TeamTournamentDetails.md b/clash-bot-api/doc/TeamTournamentDetails.md index 43b4edb..64448e0 100644 --- a/clash-bot-api/doc/TeamTournamentDetails.md +++ b/clash-bot-api/doc/TeamTournamentDetails.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TeamTournamentDetails +# openapi.model.TeamTournamentDetails ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TeamUpdate.md b/clash-bot-api/doc/TeamUpdate.md index 81b2c1c..6b16e9d 100644 --- a/clash-bot-api/doc/TeamUpdate.md +++ b/clash-bot-api/doc/TeamUpdate.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TeamUpdate +# openapi.model.TeamUpdate ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Teams.md b/clash-bot-api/doc/Teams.md index d83286f..ff10e40 100644 --- a/clash-bot-api/doc/Teams.md +++ b/clash-bot-api/doc/Teams.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Teams +# openapi.model.Teams ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Tentative.md b/clash-bot-api/doc/Tentative.md index dc8eb6b..5cbf07c 100644 --- a/clash-bot-api/doc/Tentative.md +++ b/clash-bot-api/doc/Tentative.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Tentative +# openapi.model.Tentative ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TentativeApi.md b/clash-bot-api/doc/TentativeApi.md index 3bb3226..9d7738a 100644 --- a/clash-bot-api/doc/TentativeApi.md +++ b/clash-bot-api/doc/TentativeApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.TentativeApi +# openapi.api.TentativeApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -25,7 +25,7 @@ Updates an existing Tentative queue. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TentativeApi(); final xCausedBy = xCausedBy_example; // String | @@ -72,7 +72,7 @@ Creates a Tentative queue. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TentativeApi(); final xCausedBy = xCausedBy_example; // String | @@ -117,7 +117,7 @@ Removes a User from the specified Tentative Queue. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TentativeApi(); final xCausedBy = xCausedBy_example; // String | @@ -164,7 +164,7 @@ Retrieves a Tentative queues. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TentativeApi(); final xCausedBy = xCausedBy_example; // String | @@ -209,7 +209,7 @@ Retrieves a list of Tentative queues. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TentativeApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/doc/TentativePlayer.md b/clash-bot-api/doc/TentativePlayer.md index 857f043..e6bcc00 100644 --- a/clash-bot-api/doc/TentativePlayer.md +++ b/clash-bot-api/doc/TentativePlayer.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TentativePlayer +# openapi.model.TentativePlayer ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TentativeRequired.md b/clash-bot-api/doc/TentativeRequired.md index b4ff0b1..40f388f 100644 --- a/clash-bot-api/doc/TentativeRequired.md +++ b/clash-bot-api/doc/TentativeRequired.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.TentativeRequired +# openapi.model.TentativeRequired ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/Tentatives.md b/clash-bot-api/doc/Tentatives.md index 17b1635..b433be7 100644 --- a/clash-bot-api/doc/Tentatives.md +++ b/clash-bot-api/doc/Tentatives.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Tentatives +# openapi.model.Tentatives ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/TournamentApi.md b/clash-bot-api/doc/TournamentApi.md index 0f8ec8a..62a417b 100644 --- a/clash-bot-api/doc/TournamentApi.md +++ b/clash-bot-api/doc/TournamentApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.TournamentApi +# openapi.api.TournamentApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -11,6 +11,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**createTournament**](TournamentApi.md#createtournament) | **POST** /tournaments | [**getTournaments**](TournamentApi.md#gettournaments) | **GET** /tournaments | +[**retrieveRiotClashTournaments**](TournamentApi.md#retrieveriotclashtournaments) | **PATCH** /tournaments/riot | # **createTournament** @@ -22,7 +23,7 @@ To create a Tournament ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TournamentApi(); final xCausedBy = xCausedBy_example; // String | @@ -65,7 +66,7 @@ No authorization required ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = TournamentApi(); final xCausedBy = xCausedBy_example; // String | @@ -105,3 +106,42 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **retrieveRiotClashTournaments** +> Tournaments retrieveRiotClashTournaments() + + + +Will retrieve Clash Tournaments from Riot's League of Legends API + +### Example +```dart +import 'package:openapi/api.dart'; + +final api_instance = TournamentApi(); + +try { + final result = api_instance.retrieveRiotClashTournaments(); + print(result); +} catch (e) { + print('Exception when calling TournamentApi->retrieveRiotClashTournaments: $e\n'); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**Tournaments**](Tournaments.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/clash-bot-api/doc/Tournaments.md b/clash-bot-api/doc/Tournaments.md index 6ec4cda..7d75d6a 100644 --- a/clash-bot-api/doc/Tournaments.md +++ b/clash-bot-api/doc/Tournaments.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.Tournaments +# openapi.model.Tournaments ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/UpdateUserRequest.md b/clash-bot-api/doc/UpdateUserRequest.md index eba9cc6..a2cdd59 100644 --- a/clash-bot-api/doc/UpdateUserRequest.md +++ b/clash-bot-api/doc/UpdateUserRequest.md @@ -1,8 +1,8 @@ -# clash_bot_api.model.UpdateUserRequest +# openapi.model.UpdateUserRequest ## Load the model package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` ## Properties diff --git a/clash-bot-api/doc/UserApi.md b/clash-bot-api/doc/UserApi.md index e8619e7..b71b87c 100644 --- a/clash-bot-api/doc/UserApi.md +++ b/clash-bot-api/doc/UserApi.md @@ -1,8 +1,8 @@ -# clash_bot_api.api.UserApi +# openapi.api.UserApi ## Load the API package ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; ``` All URIs are relative to *http://localhost:8080/api/v2* @@ -27,7 +27,7 @@ Adds the selected server to the users selected servers. Cannot be greater than a ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -74,7 +74,7 @@ Create a new Clash Bot Player. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -119,7 +119,7 @@ Updates the users selected servers with an entirely new list. Cannot be greater ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -166,7 +166,7 @@ Retrieve a Clash Bot Player Details ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -211,7 +211,7 @@ Removes the selected server to the users selected servers. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -258,7 +258,7 @@ Returns a list of selected servers that the User has. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | @@ -303,7 +303,7 @@ Update an existing Clash Bot Player. ### Example ```dart -import 'package:clash_bot_api/api.dart'; +import 'package:openapi/api.dart'; final api_instance = UserApi(); final xCausedBy = xCausedBy_example; // String | diff --git a/clash-bot-api/lib/api.dart b/clash-bot-api/lib/api.dart index ceda0c1..144387b 100644 --- a/clash-bot-api/lib/api.dart +++ b/clash-bot-api/lib/api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -14,6 +14,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:http/http.dart'; import 'package:intl/intl.dart'; import 'package:meta/meta.dart'; @@ -67,11 +68,16 @@ part 'model/tournaments.dart'; part 'model/update_user_request.dart'; +/// An [ApiClient] instance that uses the default values obtained from +/// the OpenAPI specification file. +var defaultApiClient = ApiClient(); + const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; const _dateEpochMarker = 'epoch'; +const _deepEquality = DeepCollectionEquality(); final _dateFormatter = DateFormat('yyyy-MM-dd'); final _regList = RegExp(r'^List<(.*)>$'); final _regSet = RegExp(r'^Set<(.*)>$'); final _regMap = RegExp(r'^Map$'); -ApiClient defaultApiClient = ApiClient(); +bool _isEpochMarker(String? pattern) => pattern == _dateEpochMarker || pattern == '/$_dateEpochMarker/'; diff --git a/clash-bot-api/lib/api/champions_api.dart b/clash-bot-api/lib/api/champions_api.dart index 9d15ff5..49f547b 100644 --- a/clash-bot-api/lib/api/champions_api.dart +++ b/clash-bot-api/lib/api/champions_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api/maintenance_api.dart b/clash-bot-api/lib/api/maintenance_api.dart index abe65a1..e5fa4a9 100644 --- a/clash-bot-api/lib/api/maintenance_api.dart +++ b/clash-bot-api/lib/api/maintenance_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api/subscription_api.dart b/clash-bot-api/lib/api/subscription_api.dart index f9199b5..a759ca8 100644 --- a/clash-bot-api/lib/api/subscription_api.dart +++ b/clash-bot-api/lib/api/subscription_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api/team_api.dart b/clash-bot-api/lib/api/team_api.dart index 65238d1..fc1459b 100644 --- a/clash-bot-api/lib/api/team_api.dart +++ b/clash-bot-api/lib/api/team_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api/tentative_api.dart b/clash-bot-api/lib/api/tentative_api.dart index 3cb06e9..bc92062 100644 --- a/clash-bot-api/lib/api/tentative_api.dart +++ b/clash-bot-api/lib/api/tentative_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api/tournament_api.dart b/clash-bot-api/lib/api/tournament_api.dart index 9971ca8..94f6675 100644 --- a/clash-bot-api/lib/api/tournament_api.dart +++ b/clash-bot-api/lib/api/tournament_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -150,4 +150,48 @@ class TournamentApi { } return null; } + + /// Will retrieve Clash Tournaments from Riot's League of Legends API + /// + /// Note: This method returns the HTTP [Response]. + Future retrieveRiotClashTournamentsWithHttpInfo() async { + // ignore: prefer_const_declarations + final path = r'/tournaments/riot'; + + // ignore: prefer_final_locals + Object? postBody; + + final queryParams = []; + final headerParams = {}; + final formParams = {}; + + const contentTypes = []; + + + return apiClient.invokeAPI( + path, + 'PATCH', + queryParams, + postBody, + headerParams, + formParams, + contentTypes.isEmpty ? null : contentTypes.first, + ); + } + + /// Will retrieve Clash Tournaments from Riot's League of Legends API + Future retrieveRiotClashTournaments() async { + final response = await retrieveRiotClashTournamentsWithHttpInfo(); + if (response.statusCode >= HttpStatus.badRequest) { + throw ApiException(response.statusCode, await _decodeBodyBytes(response)); + } + // When a remote server returns no body with a status of 204, we shall not decode it. + // At the time of writing this, `dart:convert` will throw an "Unexpected end of input" + // FormatException when trying to decode an empty string. + if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) { + return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Tournaments',) as Tournaments; + + } + return null; + } } diff --git a/clash-bot-api/lib/api/user_api.dart b/clash-bot-api/lib/api/user_api.dart index 9f69103..c246b51 100644 --- a/clash-bot-api/lib/api/user_api.dart +++ b/clash-bot-api/lib/api/user_api.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api_client.dart b/clash-bot-api/lib/api_client.dart index 54727d5..19ac034 100644 --- a/clash-bot-api/lib/api_client.dart +++ b/clash-bot-api/lib/api_client.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -11,11 +11,13 @@ part of openapi.api; class ApiClient { - ApiClient({this.basePath = 'http://localhost:8080/api/v2', this.authentication}); + ApiClient({this.basePath = 'http://localhost:8080/api/v2', this.authentication,}); final String basePath; + final Authentication? authentication; var _client = Client(); + final _defaultHeaderMap = {}; /// Returns the current HTTP [Client] instance to use in this class. /// @@ -27,15 +29,12 @@ class ApiClient { _client = newClient; } - final _defaultHeaderMap = {}; - final Authentication? authentication; + Map get defaultHeaderMap => _defaultHeaderMap; void addDefaultHeader(String key, String value) { _defaultHeaderMap[key] = value; } - Map get defaultHeaderMap => _defaultHeaderMap; - // We don't use a Map for queryParams. // If collectionFormat is 'multi', a key might appear multiple times. Future invokeAPI( @@ -47,7 +46,7 @@ class ApiClient { Map formParams, String? contentType, ) async { - _updateParamsForAuth(queryParams, headerParams); + await authentication?.applyToParams(queryParams, headerParams); headerParams.addAll(_defaultHeaderMap); if (contentType != null) { @@ -144,19 +143,19 @@ class ApiClient { ); } - Future deserializeAsync(String json, String targetType, {bool growable = false,}) async => + Future deserializeAsync(String value, String targetType, {bool growable = false,}) async => // ignore: deprecated_member_use_from_same_package - deserialize(json, targetType, growable: growable); + deserialize(value, targetType, growable: growable); @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.') - dynamic deserialize(String json, String targetType, {bool growable = false,}) { + dynamic deserialize(String value, String targetType, {bool growable = false,}) { // Remove all spaces. Necessary for regular expressions as well. targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments // If the expected target type is String, nothing to do... return targetType == 'String' - ? json - : _deserialize(jsonDecode(json), targetType, growable: growable); + ? value + : fromJson(json.decode(value), targetType, growable: growable); } // ignore: deprecated_member_use_from_same_package @@ -165,17 +164,8 @@ class ApiClient { @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.') String serialize(Object? value) => value == null ? '' : json.encode(value); - /// Update query and header parameters based on authentication settings. - void _updateParamsForAuth( - List queryParams, - Map headerParams, - ) { - if (authentication != null) { - authentication!.applyToParams(queryParams, headerParams); - } - } - - static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) { + /// Returns a native instance of an OpenAPI class matching the [specified type][targetType]. + static dynamic fromJson(dynamic value, String targetType, {bool growable = false,}) { try { switch (targetType) { case 'String': @@ -256,18 +246,18 @@ class ApiClient { dynamic match; if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) { return value - .map((dynamic v) => _deserialize(v, match, growable: growable,)) + .map((dynamic v) => fromJson(v, match, growable: growable,)) .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) { return value - .map((dynamic v) => _deserialize(v, match, growable: growable,)) + .map((dynamic v) => fromJson(v, match, growable: growable,)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) { return Map.fromIterables( value.keys.cast(), - value.values.map((dynamic v) => _deserialize(v, match, growable: growable,)), + value.values.map((dynamic v) => fromJson(v, match, growable: growable,)), ); } } @@ -296,6 +286,17 @@ class DeserializationMessage { final bool growable; } +/// Primarily intended for use in an isolate. +Future decodeAsync(DeserializationMessage message) async { + // Remove all spaces. Necessary for regular expressions as well. + final targetType = message.targetType.replaceAll(' ', ''); + + // If the expected target type is String, nothing to do... + return targetType == 'String' + ? message.json + : json.decode(message.json); +} + /// Primarily intended for use in an isolate. Future deserializeAsync(DeserializationMessage message) async { // Remove all spaces. Necessary for regular expressions as well. @@ -304,8 +305,8 @@ Future deserializeAsync(DeserializationMessage message) async { // If the expected target type is String, nothing to do... return targetType == 'String' ? message.json - : ApiClient._deserialize( - jsonDecode(message.json), + : ApiClient.fromJson( + json.decode(message.json), targetType, growable: message.growable, ); diff --git a/clash-bot-api/lib/api_exception.dart b/clash-bot-api/lib/api_exception.dart index 796f7f7..53077d6 100644 --- a/clash-bot-api/lib/api_exception.dart +++ b/clash-bot-api/lib/api_exception.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first diff --git a/clash-bot-api/lib/api_helper.dart b/clash-bot-api/lib/api_helper.dart index 775d43d..65f4945 100644 --- a/clash-bot-api/lib/api_helper.dart +++ b/clash-bot-api/lib/api_helper.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -79,6 +79,9 @@ Future _decodeBodyBytes(Response response) async { /// Returns a valid [T] value found at the specified Map [key], null otherwise. T? mapValueOfType(dynamic map, String key) { final dynamic value = map is Map ? map[key] : null; + if (T == double && value is int) { + return value.toDouble() as T; + } return value is T ? value : null; } @@ -96,7 +99,7 @@ DateTime? mapDateTime(dynamic map, String key, [String? pattern]) { if (value is int) { millis = value; } else if (value is String) { - if (pattern == _dateEpochMarker) { + if (_isEpochMarker(pattern)) { millis = int.tryParse(value); } else { return DateTime.tryParse(value); diff --git a/clash-bot-api/lib/auth/api_key_auth.dart b/clash-bot-api/lib/auth/api_key_auth.dart index e304eda..6c56217 100644 --- a/clash-bot-api/lib/auth/api_key_auth.dart +++ b/clash-bot-api/lib/auth/api_key_auth.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -20,7 +20,7 @@ class ApiKeyAuth implements Authentication { String apiKey = ''; @override - void applyToParams(List queryParams, Map headerParams) { + Future applyToParams(List queryParams, Map headerParams,) async { final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey'; if (paramValue.isNotEmpty) { diff --git a/clash-bot-api/lib/auth/authentication.dart b/clash-bot-api/lib/auth/authentication.dart index 49baf7c..5377fb6 100644 --- a/clash-bot-api/lib/auth/authentication.dart +++ b/clash-bot-api/lib/auth/authentication.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -13,5 +13,5 @@ part of openapi.api; // ignore: one_member_abstracts abstract class Authentication { /// Apply authentication settings to header and query params. - void applyToParams(List queryParams, Map headerParams); + Future applyToParams(List queryParams, Map headerParams); } diff --git a/clash-bot-api/lib/auth/http_basic_auth.dart b/clash-bot-api/lib/auth/http_basic_auth.dart index 81abd71..5e8b1c4 100644 --- a/clash-bot-api/lib/auth/http_basic_auth.dart +++ b/clash-bot-api/lib/auth/http_basic_auth.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -17,7 +17,7 @@ class HttpBasicAuth implements Authentication { String password; @override - void applyToParams(List queryParams, Map headerParams) { + Future applyToParams(List queryParams, Map headerParams,) async { if (username.isNotEmpty && password.isNotEmpty) { final credentials = '$username:$password'; headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}'; diff --git a/clash-bot-api/lib/auth/http_bearer_auth.dart b/clash-bot-api/lib/auth/http_bearer_auth.dart index 213f348..847dc05 100644 --- a/clash-bot-api/lib/auth/http_bearer_auth.dart +++ b/clash-bot-api/lib/auth/http_bearer_auth.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -27,7 +27,7 @@ class HttpBearerAuth implements Authentication { } @override - void applyToParams(List queryParams, Map headerParams) { + Future applyToParams(List queryParams, Map headerParams,) async { if (_accessToken == null) { return; } diff --git a/clash-bot-api/lib/auth/oauth.dart b/clash-bot-api/lib/auth/oauth.dart index e9b87cf..73fd820 100644 --- a/clash-bot-api/lib/auth/oauth.dart +++ b/clash-bot-api/lib/auth/oauth.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -16,7 +16,7 @@ class OAuth implements Authentication { String accessToken; @override - void applyToParams(List queryParams, Map headerParams) { + Future applyToParams(List queryParams, Map headerParams,) async { if (accessToken.isNotEmpty) { headerParams['Authorization'] = 'Bearer $accessToken'; } diff --git a/clash-bot-api/lib/model/archive_metadata.dart b/clash-bot-api/lib/model/archive_metadata.dart index ad753f3..fc059d9 100644 --- a/clash-bot-api/lib/model/archive_metadata.dart +++ b/clash-bot-api/lib/model/archive_metadata.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -47,9 +47,9 @@ class ArchiveMetadata { @override bool operator ==(Object other) => identical(this, other) || other is ArchiveMetadata && - other.teamsMoved == teamsMoved && - other.tentativeQueuesMoved == tentativeQueuesMoved && - other.totalTime == totalTime; + other.teamsMoved == teamsMoved && + other.tentativeQueuesMoved == tentativeQueuesMoved && + other.totalTime == totalTime; @override int get hashCode => @@ -62,23 +62,23 @@ class ArchiveMetadata { String toString() => 'ArchiveMetadata[teamsMoved=$teamsMoved, tentativeQueuesMoved=$tentativeQueuesMoved, totalTime=$totalTime]'; Map toJson() { - final _json = {}; - if (teamsMoved != null) { - _json[r'teamsMoved'] = teamsMoved; + final json = {}; + if (this.teamsMoved != null) { + json[r'teamsMoved'] = this.teamsMoved; } else { - _json[r'teamsMoved'] = null; + json[r'teamsMoved'] = null; } - if (tentativeQueuesMoved != null) { - _json[r'tentativeQueuesMoved'] = tentativeQueuesMoved; + if (this.tentativeQueuesMoved != null) { + json[r'tentativeQueuesMoved'] = this.tentativeQueuesMoved; } else { - _json[r'tentativeQueuesMoved'] = null; + json[r'tentativeQueuesMoved'] = null; } - if (totalTime != null) { - _json[r'totalTime'] = totalTime; + if (this.totalTime != null) { + json[r'totalTime'] = this.totalTime; } else { - _json[r'totalTime'] = null; + json[r'totalTime'] = null; } - return _json; + return json; } /// Returns a new [ArchiveMetadata] instance and imports its values from @@ -108,7 +108,7 @@ class ArchiveMetadata { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -139,12 +139,10 @@ class ArchiveMetadata { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = ArchiveMetadata.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = ArchiveMetadata.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/base_tournament.dart b/clash-bot-api/lib/model/base_tournament.dart index e54b833..03eb850 100644 --- a/clash-bot-api/lib/model/base_tournament.dart +++ b/clash-bot-api/lib/model/base_tournament.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -37,8 +37,8 @@ class BaseTournament { @override bool operator ==(Object other) => identical(this, other) || other is BaseTournament && - other.tournamentName == tournamentName && - other.tournamentDay == tournamentDay; + other.tournamentName == tournamentName && + other.tournamentDay == tournamentDay; @override int get hashCode => @@ -50,18 +50,18 @@ class BaseTournament { String toString() => 'BaseTournament[tournamentName=$tournamentName, tournamentDay=$tournamentDay]'; Map toJson() { - final _json = {}; - if (tournamentName != null) { - _json[r'tournamentName'] = tournamentName; + final json = {}; + if (this.tournamentName != null) { + json[r'tournamentName'] = this.tournamentName; } else { - _json[r'tournamentName'] = null; + json[r'tournamentName'] = null; } - if (tournamentDay != null) { - _json[r'tournamentDay'] = tournamentDay; + if (this.tournamentDay != null) { + json[r'tournamentDay'] = this.tournamentDay; } else { - _json[r'tournamentDay'] = null; + json[r'tournamentDay'] = null; } - return _json; + return json; } /// Returns a new [BaseTournament] instance and imports its values from @@ -90,7 +90,7 @@ class BaseTournament { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -121,12 +121,10 @@ class BaseTournament { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = BaseTournament.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = BaseTournament.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/champion.dart b/clash-bot-api/lib/model/champion.dart index 8143313..c2ed1f0 100644 --- a/clash-bot-api/lib/model/champion.dart +++ b/clash-bot-api/lib/model/champion.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -26,7 +26,7 @@ class Champion { @override bool operator ==(Object other) => identical(this, other) || other is Champion && - other.name == name; + other.name == name; @override int get hashCode => @@ -37,13 +37,13 @@ class Champion { String toString() => 'Champion[name=$name]'; Map toJson() { - final _json = {}; - if (name != null) { - _json[r'name'] = name; + final json = {}; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - return _json; + return json; } /// Returns a new [Champion] instance and imports its values from @@ -71,7 +71,7 @@ class Champion { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -102,12 +102,10 @@ class Champion { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Champion.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Champion.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/champions.dart b/clash-bot-api/lib/model/champions.dart index 8beeb8e..ce96941 100644 --- a/clash-bot-api/lib/model/champions.dart +++ b/clash-bot-api/lib/model/champions.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -20,7 +20,7 @@ class Champions { @override bool operator ==(Object other) => identical(this, other) || other is Champions && - other.champions == champions; + _deepEquality.equals(other.champions, champions); @override int get hashCode => @@ -31,9 +31,9 @@ class Champions { String toString() => 'Champions[champions=$champions]'; Map toJson() { - final _json = {}; - _json[r'champions'] = champions; - return _json; + final json = {}; + json[r'champions'] = this.champions; + return json; } /// Returns a new [Champions] instance and imports its values from @@ -55,13 +55,13 @@ class Champions { }()); return Champions( - champions: Champion.listFromJson(json[r'champions']) ?? const [], + champions: Champion.listFromJson(json[r'champions']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -92,12 +92,10 @@ class Champions { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Champions.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Champions.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/create_user_request.dart b/clash-bot-api/lib/model/create_user_request.dart index f916f85..9388397 100644 --- a/clash-bot-api/lib/model/create_user_request.dart +++ b/clash-bot-api/lib/model/create_user_request.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -33,10 +33,10 @@ class CreateUserRequest { @override bool operator ==(Object other) => identical(this, other) || other is CreateUserRequest && - other.discordId == discordId && - other.name == name && - other.serverId == serverId && - other.selectedGuilds == selectedGuilds; + other.discordId == discordId && + other.name == name && + other.serverId == serverId && + _deepEquality.equals(other.selectedGuilds, selectedGuilds); @override int get hashCode => @@ -50,12 +50,12 @@ class CreateUserRequest { String toString() => 'CreateUserRequest[discordId=$discordId, name=$name, serverId=$serverId, selectedGuilds=$selectedGuilds]'; Map toJson() { - final _json = {}; - _json[r'discordId'] = discordId; - _json[r'name'] = name; - _json[r'serverId'] = serverId; - _json[r'selectedGuilds'] = selectedGuilds; - return _json; + final json = {}; + json[r'discordId'] = this.discordId; + json[r'name'] = this.name; + json[r'serverId'] = this.serverId; + json[r'selectedGuilds'] = this.selectedGuilds; + return json; } /// Returns a new [CreateUserRequest] instance and imports its values from @@ -80,15 +80,15 @@ class CreateUserRequest { discordId: mapValueOfType(json, r'discordId')!, name: mapValueOfType(json, r'name')!, serverId: mapValueOfType(json, r'serverId')!, - selectedGuilds: json[r'selectedGuilds'] is List - ? (json[r'selectedGuilds'] as List).cast() + selectedGuilds: json[r'selectedGuilds'] is Iterable + ? (json[r'selectedGuilds'] as Iterable).cast().toList(growable: false) : const [], ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -119,12 +119,10 @@ class CreateUserRequest { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = CreateUserRequest.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = CreateUserRequest.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/detailed_tournament.dart b/clash-bot-api/lib/model/detailed_tournament.dart index 71c3138..99cc50d 100644 --- a/clash-bot-api/lib/model/detailed_tournament.dart +++ b/clash-bot-api/lib/model/detailed_tournament.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -57,10 +57,10 @@ class DetailedTournament { @override bool operator ==(Object other) => identical(this, other) || other is DetailedTournament && - other.tournamentName == tournamentName && - other.tournamentDay == tournamentDay && - other.startTime == startTime && - other.registrationTime == registrationTime; + other.tournamentName == tournamentName && + other.tournamentDay == tournamentDay && + other.startTime == startTime && + other.registrationTime == registrationTime; @override int get hashCode => @@ -74,28 +74,28 @@ class DetailedTournament { String toString() => 'DetailedTournament[tournamentName=$tournamentName, tournamentDay=$tournamentDay, startTime=$startTime, registrationTime=$registrationTime]'; Map toJson() { - final _json = {}; - if (tournamentName != null) { - _json[r'tournamentName'] = tournamentName; + final json = {}; + if (this.tournamentName != null) { + json[r'tournamentName'] = this.tournamentName; } else { - _json[r'tournamentName'] = null; + json[r'tournamentName'] = null; } - if (tournamentDay != null) { - _json[r'tournamentDay'] = tournamentDay; + if (this.tournamentDay != null) { + json[r'tournamentDay'] = this.tournamentDay; } else { - _json[r'tournamentDay'] = null; + json[r'tournamentDay'] = null; } - if (startTime != null) { - _json[r'startTime'] = startTime!.toUtc().toIso8601String(); + if (this.startTime != null) { + json[r'startTime'] = this.startTime!.toUtc().toIso8601String(); } else { - _json[r'startTime'] = null; + json[r'startTime'] = null; } - if (registrationTime != null) { - _json[r'registrationTime'] = registrationTime!.toUtc().toIso8601String(); + if (this.registrationTime != null) { + json[r'registrationTime'] = this.registrationTime!.toUtc().toIso8601String(); } else { - _json[r'registrationTime'] = null; + json[r'registrationTime'] = null; } - return _json; + return json; } /// Returns a new [DetailedTournament] instance and imports its values from @@ -119,14 +119,14 @@ class DetailedTournament { return DetailedTournament( tournamentName: mapValueOfType(json, r'tournamentName'), tournamentDay: mapValueOfType(json, r'tournamentDay'), - startTime: mapDateTime(json, r'startTime', ''), - registrationTime: mapDateTime(json, r'registrationTime', ''), + startTime: mapDateTime(json, r'startTime', r''), + registrationTime: mapDateTime(json, r'registrationTime', r''), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -157,12 +157,10 @@ class DetailedTournament { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = DetailedTournament.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = DetailedTournament.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/error.dart b/clash-bot-api/lib/model/error.dart index 337afcf..585570e 100644 --- a/clash-bot-api/lib/model/error.dart +++ b/clash-bot-api/lib/model/error.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -35,8 +35,8 @@ class Error { @override bool operator ==(Object other) => identical(this, other) || other is Error && - other.code == code && - other.message == message; + other.code == code && + other.message == message; @override int get hashCode => @@ -48,18 +48,18 @@ class Error { String toString() => 'Error[code=$code, message=$message]'; Map toJson() { - final _json = {}; - if (code != null) { - _json[r'code'] = code; + final json = {}; + if (this.code != null) { + json[r'code'] = this.code; } else { - _json[r'code'] = null; + json[r'code'] = null; } - if (message != null) { - _json[r'message'] = message; + if (this.message != null) { + json[r'message'] = this.message; } else { - _json[r'message'] = null; + json[r'message'] = null; } - return _json; + return json; } /// Returns a new [Error] instance and imports its values from @@ -88,7 +88,7 @@ class Error { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -119,12 +119,10 @@ class Error { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Error.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Error.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/event.dart b/clash-bot-api/lib/model/event.dart index 5ff4191..1b59a18 100644 --- a/clash-bot-api/lib/model/event.dart +++ b/clash-bot-api/lib/model/event.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -42,11 +42,11 @@ class Event { @override bool operator ==(Object other) => identical(this, other) || other is Event && - other.id == id && - other.teamEvent == teamEvent && - other.summary == summary && - other.serverId == serverId && - other.causedBy == causedBy; + other.id == id && + other.teamEvent == teamEvent && + other.summary == summary && + other.serverId == serverId && + other.causedBy == causedBy; @override int get hashCode => @@ -61,17 +61,17 @@ class Event { String toString() => 'Event[id=$id, teamEvent=$teamEvent, summary=$summary, serverId=$serverId, causedBy=$causedBy]'; Map toJson() { - final _json = {}; - _json[r'id'] = id; - _json[r'teamEvent'] = teamEvent; - if (summary != null) { - _json[r'summary'] = summary; + final json = {}; + json[r'id'] = this.id; + json[r'teamEvent'] = this.teamEvent; + if (this.summary != null) { + json[r'summary'] = this.summary; } else { - _json[r'summary'] = null; + json[r'summary'] = null; } - _json[r'serverId'] = serverId; - _json[r'causedBy'] = causedBy; - return _json; + json[r'serverId'] = this.serverId; + json[r'causedBy'] = this.causedBy; + return json; } /// Returns a new [Event] instance and imports its values from @@ -103,7 +103,7 @@ class Event { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -134,12 +134,10 @@ class Event { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Event.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Event.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/event_type.dart b/clash-bot-api/lib/model/event_type.dart index 6b4c7c8..765e73a 100644 --- a/clash-bot-api/lib/model/event_type.dart +++ b/clash-bot-api/lib/model/event_type.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -40,7 +40,7 @@ class EventType { static EventType? fromJson(dynamic value) => EventTypeTypeTransformer().decode(value); - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -73,7 +73,7 @@ class EventTypeTypeTransformer { /// and users are still using an old app with the old code. EventType? decode(dynamic data, {bool allowNull = true}) { if (data != null) { - switch (data.toString()) { + switch (data) { case r'CREATED': return EventType.CREATED; case r'JOINED': return EventType.JOINED; case r'REMOVED': return EventType.REMOVED; diff --git a/clash-bot-api/lib/model/player.dart b/clash-bot-api/lib/model/player.dart index 8451628..a71ecaf 100644 --- a/clash-bot-api/lib/model/player.dart +++ b/clash-bot-api/lib/model/player.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -67,13 +67,13 @@ class Player { @override bool operator ==(Object other) => identical(this, other) || other is Player && - other.discordId == discordId && - other.name == name && - other.role == role && - other.champions == champions && - other.subscriptions == subscriptions && - other.serverId == serverId && - other.selectedServers == selectedServers; + other.discordId == discordId && + other.name == name && + other.role == role && + _deepEquality.equals(other.champions, champions) && + _deepEquality.equals(other.subscriptions, subscriptions) && + other.serverId == serverId && + _deepEquality.equals(other.selectedServers, selectedServers); @override int get hashCode => @@ -90,31 +90,31 @@ class Player { String toString() => 'Player[discordId=$discordId, name=$name, role=$role, champions=$champions, subscriptions=$subscriptions, serverId=$serverId, selectedServers=$selectedServers]'; Map toJson() { - final _json = {}; - if (discordId != null) { - _json[r'discordId'] = discordId; + final json = {}; + if (this.discordId != null) { + json[r'discordId'] = this.discordId; } else { - _json[r'discordId'] = null; + json[r'discordId'] = null; } - if (name != null) { - _json[r'name'] = name; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - if (role != null) { - _json[r'role'] = role; + if (this.role != null) { + json[r'role'] = this.role; } else { - _json[r'role'] = null; + json[r'role'] = null; } - _json[r'champions'] = champions; - _json[r'subscriptions'] = subscriptions; - if (serverId != null) { - _json[r'serverId'] = serverId; + json[r'champions'] = this.champions; + json[r'subscriptions'] = this.subscriptions; + if (this.serverId != null) { + json[r'serverId'] = this.serverId; } else { - _json[r'serverId'] = null; + json[r'serverId'] = null; } - _json[r'selectedServers'] = selectedServers; - return _json; + json[r'selectedServers'] = this.selectedServers; + return json; } /// Returns a new [Player] instance and imports its values from @@ -139,18 +139,18 @@ class Player { discordId: mapValueOfType(json, r'discordId'), name: mapValueOfType(json, r'name'), role: Role.fromJson(json[r'role']), - champions: Champion.listFromJson(json[r'champions']) ?? const [], - subscriptions: Subscription.listFromJson(json[r'subscriptions']) ?? const [], + champions: Champion.listFromJson(json[r'champions']), + subscriptions: Subscription.listFromJson(json[r'subscriptions']), serverId: mapValueOfType(json, r'serverId'), - selectedServers: json[r'selectedServers'] is List - ? (json[r'selectedServers'] as List).cast() + selectedServers: json[r'selectedServers'] is Iterable + ? (json[r'selectedServers'] as Iterable).cast().toList(growable: false) : const [], ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -181,12 +181,10 @@ class Player { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Player.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Player.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/position_details.dart b/clash-bot-api/lib/model/position_details.dart index 3bc1db0..edeaa9f 100644 --- a/clash-bot-api/lib/model/position_details.dart +++ b/clash-bot-api/lib/model/position_details.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -35,8 +35,8 @@ class PositionDetails { @override bool operator ==(Object other) => identical(this, other) || other is PositionDetails && - other.champions == champions && - other.role == role; + other.champions == champions && + other.role == role; @override int get hashCode => @@ -48,18 +48,18 @@ class PositionDetails { String toString() => 'PositionDetails[champions=$champions, role=$role]'; Map toJson() { - final _json = {}; - if (champions != null) { - _json[r'champions'] = champions; + final json = {}; + if (this.champions != null) { + json[r'champions'] = this.champions; } else { - _json[r'champions'] = null; + json[r'champions'] = null; } - if (role != null) { - _json[r'role'] = role; + if (this.role != null) { + json[r'role'] = this.role; } else { - _json[r'role'] = null; + json[r'role'] = null; } - return _json; + return json; } /// Returns a new [PositionDetails] instance and imports its values from @@ -88,7 +88,7 @@ class PositionDetails { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -119,12 +119,10 @@ class PositionDetails { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = PositionDetails.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = PositionDetails.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/role.dart b/clash-bot-api/lib/model/role.dart index f9bee97..acfe6a6 100644 --- a/clash-bot-api/lib/model/role.dart +++ b/clash-bot-api/lib/model/role.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -23,24 +23,24 @@ class Role { String toJson() => value; - static const TOP = Role._(r'TOP'); - static const MID = Role._(r'MID'); - static const JG = Role._(r'JG'); - static const BOT = Role._(r'BOT'); - static const SUPP = Role._(r'SUPP'); + static const top = Role._(r'top'); + static const mid = Role._(r'mid'); + static const jg = Role._(r'jg'); + static const bot = Role._(r'bot'); + static const supp = Role._(r'supp'); /// List of all possible values in this [enum][Role]. static const values = [ - TOP, - MID, - JG, - BOT, - SUPP, + top, + mid, + jg, + bot, + supp, ]; static Role? fromJson(dynamic value) => RoleTypeTransformer().decode(value); - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -73,12 +73,12 @@ class RoleTypeTransformer { /// and users are still using an old app with the old code. Role? decode(dynamic data, {bool allowNull = true}) { if (data != null) { - switch (data.toString()) { - case r'TOP': return Role.TOP; - case r'MID': return Role.MID; - case r'JG': return Role.JG; - case r'BOT': return Role.BOT; - case r'SUPP': return Role.SUPP; + switch (data) { + case r'top': return Role.top; + case r'mid': return Role.mid; + case r'jg': return Role.jg; + case r'bot': return Role.bot; + case r'supp': return Role.supp; default: if (!allowNull) { throw ArgumentError('Unknown enum value to decode: $data'); diff --git a/clash-bot-api/lib/model/server.dart b/clash-bot-api/lib/model/server.dart index 8126ee8..ec1c98c 100644 --- a/clash-bot-api/lib/model/server.dart +++ b/clash-bot-api/lib/model/server.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -37,8 +37,8 @@ class Server { @override bool operator ==(Object other) => identical(this, other) || other is Server && - other.id == id && - other.name == name; + other.id == id && + other.name == name; @override int get hashCode => @@ -50,18 +50,18 @@ class Server { String toString() => 'Server[id=$id, name=$name]'; Map toJson() { - final _json = {}; - if (id != null) { - _json[r'id'] = id; + final json = {}; + if (this.id != null) { + json[r'id'] = this.id; } else { - _json[r'id'] = null; + json[r'id'] = null; } - if (name != null) { - _json[r'name'] = name; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - return _json; + return json; } /// Returns a new [Server] instance and imports its values from @@ -90,7 +90,7 @@ class Server { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -121,12 +121,10 @@ class Server { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Server.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Server.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/servers.dart b/clash-bot-api/lib/model/servers.dart index 8f3688f..04c25af 100644 --- a/clash-bot-api/lib/model/servers.dart +++ b/clash-bot-api/lib/model/servers.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -20,7 +20,7 @@ class Servers { @override bool operator ==(Object other) => identical(this, other) || other is Servers && - other.servers == servers; + _deepEquality.equals(other.servers, servers); @override int get hashCode => @@ -31,9 +31,9 @@ class Servers { String toString() => 'Servers[servers=$servers]'; Map toJson() { - final _json = {}; - _json[r'servers'] = servers; - return _json; + final json = {}; + json[r'servers'] = this.servers; + return json; } /// Returns a new [Servers] instance and imports its values from @@ -55,13 +55,13 @@ class Servers { }()); return Servers( - servers: Server.listFromJson(json[r'servers']) ?? const [], + servers: Server.listFromJson(json[r'servers']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -92,12 +92,10 @@ class Servers { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Servers.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Servers.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/subscription.dart b/clash-bot-api/lib/model/subscription.dart index 8b5ee1e..97ecb51 100644 --- a/clash-bot-api/lib/model/subscription.dart +++ b/clash-bot-api/lib/model/subscription.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -35,8 +35,8 @@ class Subscription { @override bool operator ==(Object other) => identical(this, other) || other is Subscription && - other.key == key && - other.isOn == isOn; + other.key == key && + other.isOn == isOn; @override int get hashCode => @@ -48,18 +48,18 @@ class Subscription { String toString() => 'Subscription[key=$key, isOn=$isOn]'; Map toJson() { - final _json = {}; - if (key != null) { - _json[r'key'] = key; + final json = {}; + if (this.key != null) { + json[r'key'] = this.key; } else { - _json[r'key'] = null; + json[r'key'] = null; } - if (isOn != null) { - _json[r'isOn'] = isOn; + if (this.isOn != null) { + json[r'isOn'] = this.isOn; } else { - _json[r'isOn'] = null; + json[r'isOn'] = null; } - return _json; + return json; } /// Returns a new [Subscription] instance and imports its values from @@ -88,7 +88,7 @@ class Subscription { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -119,12 +119,10 @@ class Subscription { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Subscription.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Subscription.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/subscription_type.dart b/clash-bot-api/lib/model/subscription_type.dart index 7ec030c..352e956 100644 --- a/clash-bot-api/lib/model/subscription_type.dart +++ b/clash-bot-api/lib/model/subscription_type.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -32,7 +32,7 @@ class SubscriptionType { static SubscriptionType? fromJson(dynamic value) => SubscriptionTypeTypeTransformer().decode(value); - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -65,7 +65,7 @@ class SubscriptionTypeTypeTransformer { /// and users are still using an old app with the old code. SubscriptionType? decode(dynamic data, {bool allowNull = true}) { if (data != null) { - switch (data.toString()) { + switch (data) { case r'DISCORD_MONDAY_NOTIFICATION': return SubscriptionType.DISCORD_MONDAY_NOTIFICATION; default: if (!allowNull) { diff --git a/clash-bot-api/lib/model/team.dart b/clash-bot-api/lib/model/team.dart index 8d235df..ff11404 100644 --- a/clash-bot-api/lib/model/team.dart +++ b/clash-bot-api/lib/model/team.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -75,12 +75,12 @@ class Team { @override bool operator ==(Object other) => identical(this, other) || other is Team && - other.id == id && - other.name == name && - other.playerDetails == playerDetails && - other.serverId == serverId && - other.tournament == tournament && - other.lastUpdatedAt == lastUpdatedAt; + other.id == id && + other.name == name && + other.playerDetails == playerDetails && + other.serverId == serverId && + other.tournament == tournament && + other.lastUpdatedAt == lastUpdatedAt; @override int get hashCode => @@ -96,38 +96,38 @@ class Team { String toString() => 'Team[id=$id, name=$name, playerDetails=$playerDetails, serverId=$serverId, tournament=$tournament, lastUpdatedAt=$lastUpdatedAt]'; Map toJson() { - final _json = {}; - if (id != null) { - _json[r'id'] = id; + final json = {}; + if (this.id != null) { + json[r'id'] = this.id; } else { - _json[r'id'] = null; + json[r'id'] = null; } - if (name != null) { - _json[r'name'] = name; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - if (playerDetails != null) { - _json[r'playerDetails'] = playerDetails; + if (this.playerDetails != null) { + json[r'playerDetails'] = this.playerDetails; } else { - _json[r'playerDetails'] = null; + json[r'playerDetails'] = null; } - if (serverId != null) { - _json[r'serverId'] = serverId; + if (this.serverId != null) { + json[r'serverId'] = this.serverId; } else { - _json[r'serverId'] = null; + json[r'serverId'] = null; } - if (tournament != null) { - _json[r'tournament'] = tournament; + if (this.tournament != null) { + json[r'tournament'] = this.tournament; } else { - _json[r'tournament'] = null; + json[r'tournament'] = null; } - if (lastUpdatedAt != null) { - _json[r'lastUpdatedAt'] = lastUpdatedAt!.toUtc().toIso8601String(); + if (this.lastUpdatedAt != null) { + json[r'lastUpdatedAt'] = this.lastUpdatedAt!.toUtc().toIso8601String(); } else { - _json[r'lastUpdatedAt'] = null; + json[r'lastUpdatedAt'] = null; } - return _json; + return json; } /// Returns a new [Team] instance and imports its values from @@ -154,13 +154,13 @@ class Team { playerDetails: TeamPlayerDetails.fromJson(json[r'playerDetails']), serverId: mapValueOfType(json, r'serverId'), tournament: BaseTournament.fromJson(json[r'tournament']), - lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', ''), + lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', r''), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -191,12 +191,10 @@ class Team { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Team.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Team.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_event.dart b/clash-bot-api/lib/model/team_event.dart index 5b80dd6..ec2c733 100644 --- a/clash-bot-api/lib/model/team_event.dart +++ b/clash-bot-api/lib/model/team_event.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -38,9 +38,9 @@ class TeamEvent { @override bool operator ==(Object other) => identical(this, other) || other is TeamEvent && - other.team == team && - other.tentative == tentative && - other.eventType == eventType; + other.team == team && + other.tentative == tentative && + other.eventType == eventType; @override int get hashCode => @@ -53,19 +53,19 @@ class TeamEvent { String toString() => 'TeamEvent[team=$team, tentative=$tentative, eventType=$eventType]'; Map toJson() { - final _json = {}; - if (team != null) { - _json[r'team'] = team; + final json = {}; + if (this.team != null) { + json[r'team'] = this.team; } else { - _json[r'team'] = null; + json[r'team'] = null; } - if (tentative != null) { - _json[r'tentative'] = tentative; + if (this.tentative != null) { + json[r'tentative'] = this.tentative; } else { - _json[r'tentative'] = null; + json[r'tentative'] = null; } - _json[r'eventType'] = eventType; - return _json; + json[r'eventType'] = this.eventType; + return json; } /// Returns a new [TeamEvent] instance and imports its values from @@ -95,7 +95,7 @@ class TeamEvent { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -126,12 +126,10 @@ class TeamEvent { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamEvent.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamEvent.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_player.dart b/clash-bot-api/lib/model/team_player.dart index 5036c55..a0b21f1 100644 --- a/clash-bot-api/lib/model/team_player.dart +++ b/clash-bot-api/lib/model/team_player.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -14,7 +14,6 @@ class TeamPlayer { /// Returns a new [TeamPlayer] instance. TeamPlayer({ this.discordId, - this.name, this.champions = const [], }); @@ -27,48 +26,32 @@ class TeamPlayer { /// String? discordId; - /// The Players discord name - /// - /// Please note: This property should have been non-nullable! Since the specification file - /// does not include a default value (using the "default:" property), however, the generated - /// source code must fall back to having a nullable type. - /// Consider adding a "default:" property in the specification file to hide this note. - /// - String? name; - /// A list of the Users preferred champions. List champions; @override bool operator ==(Object other) => identical(this, other) || other is TeamPlayer && - other.discordId == discordId && - other.name == name && - other.champions == champions; + other.discordId == discordId && + _deepEquality.equals(other.champions, champions); @override int get hashCode => // ignore: unnecessary_parenthesis (discordId == null ? 0 : discordId!.hashCode) + - (name == null ? 0 : name!.hashCode) + (champions.hashCode); @override - String toString() => 'TeamPlayer[discordId=$discordId, name=$name, champions=$champions]'; + String toString() => 'TeamPlayer[discordId=$discordId, champions=$champions]'; Map toJson() { - final _json = {}; - if (discordId != null) { - _json[r'discordId'] = discordId; + final json = {}; + if (this.discordId != null) { + json[r'discordId'] = this.discordId; } else { - _json[r'discordId'] = null; + json[r'discordId'] = null; } - if (name != null) { - _json[r'name'] = name; - } else { - _json[r'name'] = null; - } - _json[r'champions'] = champions; - return _json; + json[r'champions'] = this.champions; + return json; } /// Returns a new [TeamPlayer] instance and imports its values from @@ -91,14 +74,13 @@ class TeamPlayer { return TeamPlayer( discordId: mapValueOfType(json, r'discordId'), - name: mapValueOfType(json, r'name'), - champions: Champion.listFromJson(json[r'champions']) ?? const [], + champions: Champion.listFromJson(json[r'champions']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -129,12 +111,10 @@ class TeamPlayer { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamPlayer.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamPlayer.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_player_details.dart b/clash-bot-api/lib/model/team_player_details.dart index 0c3e2ba..b2e37ae 100644 --- a/clash-bot-api/lib/model/team_player_details.dart +++ b/clash-bot-api/lib/model/team_player_details.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -62,11 +62,11 @@ class TeamPlayerDetails { @override bool operator ==(Object other) => identical(this, other) || other is TeamPlayerDetails && - other.top == top && - other.mid == mid && - other.jg == jg && - other.bot == bot && - other.supp == supp; + other.top == top && + other.mid == mid && + other.jg == jg && + other.bot == bot && + other.supp == supp; @override int get hashCode => @@ -81,33 +81,33 @@ class TeamPlayerDetails { String toString() => 'TeamPlayerDetails[top=$top, mid=$mid, jg=$jg, bot=$bot, supp=$supp]'; Map toJson() { - final _json = {}; - if (top != null) { - _json[r'Top'] = top; + final json = {}; + if (this.top != null) { + json[r'top'] = this.top; } else { - _json[r'Top'] = null; + json[r'top'] = null; } - if (mid != null) { - _json[r'Mid'] = mid; + if (this.mid != null) { + json[r'mid'] = this.mid; } else { - _json[r'Mid'] = null; + json[r'mid'] = null; } - if (jg != null) { - _json[r'Jg'] = jg; + if (this.jg != null) { + json[r'jg'] = this.jg; } else { - _json[r'Jg'] = null; + json[r'jg'] = null; } - if (bot != null) { - _json[r'Bot'] = bot; + if (this.bot != null) { + json[r'bot'] = this.bot; } else { - _json[r'Bot'] = null; + json[r'bot'] = null; } - if (supp != null) { - _json[r'Supp'] = supp; + if (this.supp != null) { + json[r'supp'] = this.supp; } else { - _json[r'Supp'] = null; + json[r'supp'] = null; } - return _json; + return json; } /// Returns a new [TeamPlayerDetails] instance and imports its values from @@ -129,17 +129,17 @@ class TeamPlayerDetails { }()); return TeamPlayerDetails( - top: TeamPlayer.fromJson(json[r'Top']), - mid: TeamPlayer.fromJson(json[r'Mid']), - jg: TeamPlayer.fromJson(json[r'Jg']), - bot: TeamPlayer.fromJson(json[r'Bot']), - supp: TeamPlayer.fromJson(json[r'Supp']), + top: TeamPlayer.fromJson(json[r'top']), + mid: TeamPlayer.fromJson(json[r'mid']), + jg: TeamPlayer.fromJson(json[r'jg']), + bot: TeamPlayer.fromJson(json[r'bot']), + supp: TeamPlayer.fromJson(json[r'supp']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -170,12 +170,10 @@ class TeamPlayerDetails { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamPlayerDetails.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamPlayerDetails.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_required.dart b/clash-bot-api/lib/model/team_required.dart index 80420bc..226273d 100644 --- a/clash-bot-api/lib/model/team_required.dart +++ b/clash-bot-api/lib/model/team_required.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -57,12 +57,12 @@ class TeamRequired { @override bool operator ==(Object other) => identical(this, other) || other is TeamRequired && - other.id == id && - other.name == name && - other.playerDetails == playerDetails && - other.serverId == serverId && - other.tournament == tournament && - other.lastUpdatedAt == lastUpdatedAt; + other.id == id && + other.name == name && + other.playerDetails == playerDetails && + other.serverId == serverId && + other.tournament == tournament && + other.lastUpdatedAt == lastUpdatedAt; @override int get hashCode => @@ -78,26 +78,26 @@ class TeamRequired { String toString() => 'TeamRequired[id=$id, name=$name, playerDetails=$playerDetails, serverId=$serverId, tournament=$tournament, lastUpdatedAt=$lastUpdatedAt]'; Map toJson() { - final _json = {}; - if (id != null) { - _json[r'id'] = id; + final json = {}; + if (this.id != null) { + json[r'id'] = this.id; } else { - _json[r'id'] = null; + json[r'id'] = null; } - if (name != null) { - _json[r'name'] = name; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - _json[r'playerDetails'] = playerDetails; - _json[r'serverId'] = serverId; - _json[r'tournament'] = tournament; - if (lastUpdatedAt != null) { - _json[r'lastUpdatedAt'] = lastUpdatedAt!.toUtc().toIso8601String(); + json[r'playerDetails'] = this.playerDetails; + json[r'serverId'] = this.serverId; + json[r'tournament'] = this.tournament; + if (this.lastUpdatedAt != null) { + json[r'lastUpdatedAt'] = this.lastUpdatedAt!.toUtc().toIso8601String(); } else { - _json[r'lastUpdatedAt'] = null; + json[r'lastUpdatedAt'] = null; } - return _json; + return json; } /// Returns a new [TeamRequired] instance and imports its values from @@ -124,13 +124,13 @@ class TeamRequired { playerDetails: TeamPlayerDetails.fromJson(json[r'playerDetails'])!, serverId: mapValueOfType(json, r'serverId')!, tournament: BaseTournament.fromJson(json[r'tournament'])!, - lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', ''), + lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', r''), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -161,12 +161,10 @@ class TeamRequired { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamRequired.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamRequired.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_tournament_details.dart b/clash-bot-api/lib/model/team_tournament_details.dart index 8cd302f..47dc665 100644 --- a/clash-bot-api/lib/model/team_tournament_details.dart +++ b/clash-bot-api/lib/model/team_tournament_details.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -44,10 +44,10 @@ class TeamTournamentDetails { @override bool operator ==(Object other) => identical(this, other) || other is TeamTournamentDetails && - other.discordId == discordId && - other.tournamentName == tournamentName && - other.tournamentDay == tournamentDay && - other.role == role; + other.discordId == discordId && + other.tournamentName == tournamentName && + other.tournamentDay == tournamentDay && + other.role == role; @override int get hashCode => @@ -61,28 +61,28 @@ class TeamTournamentDetails { String toString() => 'TeamTournamentDetails[discordId=$discordId, tournamentName=$tournamentName, tournamentDay=$tournamentDay, role=$role]'; Map toJson() { - final _json = {}; - if (discordId != null) { - _json[r'discordId'] = discordId; + final json = {}; + if (this.discordId != null) { + json[r'discordId'] = this.discordId; } else { - _json[r'discordId'] = null; + json[r'discordId'] = null; } - if (tournamentName != null) { - _json[r'tournamentName'] = tournamentName; + if (this.tournamentName != null) { + json[r'tournamentName'] = this.tournamentName; } else { - _json[r'tournamentName'] = null; + json[r'tournamentName'] = null; } - if (tournamentDay != null) { - _json[r'tournamentDay'] = tournamentDay; + if (this.tournamentDay != null) { + json[r'tournamentDay'] = this.tournamentDay; } else { - _json[r'tournamentDay'] = null; + json[r'tournamentDay'] = null; } - if (role != null) { - _json[r'role'] = role; + if (this.role != null) { + json[r'role'] = this.role; } else { - _json[r'role'] = null; + json[r'role'] = null; } - return _json; + return json; } /// Returns a new [TeamTournamentDetails] instance and imports its values from @@ -113,7 +113,7 @@ class TeamTournamentDetails { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -144,12 +144,10 @@ class TeamTournamentDetails { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamTournamentDetails.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamTournamentDetails.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/team_update.dart b/clash-bot-api/lib/model/team_update.dart index eb91fdd..37dde73 100644 --- a/clash-bot-api/lib/model/team_update.dart +++ b/clash-bot-api/lib/model/team_update.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -21,7 +21,7 @@ class TeamUpdate { @override bool operator ==(Object other) => identical(this, other) || other is TeamUpdate && - other.teamName == teamName; + other.teamName == teamName; @override int get hashCode => @@ -32,9 +32,9 @@ class TeamUpdate { String toString() => 'TeamUpdate[teamName=$teamName]'; Map toJson() { - final _json = {}; - _json[r'teamName'] = teamName; - return _json; + final json = {}; + json[r'teamName'] = this.teamName; + return json; } /// Returns a new [TeamUpdate] instance and imports its values from @@ -62,7 +62,7 @@ class TeamUpdate { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -93,12 +93,10 @@ class TeamUpdate { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TeamUpdate.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TeamUpdate.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/teams.dart b/clash-bot-api/lib/model/teams.dart index 2508c7f..0b7a8f8 100644 --- a/clash-bot-api/lib/model/teams.dart +++ b/clash-bot-api/lib/model/teams.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -29,8 +29,8 @@ class Teams { @override bool operator ==(Object other) => identical(this, other) || other is Teams && - other.count == count && - other.teams == teams; + other.count == count && + _deepEquality.equals(other.teams, teams); @override int get hashCode => @@ -42,14 +42,14 @@ class Teams { String toString() => 'Teams[count=$count, teams=$teams]'; Map toJson() { - final _json = {}; - if (count != null) { - _json[r'count'] = count; + final json = {}; + if (this.count != null) { + json[r'count'] = this.count; } else { - _json[r'count'] = null; + json[r'count'] = null; } - _json[r'teams'] = teams; - return _json; + json[r'teams'] = this.teams; + return json; } /// Returns a new [Teams] instance and imports its values from @@ -72,13 +72,13 @@ class Teams { return Teams( count: mapValueOfType(json, r'count'), - teams: Team.listFromJson(json[r'teams']) ?? const [], + teams: Team.listFromJson(json[r'teams']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -109,12 +109,10 @@ class Teams { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Teams.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Teams.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/tentative.dart b/clash-bot-api/lib/model/tentative.dart index 4e022d8..e345728 100644 --- a/clash-bot-api/lib/model/tentative.dart +++ b/clash-bot-api/lib/model/tentative.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -59,11 +59,11 @@ class Tentative { @override bool operator ==(Object other) => identical(this, other) || other is Tentative && - other.id == id && - other.serverId == serverId && - other.tournamentDetails == tournamentDetails && - other.tentativePlayers == tentativePlayers && - other.lastUpdatedAt == lastUpdatedAt; + other.id == id && + other.serverId == serverId && + other.tournamentDetails == tournamentDetails && + _deepEquality.equals(other.tentativePlayers, tentativePlayers) && + other.lastUpdatedAt == lastUpdatedAt; @override int get hashCode => @@ -78,29 +78,29 @@ class Tentative { String toString() => 'Tentative[id=$id, serverId=$serverId, tournamentDetails=$tournamentDetails, tentativePlayers=$tentativePlayers, lastUpdatedAt=$lastUpdatedAt]'; Map toJson() { - final _json = {}; - if (id != null) { - _json[r'id'] = id; + final json = {}; + if (this.id != null) { + json[r'id'] = this.id; } else { - _json[r'id'] = null; + json[r'id'] = null; } - if (serverId != null) { - _json[r'serverId'] = serverId; + if (this.serverId != null) { + json[r'serverId'] = this.serverId; } else { - _json[r'serverId'] = null; + json[r'serverId'] = null; } - if (tournamentDetails != null) { - _json[r'tournamentDetails'] = tournamentDetails; + if (this.tournamentDetails != null) { + json[r'tournamentDetails'] = this.tournamentDetails; } else { - _json[r'tournamentDetails'] = null; + json[r'tournamentDetails'] = null; } - _json[r'tentativePlayers'] = tentativePlayers; - if (lastUpdatedAt != null) { - _json[r'lastUpdatedAt'] = lastUpdatedAt!.toUtc().toIso8601String(); + json[r'tentativePlayers'] = this.tentativePlayers; + if (this.lastUpdatedAt != null) { + json[r'lastUpdatedAt'] = this.lastUpdatedAt!.toUtc().toIso8601String(); } else { - _json[r'lastUpdatedAt'] = null; + json[r'lastUpdatedAt'] = null; } - return _json; + return json; } /// Returns a new [Tentative] instance and imports its values from @@ -125,14 +125,14 @@ class Tentative { id: mapValueOfType(json, r'id'), serverId: mapValueOfType(json, r'serverId'), tournamentDetails: BaseTournament.fromJson(json[r'tournamentDetails']), - tentativePlayers: TentativePlayer.listFromJson(json[r'tentativePlayers']) ?? const [], - lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', ''), + tentativePlayers: TentativePlayer.listFromJson(json[r'tentativePlayers']), + lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', r''), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -163,12 +163,10 @@ class Tentative { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Tentative.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Tentative.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/tentative_player.dart b/clash-bot-api/lib/model/tentative_player.dart index 6cd8fb7..413438c 100644 --- a/clash-bot-api/lib/model/tentative_player.dart +++ b/clash-bot-api/lib/model/tentative_player.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -50,10 +50,10 @@ class TentativePlayer { @override bool operator ==(Object other) => identical(this, other) || other is TentativePlayer && - other.discordId == discordId && - other.name == name && - other.champions == champions && - other.role == role; + other.discordId == discordId && + other.name == name && + _deepEquality.equals(other.champions, champions) && + other.role == role; @override int get hashCode => @@ -67,24 +67,24 @@ class TentativePlayer { String toString() => 'TentativePlayer[discordId=$discordId, name=$name, champions=$champions, role=$role]'; Map toJson() { - final _json = {}; - if (discordId != null) { - _json[r'discordId'] = discordId; + final json = {}; + if (this.discordId != null) { + json[r'discordId'] = this.discordId; } else { - _json[r'discordId'] = null; + json[r'discordId'] = null; } - if (name != null) { - _json[r'name'] = name; + if (this.name != null) { + json[r'name'] = this.name; } else { - _json[r'name'] = null; + json[r'name'] = null; } - _json[r'champions'] = champions; - if (role != null) { - _json[r'role'] = role; + json[r'champions'] = this.champions; + if (this.role != null) { + json[r'role'] = this.role; } else { - _json[r'role'] = null; + json[r'role'] = null; } - return _json; + return json; } /// Returns a new [TentativePlayer] instance and imports its values from @@ -108,14 +108,14 @@ class TentativePlayer { return TentativePlayer( discordId: mapValueOfType(json, r'discordId'), name: mapValueOfType(json, r'name'), - champions: Champion.listFromJson(json[r'champions']) ?? const [], + champions: Champion.listFromJson(json[r'champions']), role: Role.fromJson(json[r'role']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -146,12 +146,10 @@ class TentativePlayer { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TentativePlayer.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TentativePlayer.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/tentative_required.dart b/clash-bot-api/lib/model/tentative_required.dart index 92ccf41..5e0b25d 100644 --- a/clash-bot-api/lib/model/tentative_required.dart +++ b/clash-bot-api/lib/model/tentative_required.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -47,11 +47,11 @@ class TentativeRequired { @override bool operator ==(Object other) => identical(this, other) || other is TentativeRequired && - other.id == id && - other.serverId == serverId && - other.tournamentDetails == tournamentDetails && - other.tentativePlayers == tentativePlayers && - other.lastUpdatedAt == lastUpdatedAt; + other.id == id && + other.serverId == serverId && + other.tournamentDetails == tournamentDetails && + _deepEquality.equals(other.tentativePlayers, tentativePlayers) && + other.lastUpdatedAt == lastUpdatedAt; @override int get hashCode => @@ -66,21 +66,21 @@ class TentativeRequired { String toString() => 'TentativeRequired[id=$id, serverId=$serverId, tournamentDetails=$tournamentDetails, tentativePlayers=$tentativePlayers, lastUpdatedAt=$lastUpdatedAt]'; Map toJson() { - final _json = {}; - if (id != null) { - _json[r'id'] = id; + final json = {}; + if (this.id != null) { + json[r'id'] = this.id; } else { - _json[r'id'] = null; + json[r'id'] = null; } - _json[r'serverId'] = serverId; - _json[r'tournamentDetails'] = tournamentDetails; - _json[r'tentativePlayers'] = tentativePlayers; - if (lastUpdatedAt != null) { - _json[r'lastUpdatedAt'] = lastUpdatedAt!.toUtc().toIso8601String(); + json[r'serverId'] = this.serverId; + json[r'tournamentDetails'] = this.tournamentDetails; + json[r'tentativePlayers'] = this.tentativePlayers; + if (this.lastUpdatedAt != null) { + json[r'lastUpdatedAt'] = this.lastUpdatedAt!.toUtc().toIso8601String(); } else { - _json[r'lastUpdatedAt'] = null; + json[r'lastUpdatedAt'] = null; } - return _json; + return json; } /// Returns a new [TentativeRequired] instance and imports its values from @@ -105,14 +105,14 @@ class TentativeRequired { id: mapValueOfType(json, r'id'), serverId: mapValueOfType(json, r'serverId')!, tournamentDetails: BaseTournament.fromJson(json[r'tournamentDetails'])!, - tentativePlayers: TentativePlayer.listFromJson(json[r'tentativePlayers'])!, - lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', ''), + tentativePlayers: TentativePlayer.listFromJson(json[r'tentativePlayers']), + lastUpdatedAt: mapDateTime(json, r'lastUpdatedAt', r''), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -143,12 +143,10 @@ class TentativeRequired { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = TentativeRequired.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = TentativeRequired.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/tentatives.dart b/clash-bot-api/lib/model/tentatives.dart index 09ed786..6f4d789 100644 --- a/clash-bot-api/lib/model/tentatives.dart +++ b/clash-bot-api/lib/model/tentatives.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -29,8 +29,8 @@ class Tentatives { @override bool operator ==(Object other) => identical(this, other) || other is Tentatives && - other.count == count && - other.queues == queues; + other.count == count && + _deepEquality.equals(other.queues, queues); @override int get hashCode => @@ -42,14 +42,14 @@ class Tentatives { String toString() => 'Tentatives[count=$count, queues=$queues]'; Map toJson() { - final _json = {}; - if (count != null) { - _json[r'count'] = count; + final json = {}; + if (this.count != null) { + json[r'count'] = this.count; } else { - _json[r'count'] = null; + json[r'count'] = null; } - _json[r'queues'] = queues; - return _json; + json[r'queues'] = this.queues; + return json; } /// Returns a new [Tentatives] instance and imports its values from @@ -72,13 +72,13 @@ class Tentatives { return Tentatives( count: mapValueOfType(json, r'count'), - queues: Tentative.listFromJson(json[r'queues']) ?? const [], + queues: Tentative.listFromJson(json[r'queues']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -109,12 +109,10 @@ class Tentatives { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Tentatives.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Tentatives.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/tournaments.dart b/clash-bot-api/lib/model/tournaments.dart index 9fe62df..cfdbdc6 100644 --- a/clash-bot-api/lib/model/tournaments.dart +++ b/clash-bot-api/lib/model/tournaments.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -29,8 +29,8 @@ class Tournaments { @override bool operator ==(Object other) => identical(this, other) || other is Tournaments && - other.count == count && - other.tournaments == tournaments; + other.count == count && + _deepEquality.equals(other.tournaments, tournaments); @override int get hashCode => @@ -42,14 +42,14 @@ class Tournaments { String toString() => 'Tournaments[count=$count, tournaments=$tournaments]'; Map toJson() { - final _json = {}; - if (count != null) { - _json[r'count'] = count; + final json = {}; + if (this.count != null) { + json[r'count'] = this.count; } else { - _json[r'count'] = null; + json[r'count'] = null; } - _json[r'tournaments'] = tournaments; - return _json; + json[r'tournaments'] = this.tournaments; + return json; } /// Returns a new [Tournaments] instance and imports its values from @@ -72,13 +72,13 @@ class Tournaments { return Tournaments( count: mapValueOfType(json, r'count'), - tournaments: DetailedTournament.listFromJson(json[r'tournaments']) ?? const [], + tournaments: DetailedTournament.listFromJson(json[r'tournaments']), ); } return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -109,12 +109,10 @@ class Tournaments { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = Tournaments.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = Tournaments.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/lib/model/update_user_request.dart b/clash-bot-api/lib/model/update_user_request.dart index 596b2ef..dbcbaf6 100644 --- a/clash-bot-api/lib/model/update_user_request.dart +++ b/clash-bot-api/lib/model/update_user_request.dart @@ -1,7 +1,7 @@ // // AUTO-GENERATED FILE, DO NOT MODIFY! // -// @dart=2.12 +// @dart=2.18 // ignore_for_file: unused_element, unused_import // ignore_for_file: always_put_required_named_parameters_first @@ -21,7 +21,7 @@ class UpdateUserRequest { @override bool operator ==(Object other) => identical(this, other) || other is UpdateUserRequest && - other.serverId == serverId; + other.serverId == serverId; @override int get hashCode => @@ -32,9 +32,9 @@ class UpdateUserRequest { String toString() => 'UpdateUserRequest[serverId=$serverId]'; Map toJson() { - final _json = {}; - _json[r'serverId'] = serverId; - return _json; + final json = {}; + json[r'serverId'] = this.serverId; + return json; } /// Returns a new [UpdateUserRequest] instance and imports its values from @@ -62,7 +62,7 @@ class UpdateUserRequest { return null; } - static List? listFromJson(dynamic json, {bool growable = false,}) { + static List listFromJson(dynamic json, {bool growable = false,}) { final result = []; if (json is List && json.isNotEmpty) { for (final row in json) { @@ -93,12 +93,10 @@ class UpdateUserRequest { static Map> mapListFromJson(dynamic json, {bool growable = false,}) { final map = >{}; if (json is Map && json.isNotEmpty) { - json = json.cast(); // ignore: parameter_assignments + // ignore: parameter_assignments + json = json.cast(); for (final entry in json.entries) { - final value = UpdateUserRequest.listFromJson(entry.value, growable: growable,); - if (value != null) { - map[entry.key] = value; - } + map[entry.key] = UpdateUserRequest.listFromJson(entry.value, growable: growable,); } } return map; diff --git a/clash-bot-api/pubspec.lock b/clash-bot-api/pubspec.lock index 0e365a8..f465fc7 100644 --- a/clash-bot-api/pubspec.lock +++ b/clash-bot-api/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "4826f97faae3af9761f26c52e56b2aa5ffd18d2c1721d984ad85137721c25f43" + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "31.0.0" + version: "61.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "7337610c3f9cd13e6b7c6bb0f410644091cf63c9a1436e73352a70f3286abb03" + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "2.8.0" + version: "5.13.0" args: dependency: transitive description: @@ -41,14 +41,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" - cli_util: - dependency: transitive - description: - name: cli_util - sha256: "66f86e916d285c1a93d3b79587d94bd71984a66aac4ff74e524cfa7877f1395c" - url: "https://pub.dev" - source: hosted - version: "0.3.5" clock: dependency: transitive description: @@ -58,7 +50,7 @@ packages: source: hosted version: "1.1.2" collection: - dependency: transitive + dependency: "direct main" description: name: collection sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" @@ -217,14 +209,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - pedantic: - dependency: transitive - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" pool: dependency: transitive description: @@ -333,26 +317,26 @@ packages: dependency: "direct dev" description: name: test - sha256: d8df85e0659006d6dd09dd5d1d4bf81848d34fbe5b1fdd2b2a90e690aaa8195e + sha256: "03dbf5cb87d56394ffe951eef93893b43624240aa8dd16f6f063ee01fcb22aee" url: "https://pub.dev" source: hosted - version: "1.17.12" + version: "1.21.7" test_api: dependency: transitive description: name: test_api - sha256: "3c3c3eb64242eec8aeb7a7e530cd541737a84bb01fc08b363b429aaa4a91060d" + sha256: c9aba3b3dbfe8878845dfab5fa096eb8de7b62231baeeb1cea8e3ee81ca8c6d8 url: "https://pub.dev" source: hosted - version: "0.4.3" + version: "0.4.15" test_core: dependency: transitive description: name: test_core - sha256: f269e59fdd3abd14d6d92d3da9a03f69e931e9dd9140d6f06f94fc2204584741 + sha256: f99f8a4c093d6c5adbe100494ccc259ec69c8f86eb769d661e5af18f9b6b9375 url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "0.4.19" typed_data: dependency: transitive description: diff --git a/clash-bot-api/pubspec.yaml b/clash-bot-api/pubspec.yaml index 27cbe49..70cc820 100644 --- a/clash-bot-api/pubspec.yaml +++ b/clash-bot-api/pubspec.yaml @@ -3,14 +3,15 @@ # name: 'clash_bot_api' -version: '1.0.1' +version: '1.0.0' description: 'OpenAPI API client' homepage: 'homepage' environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: - http: '>=0.13.0 <0.14.0' - intl: '^0.18.0' - meta: '^1.1.8' + collection: '>=1.17.0 <2.0.0' + http: '>=0.13.0 <2.0.0' + intl: any + meta: '>=1.1.8 <2.0.0' dev_dependencies: - test: '>=1.16.0 <1.18.0' + test: '>=1.21.6 <1.22.0' diff --git a/clash-bot-api/test/archive_metadata_test.dart b/clash-bot-api/test/archive_metadata_test.dart deleted file mode 100644 index 78133c9..0000000 --- a/clash-bot-api/test/archive_metadata_test.dart +++ /dev/null @@ -1,40 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for ArchiveMetadata -void main() { - // final instance = ArchiveMetadata(); - - group('test ArchiveMetadata', () { - // The number of Teams moved into the archive table. - // int teamsMoved - test('to test the property `teamsMoved`', () async { - // TODO - }); - - // The number of Tentative Queues moved into the archive table. - // int tentativeQueuesMoved - test('to test the property `tentativeQueuesMoved`', () async { - // TODO - }); - - // The total time the process took in milliseconds - // String totalTime - test('to test the property `totalTime`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/base_tournament_test.dart b/clash-bot-api/test/base_tournament_test.dart deleted file mode 100644 index 2692e95..0000000 --- a/clash-bot-api/test/base_tournament_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for BaseTournament -void main() { - // final instance = BaseTournament(); - - group('test BaseTournament', () { - // The name of the Tournament. - // String tournamentName - test('to test the property `tournamentName`', () async { - // TODO - }); - - // The day number of the Tournament. [1-4] - // String tournamentDay - test('to test the property `tournamentDay`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/champion_test.dart b/clash-bot-api/test/champion_test.dart deleted file mode 100644 index 594a67b..0000000 --- a/clash-bot-api/test/champion_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Champion -void main() { - // final instance = Champion(); - - group('test Champion', () { - // String name - test('to test the property `name`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/champions_api_test.dart b/clash-bot-api/test/champions_api_test.dart deleted file mode 100644 index 532cdcf..0000000 --- a/clash-bot-api/test/champions_api_test.dart +++ /dev/null @@ -1,49 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for ChampionsApi -void main() { - // final instance = ChampionsApi(); - - group('tests for ChampionsApi', () { - // Adds the requested champion to the users preferred champions. Cannot be greater than a length of 5. - // - //Future addToPreferredChampionsForUser(String xCausedBy, String discordId, { Champions champions }) async - test('test addToPreferredChampionsForUser', () async { - // TODO - }); - - // Updates the users preferred champions with an entirely new list. Cannot be greater than a length of 5. - // - //Future createListOfPreferredChampionsForUser(String xCausedBy, String discordId, { Champions champions }) async - test('test createListOfPreferredChampionsForUser', () async { - // TODO - }); - - // Removes the requested champion to the users preferred champions. - // - //Future removePreferredChampionForUser(String xCausedBy, String discordId, List champions) async - test('test removePreferredChampionForUser', () async { - // TODO - }); - - // Returns a list of preferred champions that the User has. - // - //Future retrieveUsersPreferredChampions(String xCausedBy, String discordId) async - test('test retrieveUsersPreferredChampions', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/champions_test.dart b/clash-bot-api/test/champions_test.dart deleted file mode 100644 index 73690b8..0000000 --- a/clash-bot-api/test/champions_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Champions -void main() { - // final instance = Champions(); - - group('test Champions', () { - // List champions (default value: const []) - test('to test the property `champions`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/create_user_request_test.dart b/clash-bot-api/test/create_user_request_test.dart deleted file mode 100644 index 9f47982..0000000 --- a/clash-bot-api/test/create_user_request_test.dart +++ /dev/null @@ -1,46 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for CreateUserRequest -void main() { - // final instance = CreateUserRequest(); - - group('test CreateUserRequest', () { - // The Discord id of the player - // String discordId - test('to test the property `discordId`', () async { - // TODO - }); - - // The Clash Bot User's name - // String name - test('to test the property `name`', () async { - // TODO - }); - - // The Discord Server that the player is using by default. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // The list of available Discord Servers for the player to filter by. - // List selectedGuilds (default value: const []) - test('to test the property `selectedGuilds`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/detailed_tournament_test.dart b/clash-bot-api/test/detailed_tournament_test.dart deleted file mode 100644 index 27266ad..0000000 --- a/clash-bot-api/test/detailed_tournament_test.dart +++ /dev/null @@ -1,46 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for DetailedTournament -void main() { - // final instance = DetailedTournament(); - - group('test DetailedTournament', () { - // The name of the Tournament. - // String tournamentName - test('to test the property `tournamentName`', () async { - // TODO - }); - - // The day number of the Tournament. [1-4] - // String tournamentDay - test('to test the property `tournamentDay`', () async { - // TODO - }); - - // When the Tournament starts. - // DateTime startTime - test('to test the property `startTime`', () async { - // TODO - }); - - // When you can register for the Tournament. - // DateTime registrationTime - test('to test the property `registrationTime`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/error_test.dart b/clash-bot-api/test/error_test.dart deleted file mode 100644 index f124405..0000000 --- a/clash-bot-api/test/error_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Error -void main() { - // final instance = Error(); - - group('test Error', () { - // int code - test('to test the property `code`', () async { - // TODO - }); - - // String message - test('to test the property `message`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/event_test.dart b/clash-bot-api/test/event_test.dart deleted file mode 100644 index 5178fc2..0000000 --- a/clash-bot-api/test/event_test.dart +++ /dev/null @@ -1,51 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Event -void main() { - // final instance = Event(); - - group('test Event', () { - // The unique identifier for the event. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // TeamEvent teamEvent - test('to test the property `teamEvent`', () async { - // TODO - }); - - // A message to describe the event. - // String summary - test('to test the property `summary`', () async { - // TODO - }); - - // The Discord server id attached to the event. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // Who the event was caused by. - // String causedBy - test('to test the property `causedBy`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/event_type_test.dart b/clash-bot-api/test/event_type_test.dart deleted file mode 100644 index ad3d076..0000000 --- a/clash-bot-api/test/event_type_test.dart +++ /dev/null @@ -1,21 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for EventType -void main() { - - group('test EventType', () { - - }); - -} diff --git a/clash-bot-api/test/maintenance_api_test.dart b/clash-bot-api/test/maintenance_api_test.dart deleted file mode 100644 index 5518407..0000000 --- a/clash-bot-api/test/maintenance_api_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for MaintenanceApi -void main() { - // final instance = MaintenanceApi(); - - group('tests for MaintenanceApi', () { - // Will move all Teams and Tentative Queues that are now inactive into an archive table. This will help keep current operations clean and quick. - // - //Future archiveTeamsAndTentativeQueues(String xCausedBy) async - test('test archiveTeamsAndTentativeQueues', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/player_test.dart b/clash-bot-api/test/player_test.dart deleted file mode 100644 index 3726c25..0000000 --- a/clash-bot-api/test/player_test.dart +++ /dev/null @@ -1,62 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Player -void main() { - // final instance = Player(); - - group('test Player', () { - // Discord Id for the Player - // String discordId - test('to test the property `discordId`', () async { - // TODO - }); - - // The Players discord name - // String name - test('to test the property `name`', () async { - // TODO - }); - - // Role role - test('to test the property `role`', () async { - // TODO - }); - - // A list of the Users preferred champions. - // List champions (default value: const []) - test('to test the property `champions`', () async { - // TODO - }); - - // List subscriptions (default value: const []) - test('to test the property `subscriptions`', () async { - // TODO - }); - - // The Discord Server id that the User is defaulted to. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // The list of available Discord Servers for the player to filter by. - // List selectedServers (default value: const []) - test('to test the property `selectedServers`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/position_details_test.dart b/clash-bot-api/test/position_details_test.dart deleted file mode 100644 index f76cfe6..0000000 --- a/clash-bot-api/test/position_details_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for PositionDetails -void main() { - // final instance = PositionDetails(); - - group('test PositionDetails', () { - // Champions champions - test('to test the property `champions`', () async { - // TODO - }); - - // Role role - test('to test the property `role`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/role_test.dart b/clash-bot-api/test/role_test.dart deleted file mode 100644 index 6d52145..0000000 --- a/clash-bot-api/test/role_test.dart +++ /dev/null @@ -1,21 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Role -void main() { - - group('test Role', () { - - }); - -} diff --git a/clash-bot-api/test/server_test.dart b/clash-bot-api/test/server_test.dart deleted file mode 100644 index 82d2a40..0000000 --- a/clash-bot-api/test/server_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Server -void main() { - // final instance = Server(); - - group('test Server', () { - // The unique identifier for a Discord Server. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // The Discord Server name associated to the id. - // String name - test('to test the property `name`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/servers_test.dart b/clash-bot-api/test/servers_test.dart deleted file mode 100644 index fe125cc..0000000 --- a/clash-bot-api/test/servers_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Servers -void main() { - // final instance = Servers(); - - group('test Servers', () { - // List servers (default value: const []) - test('to test the property `servers`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/subscription_api_test.dart b/clash-bot-api/test/subscription_api_test.dart deleted file mode 100644 index 623318a..0000000 --- a/clash-bot-api/test/subscription_api_test.dart +++ /dev/null @@ -1,42 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for SubscriptionApi -void main() { - // final instance = SubscriptionApi(); - - group('tests for SubscriptionApi', () { - // Retrieve details on a user's subscription. - // - //Future isUserSubscribed(String xCausedBy, String discordId, SubscriptionType subscription) async - test('test isUserSubscribed', () async { - // TODO - }); - - // Subscribes the User to the specified subscription. - // - //Future subscribeUser(String xCausedBy, String discordId, SubscriptionType subscription) async - test('test subscribeUser', () async { - // TODO - }); - - // Unsubscribes the User from the specified subscription. - // - //Future unsubscribeUser(String xCausedBy, String discordId, SubscriptionType subscription) async - test('test unsubscribeUser', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/subscription_test.dart b/clash-bot-api/test/subscription_test.dart deleted file mode 100644 index beac1d5..0000000 --- a/clash-bot-api/test/subscription_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Subscription -void main() { - // final instance = Subscription(); - - group('test Subscription', () { - // SubscriptionType key - test('to test the property `key`', () async { - // TODO - }); - - // bool isOn - test('to test the property `isOn`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/subscription_type_test.dart b/clash-bot-api/test/subscription_type_test.dart deleted file mode 100644 index 337bcef..0000000 --- a/clash-bot-api/test/subscription_type_test.dart +++ /dev/null @@ -1,21 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for SubscriptionType -void main() { - - group('test SubscriptionType', () { - - }); - -} diff --git a/clash-bot-api/test/team_api_test.dart b/clash-bot-api/test/team_api_test.dart deleted file mode 100644 index 439cd51..0000000 --- a/clash-bot-api/test/team_api_test.dart +++ /dev/null @@ -1,63 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for TeamApi -void main() { - // final instance = TeamApi(); - - group('tests for TeamApi', () { - // Assign's a User to the specified Team based on the role provided. - // - //Future assignUserToTeam(String xCausedBy, String teamId, String discordId, PositionDetails positionDetails) async - test('test assignUserToTeam', () async { - // TODO - }); - - // Creates a Team with the defined details - // - //Future createTeam(String xCausedBy, TeamRequired teamRequired) async - test('test createTeam', () async { - // TODO - }); - - // Removes a User from the specified Team. - // - //Future removeUserFromTeam(String xCausedBy, String teamId, String discordId) async - test('test removeUserFromTeam', () async { - // TODO - }); - - // Returns a single Clash Bot Team based on the id provided. - // - //Future retrieveTeamBasedOnId(String xCausedBy, String teamId) async - test('test retrieveTeamBasedOnId', () async { - // TODO - }); - - // Returns a list of Teams. - // - //Future retrieveTeams(String xCausedBy, { bool archived, String discordId, String serverId, String tournamentName, String tournamentDay }) async - test('test retrieveTeams', () async { - // TODO - }); - - // Updates an existing Clash Bot Team's metadata. - // - //Future updateTeam(String xCausedBy, String teamId, TeamUpdate teamUpdate) async - test('test updateTeam', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/team_event_test.dart b/clash-bot-api/test/team_event_test.dart deleted file mode 100644 index bfb025e..0000000 --- a/clash-bot-api/test/team_event_test.dart +++ /dev/null @@ -1,37 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamEvent -void main() { - // final instance = TeamEvent(); - - group('test TeamEvent', () { - // Team team - test('to test the property `team`', () async { - // TODO - }); - - // Tentative tentative - test('to test the property `tentative`', () async { - // TODO - }); - - // EventType eventType - test('to test the property `eventType`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_player_details_test.dart b/clash-bot-api/test/team_player_details_test.dart deleted file mode 100644 index a7a7b84..0000000 --- a/clash-bot-api/test/team_player_details_test.dart +++ /dev/null @@ -1,47 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamPlayerDetails -void main() { - // final instance = TeamPlayerDetails(); - - group('test TeamPlayerDetails', () { - // TeamPlayer top - test('to test the property `top`', () async { - // TODO - }); - - // TeamPlayer mid - test('to test the property `mid`', () async { - // TODO - }); - - // TeamPlayer jg - test('to test the property `jg`', () async { - // TODO - }); - - // TeamPlayer bot - test('to test the property `bot`', () async { - // TODO - }); - - // TeamPlayer supp - test('to test the property `supp`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_player_test.dart b/clash-bot-api/test/team_player_test.dart deleted file mode 100644 index b9a4402..0000000 --- a/clash-bot-api/test/team_player_test.dart +++ /dev/null @@ -1,40 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamPlayer -void main() { - // final instance = TeamPlayer(); - - group('test TeamPlayer', () { - // Discord Id for the Player - // String discordId - test('to test the property `discordId`', () async { - // TODO - }); - - // The Players discord name - // String name - test('to test the property `name`', () async { - // TODO - }); - - // A list of the Users preferred champions. - // List champions (default value: const []) - test('to test the property `champions`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_required_test.dart b/clash-bot-api/test/team_required_test.dart deleted file mode 100644 index 7a89d96..0000000 --- a/clash-bot-api/test/team_required_test.dart +++ /dev/null @@ -1,56 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamRequired -void main() { - // final instance = TeamRequired(); - - group('test TeamRequired', () { - // Unique identifier for a Team. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // The name of the Team. - // String name - test('to test the property `name`', () async { - // TODO - }); - - // TeamPlayerDetails playerDetails - test('to test the property `playerDetails`', () async { - // TODO - }); - - // The Discord server id that the Team belongs to. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // BaseTournament tournament - test('to test the property `tournament`', () async { - // TODO - }); - - // The timestamp that the object was updated at - // DateTime lastUpdatedAt - test('to test the property `lastUpdatedAt`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_test.dart b/clash-bot-api/test/team_test.dart deleted file mode 100644 index d22d661..0000000 --- a/clash-bot-api/test/team_test.dart +++ /dev/null @@ -1,56 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Team -void main() { - // final instance = Team(); - - group('test Team', () { - // Unique identifier for a Team. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // The name of the Team. - // String name - test('to test the property `name`', () async { - // TODO - }); - - // TeamPlayerDetails playerDetails - test('to test the property `playerDetails`', () async { - // TODO - }); - - // The Discord server id that the Team belongs to. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // BaseTournament tournament - test('to test the property `tournament`', () async { - // TODO - }); - - // The timestamp that the object was updated at - // DateTime lastUpdatedAt - test('to test the property `lastUpdatedAt`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_tournament_details_test.dart b/clash-bot-api/test/team_tournament_details_test.dart deleted file mode 100644 index 920a3f1..0000000 --- a/clash-bot-api/test/team_tournament_details_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamTournamentDetails -void main() { - // final instance = TeamTournamentDetails(); - - group('test TeamTournamentDetails', () { - // The user's Discord Id. - // String discordId - test('to test the property `discordId`', () async { - // TODO - }); - - // The Clash Tournament's name. - // Object tournamentName - test('to test the property `tournamentName`', () async { - // TODO - }); - - // The Clash Tournament's day. - // Object tournamentDay - test('to test the property `tournamentDay`', () async { - // TODO - }); - - // Role role - test('to test the property `role`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/team_update_test.dart b/clash-bot-api/test/team_update_test.dart deleted file mode 100644 index f3b5a11..0000000 --- a/clash-bot-api/test/team_update_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TeamUpdate -void main() { - // final instance = TeamUpdate(); - - group('test TeamUpdate', () { - // The name of the team - // String teamName - test('to test the property `teamName`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/teams_test.dart b/clash-bot-api/test/teams_test.dart deleted file mode 100644 index b5c5715..0000000 --- a/clash-bot-api/test/teams_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Teams -void main() { - // final instance = Teams(); - - group('test Teams', () { - // int count - test('to test the property `count`', () async { - // TODO - }); - - // List teams (default value: const []) - test('to test the property `teams`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/tentative_api_test.dart b/clash-bot-api/test/tentative_api_test.dart deleted file mode 100644 index bfa410c..0000000 --- a/clash-bot-api/test/tentative_api_test.dart +++ /dev/null @@ -1,56 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for TentativeApi -void main() { - // final instance = TentativeApi(); - - group('tests for TentativeApi', () { - // Updates an existing Tentative queue. - // - //Future assignUserToATentativeQueue(String xCausedBy, String tentativeId, String discordId) async - test('test assignUserToATentativeQueue', () async { - // TODO - }); - - // Creates a Tentative queue. - // - //Future createTentativeQueue(String xCausedBy, { TentativeRequired tentativeRequired }) async - test('test createTentativeQueue', () async { - // TODO - }); - - // Removes a User from the specified Tentative Queue. - // - //Future removeUserFromTentativeQueue(String xCausedBy, String tentativeId, String discordId) async - test('test removeUserFromTentativeQueue', () async { - // TODO - }); - - // Retrieves a Tentative queues. - // - //Future retrieveTentativeQueue(String xCausedBy, String tentativeId) async - test('test retrieveTentativeQueue', () async { - // TODO - }); - - // Retrieves a list of Tentative queues. - // - //Future retrieveTentativeQueues(String xCausedBy, { bool archived, String discordId, String serverId, String tournamentName, String tournamentDay }) async - test('test retrieveTentativeQueues', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/tentative_player_test.dart b/clash-bot-api/test/tentative_player_test.dart deleted file mode 100644 index d3c5683..0000000 --- a/clash-bot-api/test/tentative_player_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TentativePlayer -void main() { - // final instance = TentativePlayer(); - - group('test TentativePlayer', () { - // Discord Id for the Player - // String discordId - test('to test the property `discordId`', () async { - // TODO - }); - - // The Players discord name - // String name - test('to test the property `name`', () async { - // TODO - }); - - // A list of the Users preferred champions. - // List champions (default value: const []) - test('to test the property `champions`', () async { - // TODO - }); - - // Role role - test('to test the property `role`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/tentative_required_test.dart b/clash-bot-api/test/tentative_required_test.dart deleted file mode 100644 index 31f5dc8..0000000 --- a/clash-bot-api/test/tentative_required_test.dart +++ /dev/null @@ -1,50 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for TentativeRequired -void main() { - // final instance = TentativeRequired(); - - group('test TentativeRequired', () { - // Unique identifier for the Tentative Queue. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // The default Discord Server id for the player to use. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // BaseTournament tournamentDetails - test('to test the property `tournamentDetails`', () async { - // TODO - }); - - // List tentativePlayers (default value: const []) - test('to test the property `tentativePlayers`', () async { - // TODO - }); - - // The timestamp that the object was updated at - // DateTime lastUpdatedAt - test('to test the property `lastUpdatedAt`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/tentative_test.dart b/clash-bot-api/test/tentative_test.dart deleted file mode 100644 index 4d3e5e8..0000000 --- a/clash-bot-api/test/tentative_test.dart +++ /dev/null @@ -1,50 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Tentative -void main() { - // final instance = Tentative(); - - group('test Tentative', () { - // Unique identifier for the Tentative Queue. - // String id - test('to test the property `id`', () async { - // TODO - }); - - // The default Discord Server id for the player to use. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - // BaseTournament tournamentDetails - test('to test the property `tournamentDetails`', () async { - // TODO - }); - - // List tentativePlayers (default value: const []) - test('to test the property `tentativePlayers`', () async { - // TODO - }); - - // The timestamp that the object was updated at - // DateTime lastUpdatedAt - test('to test the property `lastUpdatedAt`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/tentatives_test.dart b/clash-bot-api/test/tentatives_test.dart deleted file mode 100644 index 8c18b4b..0000000 --- a/clash-bot-api/test/tentatives_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Tentatives -void main() { - // final instance = Tentatives(); - - group('test Tentatives', () { - // int count - test('to test the property `count`', () async { - // TODO - }); - - // List queues (default value: const []) - test('to test the property `queues`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/tournament_api_test.dart b/clash-bot-api/test/tournament_api_test.dart deleted file mode 100644 index f28b64f..0000000 --- a/clash-bot-api/test/tournament_api_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for TournamentApi -void main() { - // final instance = TournamentApi(); - - group('tests for TournamentApi', () { - // To create a Tournament - // - //Future createTournament(String xCausedBy, { DetailedTournament detailedTournament }) async - test('test createTournament', () async { - // TODO - }); - - //Future getTournaments(String xCausedBy, { String tournament, String day, bool upcomingOnly }) async - test('test getTournaments', () async { - // TODO - }); - - }); -} diff --git a/clash-bot-api/test/tournaments_test.dart b/clash-bot-api/test/tournaments_test.dart deleted file mode 100644 index e4cc5f7..0000000 --- a/clash-bot-api/test/tournaments_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for Tournaments -void main() { - // final instance = Tournaments(); - - group('test Tournaments', () { - // int count - test('to test the property `count`', () async { - // TODO - }); - - // List tournaments (default value: const []) - test('to test the property `tournaments`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/update_user_request_test.dart b/clash-bot-api/test/update_user_request_test.dart deleted file mode 100644 index 8a0b4a9..0000000 --- a/clash-bot-api/test/update_user_request_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - -// tests for UpdateUserRequest -void main() { - // final instance = UpdateUserRequest(); - - group('test UpdateUserRequest', () { - // The Discord Server that the player is using by default. - // String serverId - test('to test the property `serverId`', () async { - // TODO - }); - - - }); - -} diff --git a/clash-bot-api/test/user_api_test.dart b/clash-bot-api/test/user_api_test.dart deleted file mode 100644 index 3ce433a..0000000 --- a/clash-bot-api/test/user_api_test.dart +++ /dev/null @@ -1,70 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// -// @dart=2.12 - -// ignore_for_file: unused_element, unused_import -// ignore_for_file: always_put_required_named_parameters_first -// ignore_for_file: constant_identifier_names -// ignore_for_file: lines_longer_than_80_chars - -import 'package:clash_bot_api/api.dart'; -import 'package:test/test.dart'; - - -/// tests for UserApi -void main() { - // final instance = UserApi(); - - group('tests for UserApi', () { - // Adds the selected server to the users selected servers. Cannot be greater than a length of 5. - // - //Future addUsersSelectedServers(String xCausedBy, String discordId, { Servers servers }) async - test('test addUsersSelectedServers', () async { - // TODO - }); - - // Create a new Clash Bot Player. - // - //Future createUser(String xCausedBy, { CreateUserRequest createUserRequest }) async - test('test createUser', () async { - // TODO - }); - - // Updates the users selected servers with an entirely new list. Cannot be greater than a length of 5. - // - //Future createUsersSelectedServers(String xCausedBy, String discordId, { Servers servers }) async - test('test createUsersSelectedServers', () async { - // TODO - }); - - // Retrieve a Clash Bot Player Details - // - //Future getUser(String xCausedBy, { String discordId }) async - test('test getUser', () async { - // TODO - }); - - // Removes the selected server to the users selected servers. - // - //Future removeUsersSelectedServers(String xCausedBy, String discordId, List champions) async - test('test removeUsersSelectedServers', () async { - // TODO - }); - - // Returns a list of selected servers that the User has. - // - //Future retrieveUsersSelectedServers(String xCausedBy, String discordId) async - test('test retrieveUsersSelectedServers', () async { - // TODO - }); - - // Update an existing Clash Bot Player. - // - //Future updateUser(String xCausedBy, String discordId, { UpdateUserRequest updateUserRequest }) async - test('test updateUser', () async { - // TODO - }); - - }); -} diff --git a/lib/async_test.dart b/lib/async_test.dart new file mode 100644 index 0000000..d2a62c3 --- /dev/null +++ b/lib/async_test.dart @@ -0,0 +1,190 @@ +import 'package:clashbot_flutter/core/config/env.dart'; +import 'package:clashbot_flutter/globals/color_schemes.dart'; +import 'package:clashbot_flutter/main.dart'; +import 'package:clashbot_flutter/models/websocket_state.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:mobx/mobx.dart'; +import 'package:provider/provider.dart'; + +void main() async { + runApp(const MyAppEventsTest()); +} + +class MyAppEventsTest extends StatefulWidget { + const MyAppEventsTest({super.key}); + + @override + State createState() => _MyAppEventsTestState(); +} + +class _MyAppEventsTestState extends State { + @override + Widget build(BuildContext context) { + return MultiProvider( + providers: [ + Provider( + create: (_) => NotificationHandlerStore()), + ProxyProvider2( + update: (_, clashStore, notificationHandlerStore, __) => + ClashEventsStore(clashStore, notificationHandlerStore)) + ], + child: MaterialApp( + title: 'Clash Bot Test', + theme: ThemeData( + brightness: Brightness.light, + colorScheme: lightColorScheme, + useMaterial3: true, + snackBarTheme: SnackBarThemeData( + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + )), + home: Scaffold(body: const AsyncTestWidget()), + ), + ); + } +} + +class AsyncTestWidget extends StatelessWidget { + const AsyncTestWidget({ + super.key, + }); + + @override + Widget build(BuildContext context) { + ClashEventsStore clashEventStore = context.read(); + return Observer(builder: (_) { + var button; + + switch (clashEventStore.status) { + case WebSocketState.connecting: + button = const FilledButton( + onPressed: null, + child: Text('Connecting...'), + ); + break; + case WebSocketState.open: + button = const FilledButton( + onPressed: null, + child: Text('Connected'), + ); + break; + case WebSocketState.closed: + button = FilledButton( + onPressed: () { + clashEventStore.connect(Env.clashbotEventUrl); + }, + child: const Text('Connect?'), + ); + break; + case WebSocketState.error: + button = FilledButton( + onPressed: () { + clashEventStore.connect(Env.clashbotEventUrl); + }, + child: const Text('Error Connecting'), + ); + break; + default: + button = const FilledButton( + onPressed: null, + child: Text('Unknown State'), + ); + } + + final errorStore = context.read(); + autorun((_) { + if ('' != errorStore.notification.message) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + backgroundColor: hexToColor(errorStore.notification.type.color), + content: Text(errorStore.notification.message))); + errorStore.notification.message = ''; + } + }); + + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + button, + const SizedBox( + width: 20, + ), + const Text('Last Message Received:'), + const SizedBox( + width: 20, + ), + Text(clashEventStore.lastMessageReceived.toString()), + const SizedBox( + width: 20, + ), + const Text('Clash Bot Test'), + Column( + children: [ + SizedBox( + height: 400, + width: 400, + child: ListView.builder( + itemCount: clashEventStore.events.length, + itemBuilder: (context, index) { + return Container( + padding: const EdgeInsets.all(5), + child: Column( + children: [ + ListTile( + title: Text(clashEventStore.events[index] + .toString())), + const Divider( + height: 5, + color: Colors.black, + ), + ], + ), + ); + }), + ), + SizedBox( + height: 400, + width: 400, + child: ListView.builder( + itemCount: clashEventStore.teams.length, + itemBuilder: (context, index) { + return Container( + padding: const EdgeInsets.all(5), + child: Column( + children: [ + ListTile( + title: Text(clashEventStore.teams[index].name), + subtitle: Text(clashEventStore.teams[index].id), + ), + const Divider( + height: 5, + color: Colors.black, + ), + ...clashEventStore.teams[index].members.entries + .map((entry) { + return ListTile( + title: Text(entry.key.toString()), + trailing: Text(entry.value?.id ?? 'Unknown'), + ); + }).toList(), + ], + ), + ); + }), + ), + ], + ), + ], + ), + ); + }); + } +} diff --git a/lib/core/config/env.dart b/lib/core/config/env.dart index 39d3d14..92cc44e 100644 --- a/lib/core/config/env.dart +++ b/lib/core/config/env.dart @@ -2,10 +2,7 @@ import 'package:envied/envied.dart'; part 'env.g.dart'; -@Envied( - // environment: true, - // obfuscate: true, - ) +@Envied() abstract class Env { @EnviedField(varName: 'CLASHBOT_SERVICE_URL') static String clashbotServiceUrl = _Env.clashbotServiceUrl; @@ -13,4 +10,6 @@ abstract class Env { static String mockDiscordService = _Env.mockDiscordService; @EnviedField() static String discordClientId = _Env.discordClientId; + @EnviedField() + static String clashbotEventUrl = _Env.clashbotEventUrl; } diff --git a/lib/main.dart b/lib/main.dart index d70009b..14d5cb4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:clash_bot_api/api.dart'; import 'package:clashbot_flutter/core/config/env.dart'; import 'package:clashbot_flutter/globals/color_schemes.dart'; import 'package:clashbot_flutter/models/model_first_time.dart'; +import 'package:clashbot_flutter/models/websocket_state.dart'; import 'package:clashbot_flutter/pages/errorPages/whoops_page.dart'; import 'package:clashbot_flutter/pages/home/page/home_v2.dart'; import 'package:clashbot_flutter/pages/intro/welcome_page.dart'; @@ -13,10 +14,11 @@ import 'package:clashbot_flutter/services/discord_service_impl.dart'; import 'package:clashbot_flutter/services/riot_resources_service.dart'; import 'package:clashbot_flutter/services/riot_resources_service_impl.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:clashbot_flutter/styles.dart'; import 'package:clashbot_flutter/utils/reusable_widgets.dart'; import 'package:flutter/material.dart'; @@ -32,7 +34,6 @@ import 'package:validators/validators.dart'; import 'generated/git_info.dart'; import 'globals/global_settings.dart'; import 'models/model_theme.dart'; -import 'services/clashbot_events_service.dart'; final GlobalKey _rootNavigatorKey = GlobalKey(debugLabel: 'root'); @@ -120,12 +121,13 @@ class _MyAppState extends State { providers: [ ChangeNotifierProvider(create: (context) => widget.modelFirstTime), ChangeNotifierProvider(create: (context) => widget.modelTheme), - Provider(create: (_) => ErrorHandlerStore()), + Provider( + create: (_) => NotificationHandlerStore()), Provider( create: (_) => DiscordServiceImpl(setupOauth2Helper())), Provider( create: (_) => ApiClient(basePath: Env.clashbotServiceUrl)), - ProxyProvider2( + ProxyProvider2( update: (_, apiClient, errorHandlerStore, __) => ClashBotServiceImpl( UserApi(apiClient), @@ -137,26 +139,37 @@ class _MyAppState extends State { errorHandlerStore)), Provider( create: (_) => RiotResourceServiceImpl()), - Provider( - create: (_) => ClashBotEventsService()), - ProxyProvider2( + ProxyProvider2( update: (_, clashBotService, errorHandlerStore, __) => ClashStore(clashBotService, errorHandlerStore)), - ProxyProvider2( + update: (_, clashStore, errorHandlerStore, __) => + ClashEventsStore(clashStore, errorHandlerStore)), + ProxyProvider2( update: (_, discordService, errorHandlerStore, __) => DiscordDetailsStore(discordService, errorHandlerStore)), - ProxyProvider2( update: (_, riotResourceService, errorHandlerStore, __) => RiotChampionStore(riotResourceService, errorHandlerStore)), // Depends on ClashStore, DiscordDetailsStore, RiotChampionStore, ErrorHandlerStore - ProxyProvider4( - update: (_, clashStore, discordDetailsStore, riotChampionStore, - errorHandlerStore, __) => - ApplicationDetailsStore(clashStore, discordDetailsStore, - riotChampionStore, errorHandlerStore)), + ProxyProvider5< + ClashStore, + ClashEventsStore, + DiscordDetailsStore, + RiotChampionStore, + NotificationHandlerStore, + ApplicationDetailsStore>( + update: (_, clashStore, clashEventsStore, discordDetailsStore, + riotChampionStore, errorHandlerStore, __) => + ApplicationDetailsStore( + clashStore, + clashEventsStore, + discordDetailsStore, + riotChampionStore, + errorHandlerStore)), ], child: Consumer2(builder: (context, ApplicationDetailsStore appStore, @@ -276,6 +289,14 @@ class MainApp extends StatelessWidget { } } +Color hexToColor(String hex) { + hex = hex.replaceAll("#", ""); + if (hex.length == 6) { + hex = "FF$hex"; // Add full opacity if not provided + } + return Color(int.parse(hex, radix: 16)); +} + class MainContainer extends StatelessWidget { const MainContainer({required this.child, super.key}); @@ -284,13 +305,13 @@ class MainContainer extends StatelessWidget { @override Widget build(BuildContext context) { final discordDetailsStore = context.read(); - final errorStore = context.read(); + final errorStore = context.read(); autorun((_) { - if ('' != errorStore.errorMessage) { + if ('' != errorStore.notification.message) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( - backgroundColor: Colors.redAccent, - content: Text(errorStore.errorMessage))); - errorStore.errorMessage = ''; + backgroundColor: hexToColor(errorStore.notification.type.color), + content: Text(errorStore.notification.message))); + errorStore.notification.message = ''; } }); return Consumer( diff --git a/lib/models/clash_bot_event.dart b/lib/models/clash_bot_event.dart new file mode 100644 index 0000000..03ddc56 --- /dev/null +++ b/lib/models/clash_bot_event.dart @@ -0,0 +1,108 @@ +class ClashBotEvent { + const ClashBotEvent._(this.value); + + final String value; + + @override + String toString() => value; + + String toJson() => value; + + static const TEAM_UPDATE = ClashBotEvent._(r'TEAM_UPDATE'); + static const TEAM_CREATE = ClashBotEvent._(r'TEAM_CREATE'); + static const TEAM_JOINED = ClashBotEvent._(r'TEAM_JOINED'); + static const TEAM_REMOVED_FROM = ClashBotEvent._(r'TEAM_REMOVED_FROM'); + static const TEAM_REMOVED = ClashBotEvent._(r'TEAM_REMOVED'); + static const TENTATIVE_QUEUE_UPDATE = + ClashBotEvent._(r'TENTATIVE_QUEUE_UPDATE'); + static const TENTATIVE_QUEUE_CREATE = + ClashBotEvent._(r'TENTATIVE_QUEUE_CREATE'); + static const TENTATIVE_QUEUE_JOINED = + ClashBotEvent._(r'TENTATIVE_QUEUE_JOINED'); + static const TENTATIVE_QUEUE_REMOVED = + ClashBotEvent._(r'TENTATIVE_QUEUE_REMOVED'); + + /// List of all possible values in this [enum][ClashBotEvent]. + static const values = [ + TEAM_UPDATE, + TEAM_CREATE, + TEAM_JOINED, + TEAM_REMOVED_FROM, + TEAM_REMOVED, + TENTATIVE_QUEUE_UPDATE, + TENTATIVE_QUEUE_CREATE, + TENTATIVE_QUEUE_JOINED, + TENTATIVE_QUEUE_REMOVED, + ]; + + static ClashBotEvent? fromJson(dynamic value) => + ClashBotEventTypeTransformer().decode(value); + + static List? listFromJson( + dynamic json, { + bool growable = false, + }) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = ClashBotEvent.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ClashBotEvent] to String, +/// and [decode] dynamic data back to [ClashBotEvent]. +class ClashBotEventTypeTransformer { + factory ClashBotEventTypeTransformer() => + _instance ??= const ClashBotEventTypeTransformer._(); + + const ClashBotEventTypeTransformer._(); + + String encode(ClashBotEvent data) => data.value; + + /// Decodes a [dynamic value][data] to a EventType. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + ClashBotEvent? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data.toString()) { + case 'team_update': + return ClashBotEvent.TEAM_UPDATE; + case 'team_create': + return ClashBotEvent.TEAM_CREATE; + case 'team_joined': + return ClashBotEvent.TEAM_JOINED; + case 'team_removed_from': + return ClashBotEvent.TEAM_REMOVED_FROM; + case 'team_removed': + return ClashBotEvent.TEAM_REMOVED; + case 'tentative_queue_update': + return ClashBotEvent.TENTATIVE_QUEUE_UPDATE; + case 'tentative_queue_create': + return ClashBotEvent.TENTATIVE_QUEUE_CREATE; + case 'tentative_queue_joined': + return ClashBotEvent.TENTATIVE_QUEUE_JOINED; + case 'tentative_queue_removed': + return ClashBotEvent.TENTATIVE_QUEUE_REMOVED; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [ClashBotEventTypeTransformer] instance. + static ClashBotEventTypeTransformer? _instance; +} diff --git a/lib/models/clash_event.dart b/lib/models/clash_event.dart index 5b2aa7e..b5a4d4a 100644 --- a/lib/models/clash_event.dart +++ b/lib/models/clash_event.dart @@ -1,20 +1,343 @@ +import 'dart:convert'; + import 'package:clash_bot_api/api.dart'; +import 'dart:developer' as developer; + +import 'package:clashbot_flutter/models/clash_bot_event.dart'; class ClashEvent { - String id; - TeamEvent teamEvent; - int serverId; - String causedBy; + String id; + String serverId; + String causedBy; + ClashBotEvent eventType; + + ClashEvent(this.id, this.serverId, this.causedBy, this.eventType); + + static ClashEvent fromJson(data) { + final Map json = data; + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + return ClashEvent(id, serverId, causedBy, eventType); + } + + static ClashEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + return ClashEvent(id, serverId, causedBy, eventType); + } +} + +class ClashTeamEvent extends ClashEvent { + TeamPayloadEvent payload; - ClashEvent(this.id, this.teamEvent, this.serverId, this.causedBy); + ClashTeamEvent( + super.id, super.serverId, super.causedBy, super.eventType, this.payload); + + static ClashTeamEvent fromJson(data) { + final Map json = data; + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamEvent(id, serverId, causedBy, eventType, + TeamPayloadEvent.fromJson(json['payload'])); + } + + static ClashTeamEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamEvent(id, serverId, causedBy, eventType, + TeamPayloadEvent.fromJson(json['payload'])); + } } -class TeamEvent { - Team team; - Tentative tentative; - EventType eventType; +class TeamPayloadEvent { + String id; + String name; + String serverId; + PlayerDetailsEvent playerDetails; + TournamentEvent tournament; + DateTime lastUpdatedAt; + + TeamPayloadEvent(this.id, this.name, this.serverId, this.playerDetails, + this.tournament, this.lastUpdatedAt); + + static TeamPayloadEvent fromJson(data) { + final Map json = data; + final String id = json['id']; + final String name = json['name']; + final String serverId = json['serverId']; + final PlayerDetailsEvent playerDetails = + PlayerDetailsEvent.fromJson(json['playerDetails']); + final TournamentEvent tournament = + TournamentEvent.fromJson(json['tournament']); + final DateTime lastUpdatedAt = DateTime.parse(json['lastUpdatedAt']); + return TeamPayloadEvent( + id, name, serverId, playerDetails, tournament, lastUpdatedAt); + } - TeamEvent(this.team, this.tentative, this.eventType); + static TeamPayloadEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String id = json['id']; + final String name = json['name']; + final String serverId = json['serverId']; + final PlayerDetailsEvent playerDetails = + PlayerDetailsEvent.fromJson(json['playerDetails']); + final TournamentEvent tournament = + TournamentEvent.fromJson(json['tournament']); + final DateTime lastUpdatedAt = DateTime.parse(json['lastUpdatedAt']); + return TeamPayloadEvent( + id, name, serverId, playerDetails, tournament, lastUpdatedAt); + } } -enum EventType { created, updated, deleted } +class PlayerDetailsEvent { + PlayerEvent? top; + PlayerEvent? bot; + PlayerEvent? mid; + PlayerEvent? jg; + PlayerEvent? supp; + + PlayerDetailsEvent(this.top, this.bot, this.mid, this.jg, this.supp); + + static PlayerDetailsEvent fromJson(data) { + final Map json = data; + final PlayerEvent? top = + json['top'] != null ? PlayerEvent.fromJson(json['top']) : null; + final PlayerEvent? bot = + json['bot'] != null ? PlayerEvent.fromJson(json['bot']) : null; + final PlayerEvent? mid = + json['mid'] != null ? PlayerEvent.fromJson(json['mid']) : null; + final PlayerEvent? jg = + json['jg'] != null ? PlayerEvent.fromJson(json['jg']) : null; + final PlayerEvent? supp = + json['supp'] != null ? PlayerEvent.fromJson(json['supp']) : null; + return PlayerDetailsEvent(top, bot, mid, jg, supp); + } + + static PlayerDetailsEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final PlayerEvent? top = + json['top'] != null ? PlayerEvent.fromJson(json['top']) : null; + final PlayerEvent? bot = + json['bot'] != null ? PlayerEvent.fromJson(json['bot']) : null; + final PlayerEvent? mid = + json['mid'] != null ? PlayerEvent.fromJson(json['mid']) : null; + final PlayerEvent? jg = + json['jg'] != null ? PlayerEvent.fromJson(json['jg']) : null; + final PlayerEvent? supp = + json['supp'] != null ? PlayerEvent.fromJson(json['supp']) : null; + return PlayerDetailsEvent(top, bot, mid, jg, supp); + } +} + +class PlayerEvent { + String discordId; + List? champions; + + PlayerEvent(this.discordId, [this.champions]); + + static PlayerEvent fromJson(data) { + final Map json = data; + final String discordId = json['discordId']; + final List? champions = + json['champions'] != null ? List.from(json['champions']) : null; + return PlayerEvent(discordId, champions); + } + + static PlayerEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String discordId = json['discordId']; + final List? champions = + json['champions'] != null ? List.from(json['champions']) : null; + return PlayerEvent(discordId, champions); + } +} + +class TournamentEvent { + String tournamentName; + String tournamentDay; + + TournamentEvent(this.tournamentName, this.tournamentDay); + + static TournamentEvent fromJson(data) { + final Map json = data; + final String tournamentName = json['name']; + final String tournamentDay = json['day']; + return TournamentEvent(tournamentName, tournamentDay); + } + + static TournamentEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String tournamentName = json['name']; + final String tournamentDay = json['day']; + return TournamentEvent(tournamentName, tournamentDay); + } +} + +class ClashTentativeEvent extends ClashEvent { + TentativeEvent payload; + + ClashTentativeEvent( + super.id, super.serverId, super.causedBy, super.eventType, this.payload); + + static ClashTentativeEvent fromJson(data) { + final Map json = data; + final Tentative? tentative = Tentative.fromJson(json['tentative']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + final TentativeEvent payload = TentativeEvent(tentative); + return ClashTentativeEvent(id, serverId, causedBy, eventType, payload); + } + + static ClashTentativeEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final Tentative? tentative = Tentative.fromJson(json['tentative']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId'].toString(); + final String causedBy = json['causedBy'] ?? 'Unknown'; + final TentativeEvent payload = TentativeEvent(tentative); + return ClashTentativeEvent(id, serverId, causedBy, eventType, payload); + } +} + +class TentativeEvent { + Tentative? tentative; + + TentativeEvent(this.tentative); + + static TentativeEvent fromJson(data) { + final Map json = data; + final Tentative? tentative = Tentative.fromJson(json['tentative']); + return TentativeEvent(tentative); + } + + static TentativeEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final Tentative? tentative = Tentative.fromJson(json['tentative']); + return TentativeEvent(tentative); + } +} + +class ClashTeamRemovalEvent extends ClashEvent { + UserRemovalEvent payload; + ClashTeamRemovalEvent( + super.id, super.serverId, super.causedBy, super.eventType, this.payload); + + static ClashTeamRemovalEvent fromJson(data) { + final Map json = data; + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamRemovalEvent(id, serverId, causedBy, eventType, + UserRemovalEvent.fromJson(json['payload'])); + } + + static ClashTeamRemovalEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamRemovalEvent(id, serverId, causedBy, eventType, + UserRemovalEvent.fromJson(json['payload'])); + } +} + +class UserRemovalEvent { + String teamId; + String discordId; + + UserRemovalEvent(this.teamId, this.discordId); + + static UserRemovalEvent fromJson(data) { + final Map json = data; + final String teamId = json['teamId']; + final String discordId = json['discordId']; + return UserRemovalEvent(teamId, discordId); + } + + static UserRemovalEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String teamId = json['teamId']; + final String discordId = json['discordId']; + return UserRemovalEvent(teamId, discordId); + } +} + +class ClashTeamJoinedEvent extends ClashEvent { + UserJoinedEvent payload; + ClashTeamJoinedEvent( + super.id, super.serverId, super.causedBy, super.eventType, this.payload); + + static ClashTeamJoinedEvent fromJson(data) { + final Map json = data; + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamJoinedEvent(id, serverId, causedBy, eventType, + UserJoinedEvent.fromJson(json['payload'])); + } + + static ClashTeamJoinedEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final Team? team = Team.fromJson(json['team']); + final ClashBotEvent eventType = ClashBotEvent.values.firstWhere((e) => + e.toString().toLowerCase() == '${json['eventType']}'.toLowerCase()); + final String id = json['id']; + final String serverId = json['serverId']; + final String causedBy = json['causedBy'] ?? 'Unknown'; + return ClashTeamJoinedEvent(id, serverId, causedBy, eventType, + UserJoinedEvent.fromJson(json['payload'])); + } +} + +class UserJoinedEvent { + String teamId; + PlayerDetailsEvent playerDetails; + + UserJoinedEvent(this.teamId, this.playerDetails); + + static UserJoinedEvent fromJson(data) { + final Map json = data; + final String teamId = json['teamId']; + final PlayerDetailsEvent playerDetails = + PlayerDetailsEvent.fromJson(json['playerDetails']); + return UserJoinedEvent(teamId, playerDetails); + } + + static UserJoinedEvent fromJsonString(String data) { + final Map json = jsonDecode(data); + final String teamId = json['teamId']; + final PlayerDetailsEvent playerDetails = + PlayerDetailsEvent.fromJson(json['playerDetails']); + return UserJoinedEvent(teamId, playerDetails); + } +} diff --git a/lib/models/clash_team.dart b/lib/models/clash_team.dart index 5d59975..f9fb9f2 100644 --- a/lib/models/clash_team.dart +++ b/lib/models/clash_team.dart @@ -1,4 +1,5 @@ import 'package:clash_bot_api/api.dart'; +import 'package:clashbot_flutter/models/clash_event.dart'; import 'package:clashbot_flutter/models/lol_champion.dart'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; @@ -16,29 +17,89 @@ class ClashTeam { ClashTeam(this.id, this.name, this.tournamentName, this.tournamentDay, this.members, this.serverId, this.lastUpdatedAt); + ClashTeam.fromTeam(Team team) { + id = team.id ?? ''; + name = team.name ?? ''; + tournamentName = team.tournament?.tournamentName ?? ''; + tournamentDay = team.tournament?.tournamentDay ?? ''; + serverId = team.serverId ?? ''; + lastUpdatedAt = team.lastUpdatedAt ?? DateTime.now(); + members = {}; + if (null != team.playerDetails?.top) { + members[Role.top] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.top); + } + if (null != team.playerDetails?.jg) { + members[Role.jg] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.jg); + } + if (null != team.playerDetails?.mid) { + members[Role.mid] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.mid); + } + if (null != team.playerDetails?.bot) { + members[Role.bot] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.bot); + } + if (null != team.playerDetails?.supp) { + members[Role.supp] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.supp); + } + } + + ClashTeam.fromTeamEvent(TeamPayloadEvent teamPayloadEvent) { + id = teamPayloadEvent.id; + name = teamPayloadEvent.name; + tournamentName = teamPayloadEvent.tournament.tournamentName ?? ''; + tournamentDay = teamPayloadEvent.tournament.tournamentDay ?? ''; + serverId = teamPayloadEvent.serverId; + lastUpdatedAt = teamPayloadEvent.lastUpdatedAt; + members = {}; + if (null != teamPayloadEvent.playerDetails?.top) { + members[Role.top] = PlayerDetails.playerDetailsEventToPlayerDetails( + teamPayloadEvent.playerDetails.top); + } + if (null != teamPayloadEvent.playerDetails?.jg) { + members[Role.jg] = PlayerDetails.playerDetailsEventToPlayerDetails( + teamPayloadEvent.playerDetails.jg); + } + if (null != teamPayloadEvent.playerDetails?.mid) { + members[Role.mid] = PlayerDetails.playerDetailsEventToPlayerDetails( + teamPayloadEvent.playerDetails.mid); + } + if (null != teamPayloadEvent.playerDetails?.bot) { + members[Role.bot] = PlayerDetails.playerDetailsEventToPlayerDetails( + teamPayloadEvent.playerDetails.bot); + } + if (null != teamPayloadEvent.playerDetails?.supp) { + members[Role.supp] = PlayerDetails.playerDetailsEventToPlayerDetails( + teamPayloadEvent.playerDetails.supp); + } + } + static ClashTeam? teamToClashTeam(Team? team) { if (null == team) { return null; } Map mapOfPlayers = {}; if (null != team.playerDetails?.top) { - mapOfPlayers[Role.TOP] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + mapOfPlayers[Role.top] = PlayerDetails.teamPlayerDetailsToPlayerDetails( team.playerDetails?.top); } if (null != team.playerDetails?.jg) { - mapOfPlayers[Role.JG] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + mapOfPlayers[Role.jg] = PlayerDetails.teamPlayerDetailsToPlayerDetails( team.playerDetails?.jg); } if (null != team.playerDetails?.mid) { - mapOfPlayers[Role.MID] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + mapOfPlayers[Role.mid] = PlayerDetails.teamPlayerDetailsToPlayerDetails( team.playerDetails?.mid); } if (null != team.playerDetails?.bot) { - mapOfPlayers[Role.BOT] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + mapOfPlayers[Role.bot] = PlayerDetails.teamPlayerDetailsToPlayerDetails( team.playerDetails?.bot); } if (null != team.playerDetails?.supp) { - mapOfPlayers[Role.SUPP] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + mapOfPlayers[Role.supp] = PlayerDetails.teamPlayerDetailsToPlayerDetails( team.playerDetails?.supp); } return ClashTeam( @@ -54,20 +115,27 @@ class ClashTeam { ClashTeam merge(ClashTeam clashTeam) { if (!isNull(clashTeam.name)) { name = clashTeam.name; - } if (null != clashTeam.lastUpdatedAt) { + } + if (null != clashTeam.lastUpdatedAt) { lastUpdatedAt = clashTeam.lastUpdatedAt; - } if (null != clashTeam.serverId) { + } + if (null != clashTeam.serverId) { serverId = clashTeam.serverId; - } if (null != clashTeam.members[Role.TOP]) { - members[Role.TOP] = clashTeam.members[Role.TOP]; - } if (null != clashTeam.members[Role.JG]) { - members[Role.JG] = clashTeam.members[Role.JG]; - } if (null != clashTeam.members[Role.MID]) { - members[Role.MID] = clashTeam.members[Role.MID]; - } if (null != clashTeam.members[Role.BOT]) { - members[Role.BOT] = clashTeam.members[Role.BOT]; - } if (null != clashTeam.members[Role.SUPP]) { - members[Role.SUPP] = clashTeam.members[Role.SUPP]; + } + if (null != clashTeam.members[Role.top]) { + members[Role.top] = clashTeam.members[Role.top]; + } + if (null != clashTeam.members[Role.jg]) { + members[Role.jg] = clashTeam.members[Role.jg]; + } + if (null != clashTeam.members[Role.mid]) { + members[Role.mid] = clashTeam.members[Role.mid]; + } + if (null != clashTeam.members[Role.bot]) { + members[Role.bot] = clashTeam.members[Role.bot]; + } + if (null != clashTeam.members[Role.supp]) { + members[Role.supp] = clashTeam.members[Role.supp]; } return this; } @@ -78,7 +146,7 @@ class ClashTeam { } @override - bool operator == (Object o) { + bool operator ==(Object o) { if (identical(this, o)) return true; return o is ClashTeam && o.id == id && @@ -86,16 +154,15 @@ class ClashTeam { o.tournamentName == tournamentName && o.tournamentDay == tournamentDay && o.serverId == serverId && - mapEquals(o.members,members); + mapEquals(o.members, members); } } class PlayerDetails { late String id; - late String name; late List champions; - PlayerDetails(this.id, this.name, this.champions); + PlayerDetails(this.id, this.champions); static PlayerDetails? teamPlayerDetailsToPlayerDetails( TeamPlayer? teamPlayer) { @@ -103,29 +170,41 @@ class PlayerDetails { if (null != teamPlayer) { championNames .addAll(teamPlayer.champions.map((champ) => champ.name ?? '')); - return PlayerDetails( - teamPlayer.discordId ?? '', teamPlayer.name ?? '', championNames); + return PlayerDetails(teamPlayer.discordId ?? '', championNames); + } + return null; + } + + static PlayerDetails? playerDetailsEventToPlayerDetails( + PlayerEvent? playerEvent) { + List championNames = List.empty(growable: true); + if (null != playerEvent) { + if (playerEvent.champions == null) { + return PlayerDetails(playerEvent.discordId ?? '', []); + } else { + championNames + .addAll(playerEvent.champions!.map((champ) => champ ?? '')); + return PlayerDetails(playerEvent.discordId ?? '', championNames); + } } return null; } @override String toString() { - return 'PlayerDetails(id: $id, name: $name, champions: $champions)'; + return 'PlayerDetails(id: $id, champions: $champions)'; } @override - bool operator == (Object o) { + bool operator ==(Object o) { if (identical(this, o)) return true; return o is PlayerDetails && o.id == id && - o.name == name && const ListEquality().equals(o.champions, champions); } @override int get hashCode { - return id.hashCode ^ name.hashCode ^ champions.hashCode; + return id.hashCode ^ champions.hashCode; } - } diff --git a/lib/models/notification.dart b/lib/models/notification.dart new file mode 100644 index 0000000..7df58fe --- /dev/null +++ b/lib/models/notification.dart @@ -0,0 +1,100 @@ +class Notification { + String message; + NotificationType type; + + Notification(this.message, this.type); + + Notification.error(this.message) : type = NotificationType.ERROR; + + Notification.info(this.message) : type = NotificationType.INFO; + + Notification.debug(this.message) : type = NotificationType.DEBUG; + + Notification.warning(this.message) : type = NotificationType.WARNING; +} + +class NotificationType { + const NotificationType._(this.value, this.color); + + final String value; + final String color; + + @override + String toString() => value; + + String toJson() => value; + + static const ERROR = NotificationType._(r'ERROR', r'#F44336'); + static const INFO = NotificationType._(r'INFO', r'#4CAF50'); + static const DEBUG = NotificationType._(r'DEBUG', r'#2196F3'); + static const WARNING = NotificationType._(r'WARNING', r'#FFC107'); + + /// List of all possible values in this [enum][NotificationType]. + static const values = [ + ERROR, + INFO, + DEBUG, + WARNING, + ]; + + static NotificationType? fromJson(dynamic value) => + NotificationTransformer().decode(value); + + static List? listFromJson( + dynamic json, { + bool growable = false, + }) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = NotificationType.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } +} + +/// Transformation class that can [encode] an instance of [ClashBotEvent] to String, +/// and [decode] dynamic data back to [ClashBotEvent]. +class NotificationTransformer { + factory NotificationTransformer() => + _instance ??= const NotificationTransformer._(); + + const NotificationTransformer._(); + + String encode(NotificationType data) => data.value; + + /// Decodes a [dynamic value][data] to a EventType. + /// + /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully, + /// then null is returned. However, if [allowNull] is false and the [dynamic value][data] + /// cannot be decoded successfully, then an [UnimplementedError] is thrown. + /// + /// The [allowNull] is very handy when an API changes and a new enum value is added or removed, + /// and users are still using an old app with the old code. + NotificationType? decode(dynamic data, {bool allowNull = true}) { + if (data != null) { + switch (data.toString()) { + case 'ERROR': + return NotificationType.ERROR; + case 'INFO': + return NotificationType.INFO; + case 'DEBUG': + return NotificationType.DEBUG; + case 'WARNING': + return NotificationType.WARNING; + default: + if (!allowNull) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } + } + return null; + } + + /// Singleton [NotificationTransformer] instance. + static NotificationTransformer? _instance; +} diff --git a/lib/models/role_map.dart b/lib/models/role_map.dart index 18e39d9..99d3456 100644 --- a/lib/models/role_map.dart +++ b/lib/models/role_map.dart @@ -1,9 +1,9 @@ import 'package:clash_bot_api/api.dart'; final roleToValueMapper = { - Role.TOP: 'Top', - Role.JG: 'Jungle', - Role.MID: 'Middle', - Role.BOT: 'Bottem', - Role.SUPP: 'Support', -}; \ No newline at end of file + Role.top: 'Top', + Role.jg: 'Jungle', + Role.mid: 'Middle', + Role.bot: 'Bottem', + Role.supp: 'Support', +}; diff --git a/lib/models/websocket_state.dart b/lib/models/websocket_state.dart new file mode 100644 index 0000000..674334f --- /dev/null +++ b/lib/models/websocket_state.dart @@ -0,0 +1,7 @@ +enum WebSocketState { + connecting, + open, + closing, + closed, + error, +} diff --git a/lib/pages/home/page/home_v2.dart b/lib/pages/home/page/home_v2.dart index d53707d..606cfd6 100644 --- a/lib/pages/home/page/home_v2.dart +++ b/lib/pages/home/page/home_v2.dart @@ -10,7 +10,8 @@ import 'package:clashbot_flutter/pages/home/page/widgets/server_chip_list.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_svg/svg.dart'; @@ -20,7 +21,7 @@ class HomeEvent { final DateTime date; final String title; final String description; - final ClashTeam team; + final ClashTeamStore team; HomeEvent({ required this.date, diff --git a/lib/pages/home/page/widgets/events_widget.dart b/lib/pages/home/page/widgets/events_widget.dart index a49ab44..d591118 100644 --- a/lib/pages/home/page/widgets/events_widget.dart +++ b/lib/pages/home/page/widgets/events_widget.dart @@ -4,6 +4,7 @@ import 'package:clashbot_flutter/pages/home/page/widgets/team_card.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:intl/intl.dart'; @@ -106,7 +107,7 @@ class EventTile extends StatelessWidget { required this.discordDetailStore}); final Map event; - final List eventTeams; + final List eventTeams; final ApplicationDetailsStore applicationDetailsStore; final DiscordDetailsStore discordDetailStore; diff --git a/lib/pages/home/page/widgets/team_card.dart b/lib/pages/home/page/widgets/team_card.dart index 2671ff5..08ab39c 100644 --- a/lib/pages/home/page/widgets/team_card.dart +++ b/lib/pages/home/page/widgets/team_card.dart @@ -4,6 +4,7 @@ import 'package:clashbot_flutter/snackbars/join_team_snackbar.dart'; import 'package:clashbot_flutter/snackbars/remove_team_snackbar.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:intl/intl.dart'; @@ -19,16 +20,15 @@ class TeamCard extends StatelessWidget { required this.discordDetailsStore, }); + final ClashTeamStore team; final ApplicationDetailsStore applicationDetailsStore; final DiscordDetailsStore discordDetailsStore; - - final ClashTeam team; final Map roleToImage = { - Role.TOP: 'images/TopIcon.webp', - Role.BOT: 'images/BotIcon.webp', - Role.MID: 'images/MidIcon.webp', - Role.JG: 'images/JGIcon.webp', - Role.SUPP: 'images/SuppIcon.webp', + Role.top: 'images/TopIcon.webp', + Role.bot: 'images/BotIcon.webp', + Role.mid: 'images/MidIcon.webp', + Role.jg: 'images/JGIcon.webp', + Role.supp: 'images/SuppIcon.webp', }; @override @@ -62,51 +62,64 @@ class TeamCard extends StatelessWidget { : null, ); }), - Observer(builder: (_) { - var formattedDate = DateFormat.yMd().add_jm().format( - DateTime.parse( - formatter.format(team.lastUpdatedAt.toLocal()))); - return Column( - children: [ - Text( + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Tooltip( + child: Text( team.name.length > 20 ? '${team.name.substring(0, 20)}...' : team.name, style: Theme.of(context).textTheme.titleLarge, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - spacing: 5, - children: [ - Icon(Icons.update), - Text(formattedDate, - style: Theme.of(context).textTheme.bodySmall), - ], - ), - ], - ); - }), + message: 'ID ${team.id}', + ), + ], + ), const IconButton.filledTonal( tooltip: 'Coming soon...', icon: Icon(Icons.fullscreen), onPressed: null) ], ), - Expanded( - child: Flex( - direction: Axis.vertical, - spacing: 4, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: Role.values.map((role) { - return RoleChip( - image: roleToImage[role] ?? 'Unknown', - role: role, - player: team.members[role], - teamId: team.id, - isUser: team.members[role]?.id == - applicationDetailsStore.clashBotUser.discordId); - }).toList()), + Observer( + builder: (_) => Expanded( + child: Flex( + direction: Axis.vertical, + spacing: 4, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: Role.values.map((role) { + return AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + transitionBuilder: + (Widget child, Animation animation) { + return FadeTransition( + opacity: animation, child: child); + }, + child: RoleChip( + key: ValueKey(team.members[role]?.id ?? role), + image: roleToImage[role] ?? 'Unknown', + role: role, + id: team.members[role]?.id, + teamId: team.id, + isUser: team.members[role]?.id == + applicationDetailsStore.clashBotUser.discordId, + onJoinPressed: joinTeam( + role, + team.members[role]?.id, + team.name, + team.serverId), + onRemovePressed: removeFromTeam( + role, + team.members[role]?.id, + team.name, + team.serverId), + discordDetailsStore: discordDetailsStore, + ), + ); + }).toList()), + ), ), ], ), @@ -117,56 +130,73 @@ class TeamCard extends StatelessWidget { } class RoleChip extends StatelessWidget { - const RoleChip( + RoleChip( {super.key, required this.image, required this.role, - this.player, + this.id, required this.teamId, - required this.isUser}); + required this.isUser, + required this.onJoinPressed, + required this.onRemovePressed, + required this.discordDetailsStore}); final String image; final Role role; - final PlayerDetails? player; + String? id; final String teamId; final bool isUser; + final SnackBar onJoinPressed; + final SnackBar onRemovePressed; + final DiscordDetailsStore discordDetailsStore; @override Widget build(BuildContext context) { - return player != null - ? (isUser - ? UsersFilledButton( - role: role, player: player, teamId: teamId, image: image) - : RoleFilledWidget( - role: role, player: player, teamId: teamId, image: image)) + return id != null + ? Observer(builder: (_) { + var name = discordDetailsStore.discordIdToName[id]; + if (name == null || name == 'N/A') { + discordDetailsStore.pushForName(id!); + name = id; + } + return isUser + ? UsersFilledButton( + role: role, + name: name!, + teamId: teamId, + image: image, + onPressed: onRemovePressed) + : RoleFilledWidget( + role: role, name: name!, teamId: teamId, image: image); + }) : UnfilledRoleWidget( - role: role, player: player, teamId: teamId, image: image); + role: role, teamId: teamId, image: image, onPressed: onJoinPressed); } } class UsersFilledButton extends StatelessWidget { - const UsersFilledButton({ - super.key, - required this.role, - required this.player, - required this.teamId, - required this.image, - }); + const UsersFilledButton( + {super.key, + required this.role, + required this.name, + required this.teamId, + required this.image, + required this.onPressed}); final Role role; - final PlayerDetails? player; + final String name; final String teamId; final String image; + final SnackBar onPressed; @override Widget build(BuildContext context) { return FilledButton.tonal( onPressed: () { - ScaffoldMessenger.of(context).showSnackBar( - removeFromTeam(role, player!.id, player!.name, teamId)); + ScaffoldMessenger.of(context).showSnackBar(onPressed); }, style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( + backgroundColor: WidgetStateProperty.all( Theme.of(context).colorScheme.inversePrimary), ), child: Flex( @@ -185,7 +215,7 @@ class UsersFilledButton extends StatelessWidget { flex: 3, child: Center( child: Text( - player?.name ?? 'Unknown', + name, style: const TextStyle(fontWeight: FontWeight.bold), ), ), @@ -204,15 +234,15 @@ class UnfilledRoleWidget extends StatelessWidget { const UnfilledRoleWidget({ super.key, required this.role, - required this.player, required this.teamId, required this.image, + required this.onPressed, }); final Role role; - final PlayerDetails? player; final String teamId; final String image; + final SnackBar onPressed; @override Widget build(BuildContext context) { @@ -220,8 +250,7 @@ class UnfilledRoleWidget extends StatelessWidget { width: 72.5, child: FilledButton.tonal( onPressed: () { - ScaffoldMessenger.of(context) - .showSnackBar(joinTeam(role, player!.id, player!.name, teamId)); + ScaffoldMessenger.of(context).showSnackBar(onPressed); }, child: Padding( padding: const EdgeInsets.all(4.0), @@ -238,13 +267,13 @@ class RoleFilledWidget extends StatelessWidget { const RoleFilledWidget({ super.key, required this.role, - required this.player, + required this.name, required this.teamId, required this.image, }); final Role role; - final PlayerDetails? player; + final String name; final String teamId; final String image; @@ -264,7 +293,7 @@ class RoleFilledWidget extends StatelessWidget { flex: 3, child: Center( child: Text( - player?.name ?? 'Unknown', + name, style: const TextStyle(fontWeight: FontWeight.bold), ), ), diff --git a/lib/services/clashbot_events_service.dart b/lib/services/clashbot_events_service.dart deleted file mode 100644 index 99fd16b..0000000 --- a/lib/services/clashbot_events_service.dart +++ /dev/null @@ -1,186 +0,0 @@ -import 'dart:convert'; - -import 'package:clash_bot_api/api.dart'; -import 'package:clashbot_flutter/models/clash_notification.dart'; -import 'package:clashbot_flutter/stores/discord_details.store.dart'; -import 'package:stomp_dart_client/stomp.dart'; -import 'package:stomp_dart_client/stomp_config.dart'; -import 'package:stomp_dart_client/stomp_handler.dart'; -import 'package:uuid/uuid.dart'; -import 'dart:developer' as developer; - -import 'package:validators/validators.dart'; - -class ClashBotEventsService { - StompClient? stompClient; - Map openConnections = Map.of({}); - - ClashBotEventsService(); - - void connectClient(Function onConnect, Function onError) { - if (null == stompClient) { - stompClient = StompClient( - config: StompConfig( - url: 'ws://localhost:8081/ws', - onConnect: (p0) => onConnect(), - connectionTimeout: const Duration(seconds: 20), - beforeConnect: () async { - await Future.delayed(Duration(milliseconds: 200)); - }, - onWebSocketError: (error) => onError(error), - ), - ); - stompClient?.activate(); - } - } - - void setupSubscription(String loggedInUserId, String serverId, - Function notifyUser, DiscordDetailsStore detailsStore) { - if (null != stompClient && stompClient!.connected) { - openConnections.putIfAbsent( - serverId, - () => stompClient?.subscribe( - destination: '/topic/server/$serverId', - callback: (frame) { - Event? result = Event.fromJson(json.decode(frame.body!)); - var discordId = result?.causedBy ?? ''; - var username = detailsStore.discordIdToName[discordId]; - if (isNull(username)) { - detailsStore.fetchUserDetails(result?.causedBy ?? ''); - username = detailsStore.discordIdToName[discordId]; - } - switch (result!.teamEvent.eventType) { - case EventType.CREATED: - String message = ''; - if (null != result.teamEvent.team) { - // clashPlayerStore.updateClashTeam( - // ClashTeam.teamToClashTeam(result.teamEvent.team)!); - message = - 'Team ${result.teamEvent.team?.name} has been created.'; - } else if (null != result.teamEvent.tentative) { - // clashPlayerStore.updateTentativeQueue( - // TentativeQueue.tentativeToTentativeQueue( - // result.teamEvent.tentative)!); - message = 'Tentative Queue has been created!'; - } else { - throw Error(message: "Failed to handle create event."); - } - notifyUser(ClashNotification( - const Uuid().v1(), - false, - message, - username ?? '', - result.serverId, - DateTime.now())); - break; - case EventType.UPDATED: - developer - .log("Update ${result.teamEvent.eventType} triggered."); - String message = ''; - if (null != result.teamEvent.team) { - // clashPlayerStore.updateClashTeam( - // ClashTeam.teamToClashTeam(result.teamEvent.team)!); - message = - 'Team has been updated to ${result.teamEvent.team?.name}.'; - } else if (null != result.teamEvent.tentative) { - // clashPlayerStore.updateTentativeQueue( - // TentativeQueue.tentativeToTentativeQueue( - // result.teamEvent.tentative)!); - message = 'Tentative Queue has been updated or created!'; - } else { - throw Error(message: "Failed to handle update event."); - } - notifyUser(ClashNotification( - const Uuid().v1(), - false, - message, - username ?? '', - result.serverId, - DateTime.now())); - break; - case EventType.JOINED: - String message = ''; - if (null != result.teamEvent.team) { - // clashPlayerStore.updateClashTeam( - // ClashTeam.teamToClashTeam(result.teamEvent.team)!); - message = - '$username joined Team ${result.teamEvent.team?.name}.'; - } else if (null != result.teamEvent.tentative) { - // clashPlayerStore.updateTentativeQueue( - // TentativeQueue.tentativeToTentativeQueue( - // result.teamEvent.tentative)!); - message = - '$username joined Tentative Queue ${result.teamEvent.tentative?.tournamentDetails?.tournamentName} ${result.teamEvent.tentative?.tournamentDetails?.tournamentDay}.'; - } else { - throw Error(message: "Failed to handle joined event."); - } - notifyUser(ClashNotification( - const Uuid().v1(), - false, - message, - username ?? '', - result.serverId, - DateTime.now())); - break; - case EventType.REMOVED: - String message = ''; - if (null != result.teamEvent.team) { - // clashPlayerStore.updateClashTeam( - // ClashTeam.teamToClashTeam(result.teamEvent.team)!); - message = - '$username left Team ${result.teamEvent.team?.name}.'; - } else if (null != result.teamEvent.tentative) { - // clashPlayerStore.updateTentativeQueue( - // TentativeQueue.tentativeToTentativeQueue( - // result.teamEvent.tentative)!); - message = - '$username left Tentative Queue ${result.teamEvent.tentative?.tournamentDetails?.tournamentName} ${result.teamEvent.tentative?.tournamentDetails?.tournamentDay}.'; - } else { - throw Error(message: "Failed to handle removed event."); - } - notifyUser(ClashNotification( - const Uuid().v1(), - false, - message, - username ?? '', - result.serverId, - DateTime.now())); - break; - case EventType.DELETED: - String message = ''; - if (null != result.teamEvent.team) { - // clashPlayerStore.removeClashTeams( - // ClashTeam.teamToClashTeam(result.teamEvent.team)!); - message = - 'Team ${result.teamEvent.team?.name} has been deleted!'; - } else if (null != result.teamEvent.tentative) { - // clashPlayerStore.removeTentativeQueue( - // TentativeQueue.tentativeToTentativeQueue( - // result.teamEvent.tentative)!); - message = 'Tentative Queue has been deleted.'; - } else { - throw Error(message: "Failed to handle delete event."); - } - notifyUser(ClashNotification( - const Uuid().v1(), - false, - message, - username ?? '', - result.serverId, - DateTime.now())); - break; - default: - throw Error(message: "Unknown event type occurred."); - } - })); - } - } - - void removeSubscription(String serverId) { - var unsubscribe = openConnections[serverId]; - if (null != unsubscribe) { - unsubscribe(unsubscribeHeaders: {}); - openConnections.remove(serverId); - } - } -} diff --git a/lib/services/clashbot_service_impl.dart b/lib/services/clashbot_service_impl.dart index 791437e..f0dacd2 100644 --- a/lib/services/clashbot_service_impl.dart +++ b/lib/services/clashbot_service_impl.dart @@ -3,9 +3,10 @@ import 'package:clash_bot_api/api.dart'; import 'package:clashbot_flutter/models/clash_team.dart'; import 'package:clashbot_flutter/models/clash_tournament.dart'; import 'package:clashbot_flutter/models/clashbot_user.dart'; +import 'package:clashbot_flutter/models/notification.dart'; import 'package:clashbot_flutter/models/tentative_queue.dart'; import 'package:clashbot_flutter/services/clashbot_service.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; class ClashBotServiceImpl implements ClashBotService { UserApi userApi; @@ -14,7 +15,7 @@ class ClashBotServiceImpl implements ClashBotService { SubscriptionApi subscriptionApi; TentativeApi tentativeApi; TournamentApi tournamentApi; - ErrorHandlerStore errorHandlerStore; + NotificationHandlerStore errorHandlerStore; ClashBotServiceImpl( this.userApi, @@ -34,7 +35,8 @@ class ClashBotServiceImpl implements ClashBotService { .createUser(id, createUserRequest: createUserRequest) .then(playerToClashBotUser) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to create player."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to create player.")); return error; }); } @@ -45,8 +47,8 @@ class ClashBotServiceImpl implements ClashBotService { .retrieveUsersPreferredChampions(id, id) .then(fromChampionsToStringList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to retrieve user's champions."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to retrieve user's champions.")); return error; }); } @@ -57,7 +59,8 @@ class ClashBotServiceImpl implements ClashBotService { .getUser(id, discordId: id) .then(playerToClashBotUser) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to retrieve user."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to retrieve user.")); throw error; }); } @@ -73,8 +76,8 @@ class ClashBotServiceImpl implements ClashBotService { } return subscriptions; }).catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to retrieve user's subscriptions."); + errorHandlerStore.setNotification(Notification.error( + "Whoops! Failed to retrieve user's subscriptions.")); throw error; }); ; @@ -91,8 +94,8 @@ class ClashBotServiceImpl implements ClashBotService { champions: Champions(champions: championsList)) .then(fromChampionsToStringList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to overwrite user's champions."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to overwrite user's champions.")); return error; }); } @@ -103,8 +106,8 @@ class ClashBotServiceImpl implements ClashBotService { .removePreferredChampionForUser(id, id, List.of([champion])) .then(fromChampionsToStringList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to remove user's champion."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to remove user's champion.")); return error; }); } @@ -118,8 +121,8 @@ class ClashBotServiceImpl implements ClashBotService { champions: Champions(champions: championsList)) .then(fromChampionsToStringList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to update user's champions."); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to update user's champions.")); return error; }); } @@ -135,10 +138,10 @@ class ClashBotServiceImpl implements ClashBotService { .createUsersSelectedServers(id, id, servers: Servers(servers: servers)) .then(serversToServerIdList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to create user's selected servers."); + errorHandlerStore.setNotification(Notification.error( + "Whoops! Failed to create user's selected servers.")); return error; - }); + }); } @override @@ -148,10 +151,10 @@ class ClashBotServiceImpl implements ClashBotService { .removeUsersSelectedServers(id, id, selectedServers) .then(serversToServerIdList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to remove user's selected servers."); + errorHandlerStore.setNotification(Notification.error( + "Whoops! Failed to remove user's selected servers.")); return error; - }); + }); } @override @@ -165,10 +168,10 @@ class ClashBotServiceImpl implements ClashBotService { .addUsersSelectedServers(id, id, servers: Servers(servers: servers)) .then(serversToServerIdList) .catchError((error) { - errorHandlerStore - .setErrorMessage("Whoops! Failed to update user's selected servers."); + errorHandlerStore.setNotification(Notification.error( + "Whoops! Failed to update user's selected servers.")); return error; - }); + }); } @override @@ -177,9 +180,10 @@ class ClashBotServiceImpl implements ClashBotService { .assignUserToTeam(id, teamId, id, PositionDetails(role: role)) .then((team) => teamToClashTeam(team ?? Team())) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to add user to team."); - return error; - }); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to add user to team.")); + return error; + }); } @override @@ -188,9 +192,10 @@ class ClashBotServiceImpl implements ClashBotService { .assignUserToATentativeQueue(id, tentativeId, id) .then(tentativeToTentativeQueue) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to add user to tentative queue."); - return error; - }); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to add user to tentative queue.")); + return error; + }); } @override @@ -210,9 +215,9 @@ class ClashBotServiceImpl implements ClashBotService { } } return teams; - }) - .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to retrieve teams."); + }).catchError((error) { + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to retrieve teams.")); return error; }); } @@ -236,9 +241,9 @@ class ClashBotServiceImpl implements ClashBotService { } } return tentativeQueues; - }) - .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to retrieve tentative queues."); + }).catchError((error) { + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to retrieve tentative queues.")); return error; }); } @@ -249,9 +254,10 @@ class ClashBotServiceImpl implements ClashBotService { .removeUserFromTeam(id, teamId, id) .then((team) => teamToClashTeam(team ?? Team())) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to remove user from team."); - return error; - }); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to remove user from team.")); + return error; + }); } @override @@ -261,9 +267,10 @@ class ClashBotServiceImpl implements ClashBotService { .removeUserFromTentativeQueue(id, tentativeId, id) .then(tentativeToTentativeQueue) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to remove user from tentative queue."); - return error; - }); + errorHandlerStore.setNotification(Notification.error( + "Whoops! Failed to remove user from tentative queue.")); + return error; + }); } @override @@ -271,18 +278,18 @@ class ClashBotServiceImpl implements ClashBotService { String serverId, String tournamentName, String tournamentDay) { var playerDetails; switch (role) { - case Role.TOP: + case Role.top: playerDetails = TeamPlayerDetails(top: TeamPlayer(discordId: discordId)); break; - case Role.JG: + case Role.jg: playerDetails = TeamPlayerDetails(jg: TeamPlayer(discordId: discordId)); break; - case Role.MID: + case Role.mid: playerDetails = TeamPlayerDetails(mid: TeamPlayer(discordId: discordId)); break; - case Role.BOT: + case Role.bot: playerDetails = TeamPlayerDetails(bot: TeamPlayer(discordId: discordId)); break; @@ -300,9 +307,10 @@ class ClashBotServiceImpl implements ClashBotService { .createTeam(discordId, teamRequired) .then((team) => teamToClashTeam(team ?? Team())) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to create team."); - return error; - }); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to create team.")); + return error; + }); } @override @@ -319,9 +327,10 @@ class ClashBotServiceImpl implements ClashBotService { tentativePlayers: [TentativePlayer(discordId: discordId)])) .then(tentativeToTentativeQueue) .catchError((error) { - errorHandlerStore.setErrorMessage("Whoops! Failed to create tentative queue."); - return error; - }); + errorHandlerStore.setNotification( + Notification.error("Whoops! Failed to create tentative queue.")); + return error; + }); } @override @@ -391,45 +400,40 @@ class ClashBotServiceImpl implements ClashBotService { Map map = {}; if (null != team.playerDetails) { if (null != team.playerDetails!.top) { - map[Role.TOP] = PlayerDetails( + map[Role.top] = PlayerDetails( team.playerDetails!.top?.discordId ?? '', - team.playerDetails!.top?.name ?? '', team.playerDetails!.top?.champions .map((champ) => champ.name ?? '') .toList() ?? List.empty(growable: true)); } if (null != team.playerDetails?.jg) { - map[Role.JG] = PlayerDetails( + map[Role.jg] = PlayerDetails( team.playerDetails!.jg?.discordId ?? '', - team.playerDetails!.jg?.name ?? '', team.playerDetails!.jg?.champions .map((champ) => champ.name ?? '') .toList() ?? List.empty(growable: true)); } if (null != team.playerDetails?.mid) { - map[Role.MID] = PlayerDetails( + map[Role.mid] = PlayerDetails( team.playerDetails!.mid?.discordId ?? '', - team.playerDetails!.mid?.name ?? '', team.playerDetails!.mid?.champions .map((champ) => champ.name ?? '') .toList() ?? List.empty(growable: true)); } if (null != team.playerDetails?.bot) { - map[Role.BOT] = PlayerDetails( + map[Role.bot] = PlayerDetails( team.playerDetails!.bot?.discordId ?? '', - team.playerDetails!.bot?.name ?? '', team.playerDetails!.bot?.champions .map((champ) => champ.name ?? '') .toList() ?? List.empty(growable: true)); } if (null != team.playerDetails?.supp) { - map[Role.SUPP] = PlayerDetails( + map[Role.supp] = PlayerDetails( team.playerDetails!.supp?.discordId ?? '', - team.playerDetails!.supp?.name ?? '', team.playerDetails!.supp?.champions .map((champ) => champ.name ?? '') .toList() ?? @@ -453,45 +457,40 @@ class ClashBotServiceImpl implements ClashBotService { Map map = {}; if (null != team.playerDetails) { if (null != team.playerDetails!.top) { - map[Role.TOP] = PlayerDetails( + map[Role.top] = PlayerDetails( team.playerDetails!.top?.discordId ?? '', - team.playerDetails!.top?.name ?? '', team.playerDetails!.top?.champions .map((champ) => champ.name ?? '') .toList() ?? []); } if (null != team.playerDetails?.jg) { - map[Role.JG] = PlayerDetails( + map[Role.jg] = PlayerDetails( team.playerDetails!.jg?.discordId ?? '', - team.playerDetails!.jg?.name ?? '', team.playerDetails!.jg?.champions .map((champ) => champ.name ?? '') .toList() ?? []); } if (null != team.playerDetails?.mid) { - map[Role.MID] = PlayerDetails( + map[Role.mid] = PlayerDetails( team.playerDetails!.mid?.discordId ?? '', - team.playerDetails!.mid?.name ?? '', team.playerDetails!.mid?.champions .map((champ) => champ.name ?? '') .toList() ?? []); } if (null != team.playerDetails?.bot) { - map[Role.BOT] = PlayerDetails( + map[Role.bot] = PlayerDetails( team.playerDetails!.bot?.discordId ?? '', - team.playerDetails!.bot?.name ?? '', team.playerDetails!.bot?.champions .map((champ) => champ.name ?? '') .toList() ?? []); } if (null != team.playerDetails?.supp) { - map[Role.SUPP] = PlayerDetails( + map[Role.supp] = PlayerDetails( team.playerDetails!.supp?.discordId ?? '', - team.playerDetails!.supp?.name ?? '', team.playerDetails!.supp?.champions .map((champ) => champ.name ?? '') .toList() ?? diff --git a/lib/snackbars/join_team_snackbar.dart b/lib/snackbars/join_team_snackbar.dart index 0a3d7ce..d86fdc2 100644 --- a/lib/snackbars/join_team_snackbar.dart +++ b/lib/snackbars/join_team_snackbar.dart @@ -2,7 +2,7 @@ import 'package:clash_bot_api/api.dart'; import 'package:flutter/material.dart'; SnackBar joinTeam( - Role role, String playerId, String teamName, String serverId) { + Role role, String? playerId, String teamName, String serverId) { return SnackBar( content: Text('Adding you to Team as Role: ${role.toString().split('.').last}'), diff --git a/lib/snackbars/remove_team_snackbar.dart b/lib/snackbars/remove_team_snackbar.dart index 6b7b247..4369ad5 100644 --- a/lib/snackbars/remove_team_snackbar.dart +++ b/lib/snackbars/remove_team_snackbar.dart @@ -2,7 +2,7 @@ import 'package:clash_bot_api/api.dart'; import 'package:flutter/material.dart'; SnackBar removeFromTeam( - Role role, String playerId, String teamName, String serverId) { + Role role, String? playerId, String teamName, String serverId) { return SnackBar( content: Text('Removing you from the Role: ${role.toString().split('.').last}'), diff --git a/lib/stores/application_details.store.dart b/lib/stores/application_details.store.dart index 483d5ad..24510fb 100644 --- a/lib/stores/application_details.store.dart +++ b/lib/stores/application_details.store.dart @@ -1,11 +1,15 @@ import 'package:clash_bot_api/api.dart'; +import 'package:clashbot_flutter/core/config/env.dart'; import 'package:clashbot_flutter/models/clash_notification.dart'; import 'package:clashbot_flutter/models/clashbot_user.dart'; +import 'package:clashbot_flutter/models/notification.dart'; +import 'package:clashbot_flutter/models/websocket_state.dart'; import 'package:clashbot_flutter/services/clashbot_service.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:collection/collection.dart'; import 'package:mobx/mobx.dart'; import 'dart:developer' as developer; @@ -21,9 +25,14 @@ abstract class _ApplicationDetailsStore with Store { late DiscordDetailsStore _discordDetailsStore; late RiotChampionStore _riotChampionStore; final ClashStore _clashStore; - final ErrorHandlerStore _errorHandlerStore; - _ApplicationDetailsStore(this._clashStore, this._discordDetailsStore, - this._riotChampionStore, this._errorHandlerStore) { + final NotificationHandlerStore _errorHandlerStore; + final ClashEventsStore _clashEventsStore; + _ApplicationDetailsStore( + this._clashStore, + this._clashEventsStore, + this._discordDetailsStore, + this._riotChampionStore, + this._errorHandlerStore) { reaction((_) => _discordDetailsStore.discordUser, (_) { if (_discordDetailsStore.discordUser.id != '0') { _clashStore.refreshClashBotUser(_discordDetailsStore.discordUser.id); @@ -38,7 +47,23 @@ abstract class _ApplicationDetailsStore with Store { .refreshClashTournaments(_clashStore.clashBotUser.discordId!); _clashStore.refreshClashTeams(_clashStore.clashBotUser.discordId!, _clashStore.clashBotUser.selectedServers); - setPreferredServers(_clashStore.clashBotUser.selectedServers); + if (_clashEventsStore.status != WebSocketState.open) { + _clashEventsStore.connect(Env.clashbotEventUrl); + _clashEventsStore + .subscribeToServers(_clashStore.clashBotUser.selectedServers); + } + } + }); + + reaction( + (_) => (_discordDetailsStore.failedToLoad, _clashStore.failedToLoad), + (failedToLoad) { + if (failedToLoad.$1 && failedToLoad.$2) { + _errorHandlerStore.setIrreconcilable(); + } else if (failedToLoad.$2) { + _errorHandlerStore.setIrreconcilable(); + } else { + _errorHandlerStore.clearIrreconcilable(); } }); } @@ -122,8 +147,8 @@ abstract class _ApplicationDetailsStore with Store { _clashStore.createSelectedServers(id, preferredServers); _clashStore.refreshClashBotUser(id); } on Exception catch (issue) { - _errorHandlerStore.errorMessage = - 'Failed to create new Clash Bot User, please try again.'; + _errorHandlerStore.setNotification(Notification.error( + 'Failed to create new Clash Bot User, please try again.')); rethrow; } } diff --git a/lib/stores/clash_events.store.dart b/lib/stores/clash_events.store.dart new file mode 100644 index 0000000..489bc23 --- /dev/null +++ b/lib/stores/clash_events.store.dart @@ -0,0 +1,193 @@ +import 'dart:convert'; + +import 'package:clash_bot_api/api.dart'; +import 'package:clashbot_flutter/models/clash_bot_event.dart'; +import 'package:clashbot_flutter/models/clash_event.dart'; +import 'package:clashbot_flutter/models/clash_team.dart'; +import 'package:clashbot_flutter/models/notification.dart'; +import 'package:clashbot_flutter/models/websocket_state.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; +import 'package:web_socket_channel/web_socket_channel.dart'; +import 'package:mobx/mobx.dart'; + +part 'clash_events.store.g.dart'; + +class ClashEventsStore = _ClashEventsStore with _$ClashEventsStore; + +abstract class _ClashEventsStore with Store { + late WebSocketChannel channel; + final ClashStore _clashStore; + final NotificationHandlerStore _errorHandlerStore; + + _ClashEventsStore(this._clashStore, this._errorHandlerStore) { + reaction((_) => status, (_) { + switch (status) { + case WebSocketState.connecting: + _errorHandlerStore.setNotification( + Notification.info("Connecting to Clash events...")); + break; + case WebSocketState.open: + _errorHandlerStore + .setNotification(Notification.info("Connected to Clash events")); + break; + case WebSocketState.closed: + _errorHandlerStore.setNotification( + Notification.error("Disconnected from Clash events")); + break; + case WebSocketState.error: + _errorHandlerStore.setNotification( + Notification.error("Error connecting to Clash events")); + break; + default: + _errorHandlerStore.setNotification(Notification.error( + "Unkown state connecting to Clash events: $status")); + break; + } + }); + } + + @observable + WebSocketState status = WebSocketState.closed; + + @observable + DateTime lastMessageReceived = DateTime.now(); + + @observable + List events = []; + + @observable + ObservableList teams = ObservableList(); + + @action + void subscribeToServers(List servers) { + if (servers.isEmpty) { + return; + } + channel.sink.add('{"serverIds": ${servers.map((id) => '"$id"').toList()}}'); + } + + @action + void connect(String url) { + channel = WebSocketChannel.connect(Uri.parse(url)); + status = WebSocketState.connecting; + + channel.stream.listen( + (data) { + lastMessageReceived = DateTime.now(); + var event = jsonDecode(data); + if (event['eventType'] == null) { + return; + } else { + var clashEvent = ClashBotEvent.values + .firstWhere((e) => e.toString() == event['eventType']); + events.add(event['eventType'].toString()); + handleMessage(clashEvent, data); + } + }, + onDone: () => status = WebSocketState.closed, + onError: (error) { + status = WebSocketState.error; + _errorHandlerStore.setNotification( + Notification.error("Real-time events error: $error")); + }); + + status = WebSocketState.open; + } + + @action + void handleMessage(ClashBotEvent event, String data) { + var clashEvent; + try { + clashEvent = ClashEvent.fromJsonString(data); + } catch (e) { + _errorHandlerStore.setNotification( + Notification.error("Error receiving event error: $e")); + return; + } + var payload; + if (event == ClashBotEvent.TEAM_CREATE || + event == ClashBotEvent.TEAM_UPDATE) { + try { + handleTeamEvent(ClashTeamEvent.fromJsonString(data)); + } catch (e) { + _errorHandlerStore.setNotification( + Notification.error("Error handling team update: $e")); + return; + } + } else if (event == ClashBotEvent.TEAM_JOINED) { + ClashTeamJoinedEvent clashTeamJoinedEvent = + ClashTeamJoinedEvent.fromJsonString(data); + // Find filled role + Role? role; + PlayerEvent? filledRole; + if (clashTeamJoinedEvent.payload.playerDetails.bot != null) { + filledRole = clashTeamJoinedEvent.payload.playerDetails.bot; + role = Role.bot; + } else if (clashTeamJoinedEvent.payload.playerDetails.mid != null) { + filledRole = clashTeamJoinedEvent.payload.playerDetails.mid; + role = Role.mid; + } else if (clashTeamJoinedEvent.payload.playerDetails.top != null) { + filledRole = clashTeamJoinedEvent.payload.playerDetails.top; + role = Role.top; + } else if (clashTeamJoinedEvent.payload.playerDetails.jg != null) { + filledRole = clashTeamJoinedEvent.payload.playerDetails.jg; + role = Role.jg; + } else if (clashTeamJoinedEvent.payload.playerDetails.supp != null) { + filledRole = clashTeamJoinedEvent.payload.playerDetails.supp; + role = Role.supp; + } + _clashStore.addTeamMember( + clashTeamJoinedEvent.payload.teamId, role!, filledRole!.discordId); + } else if (event == ClashBotEvent.TEAM_REMOVED) { + ClashTeamRemovalEvent clashTeamRemovalEvent = + ClashTeamRemovalEvent.fromJsonString(data); + _clashStore.removeTeamMember(clashTeamRemovalEvent.payload.teamId, + clashTeamRemovalEvent.payload.discordId); + } else { + try { + handleTentativeEvent(ClashTentativeEvent.fromJsonString(data)); + } catch (e) { + _errorHandlerStore.setNotification( + Notification.error("Error handling tenantive update: $e")); + print("Error handling tenantive update: $e"); + return; + } + } + } + + @action + void handleTeamEvent(ClashTeamEvent event) { + switch (event.eventType) { + case ClashBotEvent.TEAM_CREATE: + _clashStore.addTeam(ClashTeam.fromTeamEvent(event.payload)); + break; + case ClashBotEvent.TEAM_UPDATE: + _clashStore.updateTeam(ClashTeam.fromTeamEvent(event.payload)); + break; + default: + _errorHandlerStore.setNotification( + Notification.error("Unknown event occurred ${event.eventType}")); + break; + } + } + + @action + void handleTentativeEvent(ClashTentativeEvent event) { + // Handle tentative events here + // For example, you can update the teams list or perform other actions + if (event.eventType == ClashBotEvent.TENTATIVE_QUEUE_CREATE) { + // Handle tentative queue creation + } else if (event.eventType == ClashBotEvent.TENTATIVE_QUEUE_UPDATE) { + // Handle tentative queue update + } else if (event.eventType == ClashBotEvent.TENTATIVE_QUEUE_REMOVED) { + // Handle tentative queue removal + } + } + + @action + void disconnect() { + channel.sink.close(); + status = WebSocketState.closed; + } +} diff --git a/lib/stores/discord_details.store.dart b/lib/stores/discord_details.store.dart index cbcf4b9..499c9eb 100644 --- a/lib/stores/discord_details.store.dart +++ b/lib/stores/discord_details.store.dart @@ -2,8 +2,9 @@ import 'dart:async'; import 'package:clashbot_flutter/models/discord_guild.dart'; import 'package:clashbot_flutter/models/discord_user.dart'; +import 'package:clashbot_flutter/models/notification.dart'; import 'package:clashbot_flutter/services/discord_service.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:mobx/mobx.dart'; import 'dart:developer' as developer; @@ -13,7 +14,7 @@ class DiscordDetailsStore = _DiscordDetailsStore with _$DiscordDetailsStore; abstract class _DiscordDetailsStore with Store { final DiscordService _discordService; - final ErrorHandlerStore _errorHandlerStore; + final NotificationHandlerStore _errorHandlerStore; _DiscordDetailsStore(this._discordService, this._errorHandlerStore); @observable @@ -28,6 +29,9 @@ abstract class _DiscordDetailsStore with Store { @observable ObservableList callsInProgress = ObservableList(); + @observable + bool failedToLoad = false; + @computed bool get loadingData => callsInProgress.isNotEmpty; @@ -41,6 +45,19 @@ abstract class _DiscordDetailsStore with Store { Map get discordGuildMap => {for (var guild in discordGuilds) guild.id: guild}; + @computed + bool get irreconcilableError => failedToLoad && discordUser.id == '0'; + + @action + void loadingUserDetailsFailed() { + failedToLoad = true; + } + + @action + void userDetailsSuccessfullyLoaded() { + failedToLoad = false; + } + @action void addCallInProgress(String call) { callsInProgress.add(call); @@ -56,6 +73,15 @@ abstract class _DiscordDetailsStore with Store { callsInProgress.clear(); } + @action + void pushForName(String discordId) { + if (discordIdToName.containsKey(discordId) && + discordIdToName[discordId] != 'N/A') { + return; + } + fetchUserDetails(discordId); + } + @action Future fetchUserDetails(String discordId) async { addCallInProgress('fetchUserDetails'); @@ -64,8 +90,8 @@ abstract class _DiscordDetailsStore with Store { foundUser = await _discordService.fetchUserDetails(discordId); discordIdToName.putIfAbsent(discordId, () => foundUser.username); } on Exception catch (error) { - _errorHandlerStore.errorMessage = - 'Failed to fetch Discord User details due to ${error.toString()}'; + _errorHandlerStore.setNotification(Notification.error( + 'Failed to fetch Discord User details due to ${error.toString()}')); } removeCallInProgress('fetchUserDetails'); } @@ -79,8 +105,9 @@ abstract class _DiscordDetailsStore with Store { discordUser = updatedUser.copy(); discordIdToName.putIfAbsent(updatedUser.id, () => updatedUser.username); } on Exception catch (error) { - _errorHandlerStore.errorMessage = - 'Failed to fetch Discord User details due to ${error.toString()}'; + _errorHandlerStore.setNotification(Notification.error( + 'Failed to fetch Discord User details due to ${error.toString()}')); + loadingUserDetailsFailed(); } removeCallInProgress('fetchCurrentUserDetails'); } @@ -94,7 +121,8 @@ abstract class _DiscordDetailsStore with Store { discordGuilds.clear(); discordGuilds.addAll(guilds); } on Exception catch (error) { - _errorHandlerStore.errorMessage = error.toString(); + _errorHandlerStore.setNotification(Notification.error(error.toString())); + loadingUserDetailsFailed(); } removeCallInProgress('fetchUserGuilds'); } diff --git a/lib/stores/riot_champion.store.dart b/lib/stores/riot_champion.store.dart index bcef7c3..78266d6 100644 --- a/lib/stores/riot_champion.store.dart +++ b/lib/stores/riot_champion.store.dart @@ -1,7 +1,7 @@ import 'package:clashbot_flutter/models/lol_champion.dart'; import 'package:clashbot_flutter/services/riot_resources_service.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:mobx/mobx.dart'; part 'riot_champion.store.g.dart'; @@ -9,7 +9,7 @@ class RiotChampionStore = _RiotChampionStore with _$RiotChampionStore; abstract class _RiotChampionStore with Store { RiotResourcesService _riotResourcesService; - ErrorHandlerStore _errorHandlerStore; + NotificationHandlerStore _errorHandlerStore; _RiotChampionStore(this._riotResourcesService, this._errorHandlerStore); @observable diff --git a/lib/stores/v2-stores/clash.store.dart b/lib/stores/v2-stores/clash.store.dart index 6e756ae..3bec764 100644 --- a/lib/stores/v2-stores/clash.store.dart +++ b/lib/stores/v2-stores/clash.store.dart @@ -6,7 +6,8 @@ import 'package:clashbot_flutter/models/clashbot_user.dart'; import 'package:clashbot_flutter/pages/home/page/home_v2.dart'; import 'package:clashbot_flutter/services/clashbot_service.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:mobx/mobx.dart'; import 'dart:developer' as developer; @@ -18,7 +19,7 @@ class ClashStore = _ClashStore with _$ClashStore; abstract class _ClashStore with Store { final ClashBotService _clashService; - final ErrorHandlerStore _errorhandlerStore; + final NotificationHandlerStore _errorhandlerStore; _ClashStore(this._clashService, this._errorhandlerStore); @@ -43,7 +44,7 @@ abstract class _ClashStore with Store { ObservableList tournaments = ObservableList(); @observable - ObservableList clashTeams = ObservableList(); + ObservableList clashTeams = ObservableList(); @observable bool refreshingUser = false; @@ -51,6 +52,9 @@ abstract class _ClashStore with Store { @observable ObservableList callsInProgress = ObservableList(); + @observable + bool failedToLoad = false; + @computed bool get isRefreshingData => callsInProgress.contains(_ClashStore.refreshClashBotUserCall) || @@ -165,8 +169,8 @@ abstract class _ClashStore with Store { } @computed - Map> get tournamentsToTeams { - Map> tournamentsToTeams = {}; + Map> get tournamentsToTeams { + Map> tournamentsToTeams = {}; for (var t in tournaments) { tournamentsToTeams[t] = clashTeams.where((team) { return team.tournamentName + team.tournamentDay == @@ -178,9 +182,9 @@ abstract class _ClashStore with Store { } @computed - Map> + Map> get tournamentsToTeamsFilteredToADayIfActive { - Map> ogTeams = tournamentsToTeams; + Map> ogTeams = tournamentsToTeams; if (filterByDay) { var teamy = ogTeams.map((key, value) { return MapEntry( @@ -211,7 +215,7 @@ abstract class _ClashStore with Store { } @action - void setEvents(List events) { + void setEvents(List events) { this.clashTeams = ObservableList.of(events); } @@ -233,16 +237,11 @@ abstract class _ClashStore with Store { Future refreshClashTeams( String id, List preferredServers) async { addCallInProgress(_ClashStore.refreshClashTeamsCall); - setTeamsApiCallState(ApiCallState.loading); - var futureClashTeams; - try { - futureClashTeams = - await _clashService.getClashTeams(id, preferredServers); - setTeamsApiCallState(ApiCallState.success); - } catch (e) { - setTeamsApiCallState(ApiCallState.error); - } - clashTeams = ObservableList.of(futureClashTeams); + var futureClashTeams = + await _clashService.getClashTeams(id, preferredServers); + clashTeams = ObservableList.of(futureClashTeams.map((t) { + return ClashTeamStore.fromClashTeam(t); + }).toList()); removeCallInProgress(_ClashStore.refreshClashTeamsCall); } @@ -259,6 +258,43 @@ abstract class _ClashStore with Store { refreshClashTeams(id, selectedServers); } + @action + void addTeam(ClashTeam team) { + clashTeams.add(ClashTeamStore.fromClashTeam(team)); + } + + @action + void updateTeam(ClashTeam team) { + var index = clashTeams.indexWhere((element) => element.id == team.id); + if (index != -1) { + clashTeams[index].updateLastUpdatedAt(team.lastUpdatedAt); + clashTeams[index].updateName(team.name); + } + } + + @action + void addTeamMember(String teamId, Role role, String memberId) { + var index = clashTeams.indexWhere((element) => element.id == teamId); + print("addTeamMember: Adding member $memberId to team $teamId"); + if (index != -1) { + print("addTeamMember: Found team $teamId"); + clashTeams[index].updateMember(role, memberId, []); + } + } + + @action + void removeTeamMember(String teamId, String memberId) { + var index = clashTeams.indexWhere((element) => element.id == teamId); + if (index != -1) { + clashTeams[index].removeMember(memberId); + } + } + + @action + void removeTeam(String id) { + clashTeams.removeWhere((element) => element.id == id); + } + @action Future createPlayer( String id, String username, String preferredServers) async { diff --git a/lib/stores/v2-stores/clash_team.store.dart b/lib/stores/v2-stores/clash_team.store.dart new file mode 100644 index 0000000..db8cd5c --- /dev/null +++ b/lib/stores/v2-stores/clash_team.store.dart @@ -0,0 +1,104 @@ +import 'package:clash_bot_api/api.dart'; +import 'package:clashbot_flutter/models/clash_team.dart'; +import 'package:mobx/mobx.dart'; + +part 'clash_team.store.g.dart'; + +class ClashTeamStore = _ClashTeamStore with _$ClashTeamStore; + +abstract class _ClashTeamStore with Store { + _ClashTeamStore(this.id, this.name, this.tournamentName, this.tournamentDay, + this.members, this.serverId, this.lastUpdatedAt); + + _ClashTeamStore.fromTeam(Team team) { + id = team.id ?? ''; + name = team.name ?? ''; + tournamentName = team.tournament?.tournamentName ?? ''; + tournamentDay = team.tournament?.tournamentDay ?? ''; + serverId = team.serverId ?? ''; + lastUpdatedAt = team.lastUpdatedAt ?? DateTime.now(); + members = ObservableMap(); + if (null != team.playerDetails?.top) { + members[Role.top] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.top); + } + if (null != team.playerDetails?.jg) { + members[Role.jg] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.jg); + } + if (null != team.playerDetails?.mid) { + members[Role.mid] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.mid); + } + if (null != team.playerDetails?.bot) { + members[Role.bot] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.bot); + } + if (null != team.playerDetails?.supp) { + members[Role.supp] = PlayerDetails.teamPlayerDetailsToPlayerDetails( + team.playerDetails?.supp); + } + } + + _ClashTeamStore.fromClashTeam(ClashTeam clashTeam) { + id = clashTeam.id; + name = clashTeam.name; + tournamentName = clashTeam.tournamentName; + tournamentDay = clashTeam.tournamentDay; + serverId = clashTeam.serverId; + lastUpdatedAt = clashTeam.lastUpdatedAt; + members = ObservableMap(); + members.addAll(clashTeam.members); + } + + late String id; + late String serverId; + late String tournamentName; + late String tournamentDay; + + @observable + late String name; + + @observable + late ObservableMap members; + + @observable + late DateTime lastUpdatedAt; + + @action + void updateName(String newName) { + name = newName; + } + + @action + void updateMember(Role role, String id, List champions) { + print("clash_team.store: Updating member $id"); + if (members[role] == null) { + print("clash_team.store: Found member $id"); + // Remove player from other role + members.forEach((key, value) { + if (value?.id == id) { + print( + "clash_team.store: Removing member $id from role $key"); + members[key] = null; + } + }); + print("clash_team.store: Adding member $id to role $role"); + members[role] = PlayerDetails( + id, + champions, + ); + } + } + + @action + void removeMember(String discordId) { + print("clash_team.store: Removing member $discordId"); + members.removeWhere((key, value) => value?.id == discordId); + } + + @action + void updateLastUpdatedAt(DateTime newDate) { + lastUpdatedAt = newDate; + } +} diff --git a/lib/stores/v2-stores/error_handler.store.dart b/lib/stores/v2-stores/error_handler.store.dart deleted file mode 100644 index 9d5caaa..0000000 --- a/lib/stores/v2-stores/error_handler.store.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:mobx/mobx.dart'; - -part 'error_handler.store.g.dart'; - -class ErrorHandlerStore = _ErrorHandlerStore with _$ErrorHandlerStore; - -abstract class _ErrorHandlerStore with Store { - @observable - String errorMessage = ''; - - @action - void setErrorMessage(String message) { - errorMessage = message; - } - - @action - void clearErrorMessage() { - errorMessage = ''; - } -} diff --git a/lib/stores/v2-stores/notification_handler.store.dart b/lib/stores/v2-stores/notification_handler.store.dart new file mode 100644 index 0000000..7d834f5 --- /dev/null +++ b/lib/stores/v2-stores/notification_handler.store.dart @@ -0,0 +1,38 @@ +import 'package:clashbot_flutter/models/notification.dart'; +import 'package:mobx/mobx.dart'; + +part 'notification_handler.store.g.dart'; + +class NotificationHandlerStore = _NotificationHandlerStore + with _$NotificationHandlerStore; + +abstract class _NotificationHandlerStore with Store { + @observable + Notification notification = Notification( + '', + NotificationType.ERROR, + ); + + @observable + bool irreconcilable = false; + + @action + void setIrreconcilable() { + irreconcilable = true; + } + + @action + void clearIrreconcilable() { + irreconcilable = false; + } + + @action + void setNotification(Notification notification) { + this.notification = notification; + } + + @action + void clearNotification() { + notification = Notification('', NotificationType.ERROR); + } +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 7cd50bf..f80952e 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -182,7 +182,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 5a1da84..41f66f7 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift index d53ef64..b3c1761 100644 --- a/macos/Runner/AppDelegate.swift +++ b/macos/Runner/AppDelegate.swift @@ -1,9 +1,13 @@ import Cocoa import FlutterMacOS -@NSApplicationMain +@main class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/pubspec.lock b/pubspec.lock index 9f0472b..92ab8be 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -148,7 +148,7 @@ packages: path: clash-bot-api relative: true source: path - version: "1.0.1" + version: "1.0.0" clock: dependency: transitive description: @@ -1241,7 +1241,7 @@ packages: source: hosted version: "1.1.1" web_socket_channel: - dependency: transitive + dependency: "direct main" description: name: web_socket_channel sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b diff --git a/pubspec.yaml b/pubspec.yaml index b85a4e6..9efade5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: clashbot_flutter description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -31,7 +31,6 @@ dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -64,6 +63,7 @@ dependencies: intl: ^0.18.1 flutter_neat_and_clean_calendar: ^0.4.16 flutter_svg: ^2.0.9 + web_socket_channel: ^2.4.0 dev_dependencies: flutter_test: @@ -91,7 +91,6 @@ scripts: # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. diff --git a/test/unit/models/clash_event_test.dart b/test/unit/models/clash_event_test.dart new file mode 100644 index 0000000..0b833b2 --- /dev/null +++ b/test/unit/models/clash_event_test.dart @@ -0,0 +1,63 @@ +import 'package:clashbot_flutter/models/clash_bot_event.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:clashbot_flutter/models/clash_event.dart'; +import 'package:clash_bot_api/api.dart'; + +void main() { + group('ClashEvent', () { + test('fromJson creates a valid ClashEvent object', () { + const data = ''' + { + "id": "ct-91ca1a97-054f-4e29-bdab-714f865293ba", + "serverId": "123456", + "summary": "Team created", + "causedBy": null, + "payload": { + "id": "ct-91ca1a97-054f-4e29-bdab-714f865293ba", + "serverId": "123456", + "lastUpdatedAt": "2025-03-30T22:50:37.217685-05:00", + "name": "Some Team 2", + "playerDetails": { + "top": { + "discordId": "1", + "champions": [] + }, + "jg": null, + "mid": null, + "bot": { + "discordId": "2", + "champions": [] + }, + "supp": null + }, + "tournament": { + "name": "ARAM", + "day": "2" + } + }, + "eventType": "TEAM_CREATE" + } + '''; + + final clashEvent = ClashTeamEvent.fromJsonString(data); + + expect(clashEvent.id, 'ct-91ca1a97-054f-4e29-bdab-714f865293ba'); + expect(clashEvent.serverId, "123456"); + expect(clashEvent.causedBy, "Unknown"); + expect(clashEvent.eventType, ClashBotEvent.TEAM_CREATE); + expect(clashEvent.payload.name, 'Some Team 2'); + expect(clashEvent.payload.playerDetails.top?.discordId, '1'); + expect(clashEvent.payload.playerDetails.bot?.discordId, '2'); + expect(clashEvent.payload.playerDetails.top?.champions, []); + expect(clashEvent.payload.playerDetails.bot?.champions, []); + expect(clashEvent.payload.playerDetails.jg, null); + expect(clashEvent.payload.playerDetails.mid, null); + expect(clashEvent.payload.playerDetails.supp, null); + expect(clashEvent.payload.tournament.tournamentName, "ARAM"); + expect(clashEvent.payload.tournament.tournamentDay, "2"); + expect(clashEvent.payload.lastUpdatedAt, + DateTime.parse('2025-03-30T22:50:37.217685-05:00')); + expect(clashEvent.payload.id, 'ct-91ca1a97-054f-4e29-bdab-714f865293ba'); + }); + }); +} diff --git a/test/unit/models/clash_team_test.dart b/test/unit/models/clash_team_test.dart index 4bea682..3e6a5bd 100644 --- a/test/unit/models/clash_team_test.dart +++ b/test/unit/models/clash_team_test.dart @@ -6,11 +6,8 @@ void main() { group("Player Details", () { test('Test TeamPlayer to PlayerDetails mapping', () async { var teamPlayer = TeamPlayer( - discordId: '123', - name: 'somePlayer', - champions: List.of([Champion(name: 'Aatrox')])); - var expectedPlayerDetails = - PlayerDetails("123", 'somePlayer', ['Aatrox']); + discordId: '123', champions: List.of([Champion(name: 'Aatrox')])); + var expectedPlayerDetails = PlayerDetails("123", ['Aatrox']); expect(PlayerDetails.teamPlayerDetailsToPlayerDetails(teamPlayer), expectedPlayerDetails); }); @@ -19,9 +16,7 @@ void main() { group("Clash Team", () { test('Test Team to ClashTeam mapping', () async { var teamPlayer = TeamPlayer( - discordId: '123', - name: 'somePlayer', - champions: List.of([Champion(name: 'Aatrox')])); + discordId: '123', champions: List.of([Champion(name: 'Aatrox')])); var team = Team( id: "ct-123-123-123", name: 'Some Team Name', @@ -30,10 +25,14 @@ void main() { tournamentName: 'awesome_sauce', tournamentDay: '1'), lastUpdatedAt: DateTime(2023, 2, 1, 12, 51, 0, 0, 0), playerDetails: TeamPlayerDetails(top: teamPlayer)); - var expectedPlayerDetails = - PlayerDetails("123", 'somePlayer', ['Aatrox']); - var expectedClashTeam = ClashTeam('ct-123-123-123', 'Some Team Name', - 'awesome_sauce', '1', {Role.TOP: expectedPlayerDetails}, '123', + var expectedPlayerDetails = PlayerDetails("123", ['Aatrox']); + var expectedClashTeam = ClashTeam( + 'ct-123-123-123', + 'Some Team Name', + 'awesome_sauce', + '1', + {Role.top: expectedPlayerDetails}, + '123', DateTime.now()); expect(ClashTeam.teamToClashTeam(team), expectedClashTeam); }); @@ -44,32 +43,28 @@ void main() { serverId: '123', tournament: BaseTournament( tournamentName: 'awesome_sauce', tournamentDay: '1')); - var expectedClashTeam = ClashTeam('ct-123-123-123', 'Some Team Name', - 'awesome_sauce', '1', {}, '123', DateTime(2023, 2, 1, 12, 51, 0, 0, 0)); + var expectedClashTeam = ClashTeam( + 'ct-123-123-123', + 'Some Team Name', + 'awesome_sauce', + '1', + {}, + '123', + DateTime(2023, 2, 1, 12, 51, 0, 0, 0)); expect(ClashTeam.teamToClashTeam(team), expectedClashTeam); }); test('All Players - Test Team to ClashTeam mapping', () async { var topPlayer = TeamPlayer( - discordId: '123', - name: 'somePlayer1', - champions: List.of([Champion(name: 'Aatrox')])); + discordId: '123', champions: List.of([Champion(name: 'Aatrox')])); var jgPlayer = TeamPlayer( - discordId: '124', - name: 'somePlayer2', - champions: List.of([Champion(name: 'Nocturn')])); + discordId: '124', champions: List.of([Champion(name: 'Nocturn')])); var midPlayer = TeamPlayer( - discordId: '125', - name: 'somePlayer3', - champions: List.of([Champion(name: 'Anivia')])); + discordId: '125', champions: List.of([Champion(name: 'Anivia')])); var botPlayer = TeamPlayer( - discordId: '126', - name: 'somePlayer4', - champions: List.of([Champion(name: 'Jhin')])); + discordId: '126', champions: List.of([Champion(name: 'Jhin')])); var suppPlayer = TeamPlayer( - discordId: '127', - name: 'somePlayer5', - champions: List.of([Champion(name: 'Karma')])); + discordId: '127', champions: List.of([Champion(name: 'Karma')])); var team = Team( id: "ct-123-123-123", name: 'Some Team Name', @@ -77,31 +72,30 @@ void main() { tournament: BaseTournament( tournamentName: 'awesome_sauce', tournamentDay: '1'), playerDetails: TeamPlayerDetails( - top: topPlayer, - jg: jgPlayer, - mid: midPlayer, - bot: botPlayer, - supp: suppPlayer - )); - var expectedTopPlayerDetails = - PlayerDetails("123", 'somePlayer1', ['Aatrox']); - var expectedJgPlayerDetails = - PlayerDetails("124", 'somePlayer2', ['Nocturn']); - var expectedMidPlayerDetails = - PlayerDetails("125", 'somePlayer3', ['Anivia']); - var expectedBotPlayerDetails = - PlayerDetails("126", 'somePlayer4', ['Jhin']); - var expectedSuppPlayerDetails = - PlayerDetails("127", 'somePlayer5', ['Karma']); - var expectedClashTeam = ClashTeam('ct-123-123-123', 'Some Team Name', - 'awesome_sauce', '1', { - Role.TOP: expectedTopPlayerDetails, - Role.JG: expectedJgPlayerDetails, - Role.MID: expectedMidPlayerDetails, - Role.BOT: expectedBotPlayerDetails, - Role.SUPP: expectedSuppPlayerDetails + top: topPlayer, + jg: jgPlayer, + mid: midPlayer, + bot: botPlayer, + supp: suppPlayer)); + var expectedTopPlayerDetails = PlayerDetails("123", ['Aatrox']); + var expectedJgPlayerDetails = PlayerDetails("124", ['Nocturn']); + var expectedMidPlayerDetails = PlayerDetails("125", ['Anivia']); + var expectedBotPlayerDetails = PlayerDetails("126", ['Jhin']); + var expectedSuppPlayerDetails = PlayerDetails("127", ['Karma']); + var expectedClashTeam = ClashTeam( + 'ct-123-123-123', + 'Some Team Name', + 'awesome_sauce', + '1', + { + Role.top: expectedTopPlayerDetails, + Role.jg: expectedJgPlayerDetails, + Role.mid: expectedMidPlayerDetails, + Role.bot: expectedBotPlayerDetails, + Role.supp: expectedSuppPlayerDetails }, - '123', DateTime.now()); + '123', + DateTime.now()); expect(ClashTeam.teamToClashTeam(team), expectedClashTeam); }); }); diff --git a/widgetbook/lib/calendar_widget.dart b/widgetbook/lib/calendar_widget.dart index 3db5786..8b01e8c 100644 --- a/widgetbook/lib/calendar_widget.dart +++ b/widgetbook/lib/calendar_widget.dart @@ -12,7 +12,8 @@ import 'package:clashbot_flutter/services/riot_resources_service_impl.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:flutter/material.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; @@ -24,7 +25,7 @@ import 'package:widgetbook_workspace/utils/mock_utils.dart'; @widgetbook.UseCase(name: 'Loading', type: CalendarWidget) Widget buildCoolButtonUseCase(BuildContext context) { List tournaments = buildTournaments(1); - List clashTeams = buildClashTeams(2); + List clashTeams = buildClashTeams(2); List guilds = buildGuilds(1); CalendarWidgetDependencies calendarWidgetDependencies = buildCalendarWidgetDependencies( @@ -52,7 +53,7 @@ Widget buildCalendarStory(BuildContext context) { initialValue: 1, ); List tournaments = buildTournaments(numberOfTournaments); - List clashTeams = buildClashTeams(2); + List clashTeams = buildClashTeams(2); List guilds = buildGuilds(1); CalendarWidgetDependencies calendarWidgetDependencies = buildCalendarWidgetDependencies( @@ -81,7 +82,7 @@ Widget buildCalendarStoryError(BuildContext context) { initialValue: 1, ); List tournaments = buildTournaments(numberOfTournaments); - List clashTeams = buildClashTeams(2); + List clashTeams = buildClashTeams(2); List guilds = buildGuilds(1); CalendarWidgetDependencies calendarWidgetDependencies = buildCalendarWidgetDependencies( @@ -105,7 +106,7 @@ class CalendarWidgetDependencies { final ClashStore clashStore; final DiscordDetailsStore discordDetailsStore; final RiotChampionStore riotChampionStore; - final ErrorHandlerStore errorHandlerStore; + final NotificationHandlerStore errorHandlerStore; CalendarWidgetDependencies( this.clashStore, @@ -117,7 +118,7 @@ class CalendarWidgetDependencies { CalendarWidgetDependencies buildCalendarWidgetDependencies( List tournaments, - List clashTeams, + List clashTeams, List guilds, ApiCallState tournamentsApiCallState, ApiCallState teamsApiCallState, @@ -127,12 +128,12 @@ CalendarWidgetDependencies buildCalendarWidgetDependencies( guilds, DiscordUser('1', 'Mock User', 'icon', '1'), DiscordServiceImpl(setupOauth2Helper()), - ErrorHandlerStore(), + NotificationHandlerStore(), ); var clashUser = ClashBotUser( discordId: "1", champions: [], - role: Role.TOP, + role: Role.top, serverId: 'server1', selectedServers: ['server1'], preferredServers: ['server1', 'server2'], @@ -152,15 +153,18 @@ CalendarWidgetDependencies buildCalendarWidgetDependencies( SubscriptionApi(apiClient), TentativeApi(apiClient), TournamentApi(apiClient), - ErrorHandlerStore(), + NotificationHandlerStore(), ), - ErrorHandlerStore(), + NotificationHandlerStore(), ); clashStore.addCallInProgress('getTournaments'); return CalendarWidgetDependencies( clashStore, discordDetailsStore, - MockRiotChampionStore(RiotResourceServiceImpl(), ErrorHandlerStore()), - ErrorHandlerStore(), + MockRiotChampionStore( + RiotResourceServiceImpl(), + NotificationHandlerStore(), + ), + NotificationHandlerStore(), ); } diff --git a/widgetbook/lib/event_list_widget.dart b/widgetbook/lib/event_list_widget.dart index c6efc9b..38e4942 100644 --- a/widgetbook/lib/event_list_widget.dart +++ b/widgetbook/lib/event_list_widget.dart @@ -10,10 +10,13 @@ import 'package:clashbot_flutter/services/clashbot_service_impl.dart'; import 'package:clashbot_flutter/services/discord_service_impl.dart'; import 'package:clashbot_flutter/services/riot_resources_service_impl.dart'; import 'package:clashbot_flutter/stores/application_details.store.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:flutter/material.dart'; +import 'package:mobx/mobx.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart'; import 'package:widgetbook_workspace/utils/mock_utils.dart'; @@ -23,7 +26,7 @@ Widget buildEventListWidget(BuildContext context) { var clashBotUser = ClashBotUser( discordId: "1", champions: [], - role: Role.TOP, + role: Role.top, serverId: 'server1', selectedServers: ['server1'], preferredServers: ['server1', 'server2'], @@ -69,17 +72,17 @@ Widget buildEventListWidget(BuildContext context) { ), ], [ - ClashTeam( + ClashTeamStore( '1', 'Mock Team 1', 'Mock Tournament 1', '1', - { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.JG: PlayerDetails('2', 'Player 2', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.SUPP: PlayerDetails('5', 'Player 5', []), - }, + ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.jg: PlayerDetails('2', []), + Role.mid: PlayerDetails('3', []), + Role.supp: PlayerDetails('5', []), + }), '460520499680641035', DateTime.now(), ), @@ -94,24 +97,25 @@ Widget buildEventListWidget(BuildContext context) { SubscriptionApi(apiClient), TentativeApi(apiClient), TournamentApi(apiClient), - ErrorHandlerStore(), + NotificationHandlerStore(), ), - ErrorHandlerStore(), + NotificationHandlerStore(), ); var mockDiscordDetailsStore = MockDiscordDetailsStore( buildGuilds(2), DiscordUser('1', 'Mock User', 'Mock#0001', 'avatar'), DiscordServiceImpl(setupOauth2Helper()), - ErrorHandlerStore(), + NotificationHandlerStore(), ); var mockServers = buildMockServers(2); var applicationDetailsStore = MockApplicationDetailsStore( clashBotUser, mockServers, clashStoreW5Tournies, + ClashEventsStore(clashStoreW5Tournies, NotificationHandlerStore()), mockDiscordDetailsStore, - RiotChampionStore(RiotResourceServiceImpl(), ErrorHandlerStore()), - ErrorHandlerStore(), + RiotChampionStore(RiotResourceServiceImpl(), NotificationHandlerStore()), + NotificationHandlerStore(), ); return EventsListWidget( clashStore: clashStoreW5Tournies, diff --git a/widgetbook/lib/server_list_widget.dart b/widgetbook/lib/server_list_widget.dart index 05fa2ea..f48818b 100644 --- a/widgetbook/lib/server_list_widget.dart +++ b/widgetbook/lib/server_list_widget.dart @@ -1,4 +1,6 @@ import 'package:clashbot_flutter/pages/home/page/widgets/server_chip_list.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:flutter/widgets.dart'; import 'package:clash_bot_api/api.dart'; import 'package:clashbot_flutter/enums/api_call_state.dart'; @@ -16,7 +18,6 @@ import 'package:clashbot_flutter/stores/application_details.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import 'package:provider/provider.dart'; @@ -70,13 +71,13 @@ ServerChipListDependencies buildServerChipListDependencies({ final mockUser = ClashBotUser( discordId: '123456789', champions: [], - role: Role.TOP, + role: Role.top, serverId: servers[0], selectedServers: servers, preferredServers: servers, ); - final errorHandlerStore = ErrorHandlerStore(); + final errorHandlerStore = NotificationHandlerStore(); final mockDiscordUser = DiscordUser( '123456789', 'mock_username', @@ -115,6 +116,7 @@ ServerChipListDependencies buildServerChipListDependencies({ mockUser, servers, mockClashStore, + ClashEventsStore(mockClashStore, errorHandlerStore), mockDiscordDetailsStore, RiotChampionStore(RiotResourceServiceImpl(), errorHandlerStore), errorHandlerStore, diff --git a/widgetbook/lib/team_card_widget.dart b/widgetbook/lib/team_card_widget.dart index 9e5f4cc..f94da28 100644 --- a/widgetbook/lib/team_card_widget.dart +++ b/widgetbook/lib/team_card_widget.dart @@ -8,9 +8,11 @@ import 'package:clashbot_flutter/pages/home/page/widgets/team_card.dart'; import 'package:clashbot_flutter/services/clashbot_service_impl.dart'; import 'package:clashbot_flutter/services/discord_service_impl.dart'; import 'package:clashbot_flutter/services/riot_resources_service_impl.dart'; -import 'package:clashbot_flutter/stores/riot_champion.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/clash_events.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/notification_handler.store.dart'; import 'package:flutter/material.dart'; +import 'package:mobx/mobx.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart'; import 'package:widgetbook_workspace/utils/mock_utils.dart'; @@ -20,7 +22,7 @@ Widget buildTeamCardWidget(BuildContext context) { var clashUser = ClashBotUser( discordId: "1", champions: [], - role: Role.TOP, + role: Role.top, serverId: 'server1', selectedServers: ['server1'], preferredServers: ['server1', 'server2'], @@ -31,38 +33,43 @@ Widget buildTeamCardWidget(BuildContext context) { buildGuilds(2), DiscordUser('1', 'Mock User', 'Mock#0001', 'avatar'), DiscordServiceImpl(setupOauth2Helper()), - ErrorHandlerStore(), + NotificationHandlerStore(), + ); + var mockClashStore = MockClashStore( + clashUser, + buildTournaments(2), + buildClashTeams(2), + ApiCallState.success, + ApiCallState.success, + ApiCallState.success, + ClashBotServiceImpl( + UserApi(apiClient), + TeamApi(apiClient), + ChampionsApi(apiClient), + SubscriptionApi(apiClient), + TentativeApi(apiClient), + TournamentApi(apiClient), + NotificationHandlerStore(), + ), + NotificationHandlerStore(), ); var mockApplicationDetailsStore = new MockApplicationDetailsStore( clashUser, mockServers, - MockClashStore( - clashUser, - buildTournaments(2), - buildClashTeams(2), - ApiCallState.success, - ApiCallState.success, - ApiCallState.success, - ClashBotServiceImpl( - UserApi(apiClient), - TeamApi(apiClient), - ChampionsApi(apiClient), - SubscriptionApi(apiClient), - TentativeApi(apiClient), - TournamentApi(apiClient), - ErrorHandlerStore(), - ), - ErrorHandlerStore(), - ), + mockClashStore, + ClashEventsStore(mockClashStore, NotificationHandlerStore()), mockDiscordDetailsStore, - MockRiotChampionStore(RiotResourceServiceImpl(), ErrorHandlerStore()), - ErrorHandlerStore(), + MockRiotChampionStore( + RiotResourceServiceImpl(), + NotificationHandlerStore(), + ), + NotificationHandlerStore(), ); return Center( child: TeamCard( applicationDetailsStore: mockApplicationDetailsStore, discordDetailsStore: mockDiscordDetailsStore, - team: ClashTeam( + team: ClashTeamStore( '1', 'Mock Team', 'Tournament 1', @@ -75,60 +82,60 @@ Widget buildTeamCardWidget(BuildContext context) { min: 0, )) { case 0: - return { - Role.TOP: PlayerDetails('123456789', 'Player 1', []), - Role.JG: PlayerDetails('2', 'Player 2', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.BOT: PlayerDetails('5', 'Player 4', []), - Role.SUPP: PlayerDetails('5', 'Player 5', []), - }; + return ObservableMap.of({ + Role.top: PlayerDetails('123456789', []), + Role.jg: PlayerDetails('2', []), + Role.mid: PlayerDetails('3', []), + Role.bot: PlayerDetails('5', []), + Role.supp: PlayerDetails('5', []), + }); case 1: - return { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.JG: PlayerDetails('2', 'Player 2', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.BOT: PlayerDetails('5', 'Player 4', []), - Role.SUPP: null, - }; + return ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.jg: PlayerDetails('2', []), + Role.mid: PlayerDetails('3', []), + Role.bot: PlayerDetails('5', []), + Role.supp: null, + }); case 2: - return { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.JG: PlayerDetails('2', 'Player 2', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.BOT: null, - Role.SUPP: null, - }; + return ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.jg: PlayerDetails('2', []), + Role.mid: PlayerDetails('3', []), + Role.bot: null, + Role.supp: null, + }); case 3: - return { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.JG: null, - Role.BOT: null, - Role.SUPP: null, - }; + return ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.mid: PlayerDetails('3', []), + Role.jg: null, + Role.bot: null, + Role.supp: null, + }); case 4: - return { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.JG: null, - Role.MID: null, - Role.BOT: null, - Role.SUPP: null, - }; + return ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.mid: null, + Role.jg: null, + Role.bot: null, + Role.supp: null, + }); case 5: - return { - Role.TOP: null, - Role.JG: null, - Role.MID: null, - Role.BOT: null, - Role.SUPP: null, - }; + return ObservableMap.of({ + Role.top: null, + Role.mid: null, + Role.jg: null, + Role.bot: null, + Role.supp: null, + }); default: - return { - Role.TOP: PlayerDetails('1', 'Player 1', []), - Role.JG: PlayerDetails('2', 'Player 2', []), - Role.MID: PlayerDetails('3', 'Player 3', []), - Role.SUPP: PlayerDetails('5', 'Player 5', []), - }; + return ObservableMap.of({ + Role.top: PlayerDetails('1', []), + Role.jg: PlayerDetails('2', []), + Role.mid: PlayerDetails('3', []), + Role.supp: PlayerDetails('5', []), + }); } }(), '123456789', diff --git a/widgetbook/lib/utils/mock_utils.dart b/widgetbook/lib/utils/mock_utils.dart index 7521212..501ae6d 100644 --- a/widgetbook/lib/utils/mock_utils.dart +++ b/widgetbook/lib/utils/mock_utils.dart @@ -14,7 +14,7 @@ import 'package:clashbot_flutter/stores/application_details.store.dart'; import 'package:clashbot_flutter/stores/discord_details.store.dart'; import 'package:clashbot_flutter/stores/riot_champion.store.dart'; import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart'; -import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart'; +import 'package:clashbot_flutter/stores/v2-stores/clash_team.store.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; @@ -30,20 +30,20 @@ List buildTournaments(int count) { ); } -List buildClashTeams(int count) { +List buildClashTeams(int count) { return List.generate( count, - (index) => ClashTeam( + (index) => ClashTeamStore( '$index', 'Mock Team $index', 'Mock Tournament $index', '$index', - { - Role.TOP: PlayerDetails('$index', 'Player $index', []), - Role.JG: PlayerDetails('${index + 1}', 'Player ${index + 1}', []), - Role.MID: PlayerDetails('${index + 2}', 'Player ${index + 2}', []), - Role.SUPP: PlayerDetails('${index + 3}', 'Player ${index + 3}', []), - }, + ObservableMap.of({ + Role.top: PlayerDetails('$index', []), + Role.jg: PlayerDetails('${index + 1}', []), + Role.mid: PlayerDetails('${index + 2}', []), + Role.supp: PlayerDetails('${index + 3}', []), + }), '123456789', DateTime.now(), ), @@ -68,6 +68,7 @@ class MockApplicationDetailsStore extends ApplicationDetailsStore { ClashBotUser mockClashBotUser, List mockPreferredServers, super._clashStore, + super._clashEventsStore, super._discordDetailsStore, super._riotChampionStore, super._errorHandlerStore, @@ -94,7 +95,7 @@ class MockClashStore extends ClashStore { MockClashStore( ClashBotUser clashBotUser, List tournaments, - List clashTeams, + List clashTeams, ApiCallState tournamentsApiCallStateToBeSet, ApiCallState teamsApiCallState, ApiCallState userApiCallState,