From ff485400504936477c1a67fd3bf3f7f21e124c04 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 05:28:39 +0000 Subject: [PATCH] SDK regeneration --- .github/workflows/ci.yml | 18 +- build.gradle | 20 +- .../codecombat/api/CodecombatApiClient.java | 151 ++++-- .../api/CodecombatApiClientBuilder.java | 33 ++ .../api/client/auth/authService.java | 39 -- .../api/client/auth/authServiceClient.java | 34 -- .../client/auth/authServiceErrorDecoder.java | 31 -- .../api/client/auth/endpoints/Get.java | 255 --------- .../client/auth/exceptions/GetException.java | 116 ---- .../api/client/clans/clansService.java | 37 -- .../api/client/clans/clansServiceClient.java | 36 -- .../clans/clansServiceErrorDecoder.java | 31 -- .../client/clans/endpoints/UpsertClan.java | 115 ---- .../clans/exceptions/UpsertClanException.java | 117 ---- .../api/client/clans/types/ClanResponse.java | 294 ----------- .../client/clans/types/UpsertClanRequest.java | 100 ---- .../client/classrooms/classroomsService.java | 107 ---- .../classrooms/classroomsServiceClient.java | 138 ----- .../classroomsServiceErrorDecoder.java | 59 --- .../client/classrooms/endpoints/Create.java | 115 ---- .../endpoints/DeleteUserFromClassroom.java | 142 ----- .../endpoints/EnrollUserInCourse.java | 204 ------- .../api/client/classrooms/endpoints/Get.java | 155 ------ .../classrooms/endpoints/GetLevelSession.java | 148 ------ .../classrooms/endpoints/GetMembersStats.java | 222 -------- .../endpoints/RemoveUserFromClassroom.java | 204 ------- .../endpoints/UpsertFromClassroom.java | 142 ----- .../exceptions/CreateException.java | 117 ---- .../DeleteUserFromClassroomException.java | 117 ---- .../EnrollUserInCourseException.java | 117 ---- .../classrooms/exceptions/GetException.java | 116 ---- .../exceptions/GetLevelSessionException.java | 117 ---- .../exceptions/GetMembersStatsException.java | 117 ---- .../RemoveUserFromClassroomException.java | 117 ---- .../UpsertFromClassroomException.java | 117 ---- .../client/classrooms/types/AceConfig.java | 93 ---- .../types/CreateClassroomRequest.java | 144 ----- .../types/DeleteUserFromClassroomRequest.java | 141 ----- .../types/EnrollUserInCourseRequest.java | 93 ---- .../api/client/classrooms/types/Level.java | 93 ---- .../types/LevelSessionResponse.java | 332 ------------ .../client/classrooms/types/MemberStat.java | 115 ---- .../client/classrooms/types/PlayStats.java | 119 ----- .../types/RemoveUserFromClassroomRequest.java | 93 ---- .../api/client/classrooms/types/State.java | 91 ---- .../types/UpsertClassroomRequest.java | 170 ------ .../client/commons/types/AuthIdentity.java | 115 ---- .../commons/types/ClassroomResponse.java | 217 -------- .../types/ClassroomResponseWithCode.java | 294 ----------- .../api/client/commons/types/Course.java | 168 ------ .../api/client/commons/types/License.java | 116 ---- .../client/commons/types/Subscription.java | 116 ---- .../client/commons/types/UserResponse.java | 294 ----------- .../api/client/commons/types/UserStats.java | 146 ----- .../stats/endpoints/GetLicenseStats.java | 80 --- .../stats/endpoints/GetPlaytimeStats.java | 150 ------ .../exceptions/GetLicenseStatsException.java | 117 ---- .../exceptions/GetPlaytimeStatsException.java | 117 ---- .../api/client/stats/statsService.java | 47 -- .../api/client/stats/statsServiceClient.java | 52 -- .../stats/statsServiceErrorDecoder.java | 35 -- .../stats/types/LicenseStatsResponse.java | 179 ------- .../stats/types/PlaytimeStatsResponse.java | 122 ----- .../users/endpoints/AddOAuthIdentity.java | 142 ----- .../api/client/users/endpoints/Create.java | 115 ---- .../api/client/users/endpoints/FindUser.java | 148 ------ .../api/client/users/endpoints/Get.java | 154 ------ .../client/users/endpoints/GetClassrooms.java | 155 ------ .../api/client/users/endpoints/GetHero.java | 142 ----- .../client/users/endpoints/GrantLicense.java | 142 ----- .../client/users/endpoints/SetAceConfig.java | 142 ----- .../users/endpoints/ShortenLicense.java | 142 ----- .../users/endpoints/ShortenSubscription.java | 142 ----- .../api/client/users/endpoints/Update.java | 142 ----- .../users/endpoints/UpdateSubscription.java | 142 ----- .../exceptions/AddOAuthIdentityException.java | 117 ---- .../users/exceptions/CreateException.java | 117 ---- .../users/exceptions/FindUserException.java | 117 ---- .../exceptions/GetClassroomsException.java | 117 ---- .../client/users/exceptions/GetException.java | 116 ---- .../users/exceptions/GetHeroException.java | 117 ---- .../exceptions/GrantLicenseException.java | 117 ---- .../exceptions/SetAceConfigException.java | 117 ---- .../exceptions/ShortenLicenseException.java | 117 ---- .../ShortenSubscriptionException.java | 117 ---- .../users/exceptions/UpdateException.java | 117 ---- .../UpdateSubscriptionException.java | 117 ---- .../users/types/AddOAuthIdentityRequest.java | 178 ------- .../client/users/types/CreateUserRequest.java | 250 --------- .../client/users/types/GetHeroRequest.java | 90 ---- .../users/types/GrantLicenseRequest.java | 93 ---- .../api/client/users/types/HeroConfig.java | 90 ---- .../api/client/users/types/SetAceConfig.java | 151 ------ .../users/types/ShortenLicenseRequest.java | 93 ---- .../types/ShortenSubscriptionRequest.java | 93 ---- .../types/UpdateSubscriptionRequest.java | 93 ---- .../client/users/types/UpdateUserRequest.java | 140 ----- .../api/client/users/types/UserRole.java | 87 --- .../api/client/users/usersService.java | 125 ----- .../api/client/users/usersServiceClient.java | 204 ------- .../users/usersServiceErrorDecoder.java | 75 --- .../com/codecombat/api/core/ApiError.java | 25 + .../com/codecombat/api/core/BasicAuth.java | 58 -- .../codecombat/api/core/ClientOptions.java | 86 +++ .../com/codecombat/api/core/Environment.java | 24 +- .../codecombat/api/core/ObjectMappers.java | 28 +- .../codecombat/api/core/RequestOptions.java | 23 + .../com/codecombat/api/core/Suppliers.java | 20 + ...PostUsersHandleOAuthIdentitiesRequest.java | 164 ++++++ .../api/resources/auth/AuthClient.java | 63 +++ .../auth/requests/LoginOauthRequest.java | 241 +++++++++ .../api/resources/clans/ClansClient.java | 65 +++ .../requests/ClansUpsertMemberRequest.java | 90 ++++ .../classrooms/ClassroomsClient.java | 385 ++++++++++++++ .../requests/ClassroomsCreateRequest.java | 135 +++++ .../ClassroomsEnrollUserInCourseRequest.java | 121 +++++ .../ClassroomsGetMembersStatsRequest.java | 133 +++++ .../requests/ClassroomsGetRequest.java | 127 +++++ .../ClassroomsRemoveEnrolledUserRequest.java | 121 +++++ .../ClassroomsRemoveMemberRequest.java | 127 +++++ .../ClassroomsUpsertMemberRequest.java | 156 ++++++ .../api/resources/stats/StatsClient.java | 93 ++++ .../StatsGetPlaytimeStatsRequest.java | 131 +++++ .../api/resources/users/UsersClient.java | 499 ++++++++++++++++++ .../users/requests/UsersCreateRequest.java | 239 +++++++++ .../requests/UsersGetClassroomsRequest.java | 80 +++ .../users/requests/UsersGetRequest.java | 80 +++ .../requests/UsersGrantLicenseRequest.java | 83 +++ .../UsersGrantPremiumSubscriptionRequest.java | 84 +++ .../requests/UsersSetAceConfigRequest.java | 133 +++++ .../users/requests/UsersSetHeroRequest.java | 77 +++ .../requests/UsersShortenLicenseRequest.java | 83 +++ .../UsersShortenSubscriptionRequest.java | 83 +++ .../users/requests/UsersUpdateRequest.java | 127 +++++ .../codecombat/api/types/ClanResponse.java | 281 ++++++++++ .../api/types/ClassroomResponse.java | 199 +++++++ .../types/ClassroomResponseCoursesItem.java | 152 ++++++ .../api/types/ClassroomResponseWithCode.java | 281 ++++++++++ .../ClassroomResponseWithCodeCoursesItem.java | 153 ++++++ .../ClassroomsCreateRequestAceConfig.java | 80 +++ ...ClassroomsGetMembersStatsResponseItem.java | 101 ++++ ...roomsGetMembersStatsResponseItemStats.java | 103 ++++ .../api/types/LevelSessionResponse.java | 326 ++++++++++++ .../api/types/LevelSessionResponseLevel.java | 80 +++ .../api/types/LevelSessionResponseState.java | 77 +++ .../api/types/LicenseStatsResponse.java | 163 ++++++ .../api/types/PlaytimeStatsResponse.java | 105 ++++ .../codecombat/api/types/UserResponse.java | 280 ++++++++++ .../api/types/UserResponseLicense.java | 99 ++++ .../UserResponseOAuthIdentitiesItem.java | 99 ++++ .../api/types/UserResponseStats.java | 128 +++++ .../api/types/UserResponseSubscription.java | 99 ++++ .../types/UsersCreateRequestHeroConfig.java | 77 +++ .../api/types/UsersCreateRequestRole.java | 21 + .../java/com/codecombat/api/TestClient.java | 8 + 155 files changed, 6982 insertions(+), 12634 deletions(-) create mode 100644 src/main/java/com/codecombat/api/CodecombatApiClientBuilder.java delete mode 100644 src/main/java/com/codecombat/api/client/auth/authService.java delete mode 100644 src/main/java/com/codecombat/api/client/auth/authServiceClient.java delete mode 100644 src/main/java/com/codecombat/api/client/auth/authServiceErrorDecoder.java delete mode 100644 src/main/java/com/codecombat/api/client/auth/endpoints/Get.java delete mode 100644 src/main/java/com/codecombat/api/client/auth/exceptions/GetException.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/clansService.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/clansServiceClient.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/clansServiceErrorDecoder.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/endpoints/UpsertClan.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/exceptions/UpsertClanException.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/types/ClanResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/clans/types/UpsertClanRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/classroomsService.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/classroomsServiceClient.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/classroomsServiceErrorDecoder.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/Create.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/DeleteUserFromClassroom.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/EnrollUserInCourse.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/Get.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/GetLevelSession.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/GetMembersStats.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/RemoveUserFromClassroom.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/endpoints/UpsertFromClassroom.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/CreateException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/DeleteUserFromClassroomException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/EnrollUserInCourseException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/GetException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/GetLevelSessionException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/GetMembersStatsException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/RemoveUserFromClassroomException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/exceptions/UpsertFromClassroomException.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/AceConfig.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/CreateClassroomRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/DeleteUserFromClassroomRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/EnrollUserInCourseRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/Level.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/LevelSessionResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/MemberStat.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/PlayStats.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/RemoveUserFromClassroomRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/State.java delete mode 100644 src/main/java/com/codecombat/api/client/classrooms/types/UpsertClassroomRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/AuthIdentity.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/ClassroomResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/ClassroomResponseWithCode.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/Course.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/License.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/Subscription.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/UserResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/commons/types/UserStats.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/endpoints/GetLicenseStats.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/endpoints/GetPlaytimeStats.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/exceptions/GetLicenseStatsException.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/exceptions/GetPlaytimeStatsException.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/statsService.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/statsServiceClient.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/statsServiceErrorDecoder.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/types/LicenseStatsResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/stats/types/PlaytimeStatsResponse.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/AddOAuthIdentity.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/Create.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/FindUser.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/Get.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/GetClassrooms.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/GetHero.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/GrantLicense.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/SetAceConfig.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/ShortenLicense.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/ShortenSubscription.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/Update.java delete mode 100644 src/main/java/com/codecombat/api/client/users/endpoints/UpdateSubscription.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/AddOAuthIdentityException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/CreateException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/FindUserException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/GetClassroomsException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/GetException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/GetHeroException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/GrantLicenseException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/SetAceConfigException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/ShortenLicenseException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/ShortenSubscriptionException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/UpdateException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/exceptions/UpdateSubscriptionException.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/AddOAuthIdentityRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/CreateUserRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/GetHeroRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/GrantLicenseRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/HeroConfig.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/SetAceConfig.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/ShortenLicenseRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/ShortenSubscriptionRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/UpdateSubscriptionRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/UpdateUserRequest.java delete mode 100644 src/main/java/com/codecombat/api/client/users/types/UserRole.java delete mode 100644 src/main/java/com/codecombat/api/client/users/usersService.java delete mode 100644 src/main/java/com/codecombat/api/client/users/usersServiceClient.java delete mode 100644 src/main/java/com/codecombat/api/client/users/usersServiceErrorDecoder.java create mode 100644 src/main/java/com/codecombat/api/core/ApiError.java delete mode 100644 src/main/java/com/codecombat/api/core/BasicAuth.java create mode 100644 src/main/java/com/codecombat/api/core/ClientOptions.java create mode 100644 src/main/java/com/codecombat/api/core/RequestOptions.java create mode 100644 src/main/java/com/codecombat/api/core/Suppliers.java create mode 100644 src/main/java/com/codecombat/api/requests/PostUsersHandleOAuthIdentitiesRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/auth/AuthClient.java create mode 100644 src/main/java/com/codecombat/api/resources/auth/requests/LoginOauthRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/clans/ClansClient.java create mode 100644 src/main/java/com/codecombat/api/resources/clans/requests/ClansUpsertMemberRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/ClassroomsClient.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsCreateRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsEnrollUserInCourseRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetMembersStatsRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveEnrolledUserRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveMemberRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsUpsertMemberRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/stats/StatsClient.java create mode 100644 src/main/java/com/codecombat/api/resources/stats/requests/StatsGetPlaytimeStatsRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/UsersClient.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersCreateRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersGetClassroomsRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersGetRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersGrantLicenseRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersGrantPremiumSubscriptionRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersSetAceConfigRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersSetHeroRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersShortenLicenseRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersShortenSubscriptionRequest.java create mode 100644 src/main/java/com/codecombat/api/resources/users/requests/UsersUpdateRequest.java create mode 100644 src/main/java/com/codecombat/api/types/ClanResponse.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomResponse.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomResponseCoursesItem.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomResponseWithCode.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomResponseWithCodeCoursesItem.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomsCreateRequestAceConfig.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItem.java create mode 100644 src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItemStats.java create mode 100644 src/main/java/com/codecombat/api/types/LevelSessionResponse.java create mode 100644 src/main/java/com/codecombat/api/types/LevelSessionResponseLevel.java create mode 100644 src/main/java/com/codecombat/api/types/LevelSessionResponseState.java create mode 100644 src/main/java/com/codecombat/api/types/LicenseStatsResponse.java create mode 100644 src/main/java/com/codecombat/api/types/PlaytimeStatsResponse.java create mode 100644 src/main/java/com/codecombat/api/types/UserResponse.java create mode 100644 src/main/java/com/codecombat/api/types/UserResponseLicense.java create mode 100644 src/main/java/com/codecombat/api/types/UserResponseOAuthIdentitiesItem.java create mode 100644 src/main/java/com/codecombat/api/types/UserResponseStats.java create mode 100644 src/main/java/com/codecombat/api/types/UserResponseSubscription.java create mode 100644 src/main/java/com/codecombat/api/types/UsersCreateRequestHeroConfig.java create mode 100644 src/main/java/com/codecombat/api/types/UsersCreateRequestRole.java create mode 100644 src/test/java/com/codecombat/api/TestClient.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7c5f89..0414818 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,8 +20,24 @@ jobs: - name: Compile run: ./gradlew compileJava - publish: + test: needs: [ compile ] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Java + id: setup-jre + uses: actions/setup-java@v1 + with: + java-version: "11" + architecture: x64 + + - name: Test + run: ./gradlew test + publish: + needs: [ compile, test ] if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index 8cd811e..952528d 100644 --- a/build.gradle +++ b/build.gradle @@ -12,17 +12,17 @@ repositories { } dependencies { - api 'io.github.fern-api:jersey-utils:0.0.82' + api 'com.squareup.okhttp3:okhttp:4.9.3' api 'com.fasterxml.jackson.core:jackson-databind:2.13.0' api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3' - api 'io.github.openfeign:feign-jackson:11.8' - api 'io.github.openfeign:feign-core:11.8' - api 'io.github.openfeign:feign-jaxrs2:11.8' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' } spotless { java { - googleJavaFormat() + palantirJavaFormat() } } @@ -31,12 +31,16 @@ java { withJavadocJar() } +test { + useJUnitPlatform() +} + publishing { publications { maven(MavenPublication) { - groupId = 'io.github.fern-api' - artifactId = 'codecombat' - version = '0.0.9' + groupId = 'com.codecombat' + artifactId = 'codecombat-java' + version = '0.1.5' from components.java } } diff --git a/src/main/java/com/codecombat/api/CodecombatApiClient.java b/src/main/java/com/codecombat/api/CodecombatApiClient.java index aedd840..74ac219 100644 --- a/src/main/java/com/codecombat/api/CodecombatApiClient.java +++ b/src/main/java/com/codecombat/api/CodecombatApiClient.java @@ -1,67 +1,118 @@ package com.codecombat.api; -import com.codecombat.api.client.auth.authServiceClient; -import com.codecombat.api.client.clans.clansServiceClient; -import com.codecombat.api.client.classrooms.classroomsServiceClient; -import com.codecombat.api.client.stats.statsServiceClient; -import com.codecombat.api.client.users.usersServiceClient; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.Environment; -import java.util.Objects; -import java.util.concurrent.atomic.AtomicReference; +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.core.Suppliers; +import com.codecombat.api.requests.PostUsersHandleOAuthIdentitiesRequest; +import com.codecombat.api.resources.auth.AuthClient; +import com.codecombat.api.resources.clans.ClansClient; +import com.codecombat.api.resources.classrooms.ClassroomsClient; +import com.codecombat.api.resources.stats.StatsClient; +import com.codecombat.api.resources.users.UsersClient; +import com.codecombat.api.types.UserResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import java.util.function.Supplier; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; -public final class CodecombatApiClient { - private final Supplier authServiceClient; +public class CodecombatApiClient { + protected final ClientOptions clientOptions; - private final Supplier clansServiceClient; + protected final Supplier authClient; - private final Supplier classroomsServiceClient; + protected final Supplier clansClient; - private final Supplier statsServiceClient; + protected final Supplier classroomsClient; - private final Supplier usersServiceClient; + protected final Supplier statsClient; - public CodecombatApiClient(BasicAuth auth) { - this(Environment.PRODUCTION, auth); - } + protected final Supplier usersClient; - public CodecombatApiClient(Environment environment, BasicAuth auth) { - this.authServiceClient = memoize(() -> new authServiceClient(environment.getUrl(), auth)); - this.clansServiceClient = memoize(() -> new clansServiceClient(environment.getUrl(), auth)); - this.statsServiceClient = memoize(() -> new statsServiceClient(environment.getUrl(), auth)); - this.classroomsServiceClient = memoize(() -> new classroomsServiceClient(environment.getUrl(), auth)); - this.usersServiceClient = memoize(() -> new usersServiceClient(environment.getUrl(), auth)); - } + public CodecombatApiClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.authClient = Suppliers.memoize(() -> new AuthClient(clientOptions)); + this.clansClient = Suppliers.memoize(() -> new ClansClient(clientOptions)); + this.classroomsClient = Suppliers.memoize(() -> new ClassroomsClient(clientOptions)); + this.statsClient = Suppliers.memoize(() -> new StatsClient(clientOptions)); + this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions)); + } - public final authServiceClient auth() { - return this.authServiceClient.get(); - } + public UserResponse postUsersHandleOAuthIdentities(String handle, PostUsersHandleOAuthIdentitiesRequest request) { + return postUsersHandleOAuthIdentities(handle, request, null); + } - public final clansServiceClient clans() { - return this.clansServiceClient.get(); - } + public UserResponse postUsersHandleOAuthIdentities( + String handle, PostUsersHandleOAuthIdentitiesRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("o-auth-identities") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("provider", request.getProvider()); + if (request.getAccessToken().isPresent()) { + _requestBodyProperties.put("accessToken", request.getAccessToken()); + } + if (request.getCode().isPresent()) { + _requestBodyProperties.put("code", request.getCode()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("POST", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } - public final classroomsServiceClient classrooms() { - return this.classroomsServiceClient.get(); - } + public AuthClient auth() { + return this.authClient.get(); + } - public final statsServiceClient stats() { - return this.statsServiceClient.get(); - } + public ClansClient clans() { + return this.clansClient.get(); + } - public final usersServiceClient users() { - return this.usersServiceClient.get(); - } + public ClassroomsClient classrooms() { + return this.classroomsClient.get(); + } - private static Supplier memoize(Supplier delegate) { - AtomicReference value = new AtomicReference<>(); - return () -> { - T val = value.get(); - if (val == null) { - val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); - } - return val; - } ; - } + public StatsClient stats() { + return this.statsClient.get(); + } + + public UsersClient users() { + return this.usersClient.get(); + } + + public static CodecombatApiClientBuilder builder() { + return new CodecombatApiClientBuilder(); + } } diff --git a/src/main/java/com/codecombat/api/CodecombatApiClientBuilder.java b/src/main/java/com/codecombat/api/CodecombatApiClientBuilder.java new file mode 100644 index 0000000..6fb285c --- /dev/null +++ b/src/main/java/com/codecombat/api/CodecombatApiClientBuilder.java @@ -0,0 +1,33 @@ +package com.codecombat.api; + +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.Environment; +import java.util.Base64; + +public final class CodecombatApiClientBuilder { + private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); + + private Environment environment = Environment.DEFAULT; + + public CodecombatApiClientBuilder credentials(String username, String password) { + String unencodedToken = username + ":" + password; + String encodedToken = Base64.getEncoder().encodeToString(unencodedToken.getBytes()); + this.clientOptionsBuilder.addHeader("Authorization", "Basic " + encodedToken); + return this; + } + + public CodecombatApiClientBuilder environment(Environment environment) { + this.environment = environment; + return this; + } + + public CodecombatApiClientBuilder url(String url) { + this.environment = Environment.custom(url); + return this; + } + + public CodecombatApiClient build() { + clientOptionsBuilder.environment(this.environment); + return new CodecombatApiClient(clientOptionsBuilder.build()); + } +} diff --git a/src/main/java/com/codecombat/api/client/auth/authService.java b/src/main/java/com/codecombat/api/client/auth/authService.java deleted file mode 100644 index 406a27e..0000000 --- a/src/main/java/com/codecombat/api/client/auth/authService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.codecombat.api.client.auth; - -import com.codecombat.api.client.auth.exceptions.GetException; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.ObjectMappers; -import com.fern.java.jersey.contracts.OptionalAwareContract; -import feign.Feign; -import feign.jackson.JacksonDecoder; -import feign.jackson.JacksonEncoder; -import feign.jaxrs.JAXRSContract; -import java.lang.String; -import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/auth/login-o-auth") -interface authService { - @GET - @Path("") - void get(@HeaderParam("Authorization") BasicAuth auth, @QueryParam("provider") String provider, - @QueryParam("accessToken") Optional accessToken, - @QueryParam("code") Optional code, @QueryParam("redirect") Optional redirect, - @QueryParam("errorRedirect") Optional errorRedirect) throws GetException; - - static authService getClient(String url) { - return Feign.builder() - .contract(new OptionalAwareContract(new JAXRSContract())) - .decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER)) - .encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER)) - .errorDecoder(new authServiceErrorDecoder()).target(authService.class, url); - } -} diff --git a/src/main/java/com/codecombat/api/client/auth/authServiceClient.java b/src/main/java/com/codecombat/api/client/auth/authServiceClient.java deleted file mode 100644 index d0e6813..0000000 --- a/src/main/java/com/codecombat/api/client/auth/authServiceClient.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.codecombat.api.client.auth; - -import com.codecombat.api.client.auth.endpoints.Get; -import com.codecombat.api.client.auth.exceptions.GetException; -import com.codecombat.api.core.BasicAuth; -import java.lang.RuntimeException; -import java.lang.String; -import java.util.Optional; - -public final class authServiceClient { - private final authService service; - - private final Optional auth; - - public authServiceClient(String url) { - this.service = authService.getClient(url); - this.auth = Optional.empty(); - } - - public authServiceClient(String url, BasicAuth auth) { - this.service = authService.getClient(url); - this.auth = Optional.of(auth); - } - - /** - *

Logs a user in. #### Example javascript url = `https://codecombat.com/auth/login-o-auth?provider=${OAUTH_PROVIDER_ID}&accessToken=1234` res.redirect(url) // User is sent to this CodeCombat URL and assuming everything checks out, // is logged in and redirected to the home page. In this example, we call your lookup URL (let's say, https://oauth.provider/user?t=<%= accessToken %>) with the access token (1234). The lookup URL returns { id: 'abcd' } in this case. We will match this id with the OAuthIdentity stored in the user information in our db. If everything checks out, the user is logged in and redirected to the home page.

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetException Exception that wraps all possible endpoint errors - */ - public void get(Get.Request request) throws GetException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - this.service.get(authValue, request.getProvider(), request.getAccessToken(), request.getCode(), request.getRedirect(), request.getErrorRedirect()); - } -} diff --git a/src/main/java/com/codecombat/api/client/auth/authServiceErrorDecoder.java b/src/main/java/com/codecombat/api/client/auth/authServiceErrorDecoder.java deleted file mode 100644 index dc7070e..0000000 --- a/src/main/java/com/codecombat/api/client/auth/authServiceErrorDecoder.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.codecombat.api.client.auth; - -import com.codecombat.api.client.auth.exceptions.GetException; -import com.codecombat.api.core.ObjectMappers; -import feign.Response; -import feign.codec.ErrorDecoder; -import java.io.IOException; -import java.lang.Class; -import java.lang.Exception; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; - -final class authServiceErrorDecoder implements ErrorDecoder { - @Override - public Exception decode(String methodKey, Response response) { - try { - if (methodKey.contains("get")) { - return decodeException(response, GetException.class); - } - } - catch (IOException e) { - } - return new RuntimeException("Failed to read response body. Received status " + response.status() + " for method " + methodKey); - } - - private static Exception decodeException(Response response, Class clazz) - throws IOException { - return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz); - } -} diff --git a/src/main/java/com/codecombat/api/client/auth/endpoints/Get.java b/src/main/java/com/codecombat/api/client/auth/endpoints/Get.java deleted file mode 100644 index 4fe0c1e..0000000 --- a/src/main/java/com/codecombat/api/client/auth/endpoints/Get.java +++ /dev/null @@ -1,255 +0,0 @@ -package com.codecombat.api.client.auth.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Get { - private Get() { - } - - public static final class Request { - private final String provider; - - private final Optional accessToken; - - private final Optional code; - - private final Optional redirect; - - private final Optional errorRedirect; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String provider, Optional accessToken, Optional code, - Optional redirect, Optional errorRedirect, - Optional authOverride) { - this.provider = provider; - this.accessToken = accessToken; - this.code = code; - this.redirect = redirect; - this.errorRedirect = errorRedirect; - this.authOverride = authOverride; - } - - /** - * @return Your OAuth Provider ID - */ - public String getProvider() { - return provider; - } - - /** - * @return Will be passed through your lookup URL to get the user ID. Required if no code. - */ - public Optional getAccessToken() { - return accessToken; - } - - /** - * @return Will be passed to the OAuth token endpoint to get a token. Required if no accessToken. - */ - public Optional getCode() { - return code; - } - - /** - * @return Override where the user will navigate to after successfully logging in. - */ - public Optional getRedirect() { - return redirect; - } - - /** - * @return If an error happens, redirects the user to this url, with at least query parameters code, errorName and message. - */ - public Optional getErrorRedirect() { - return errorRedirect; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return provider.equals(other.provider) && accessToken.equals(other.accessToken) && code.equals(other.code) && redirect.equals(other.redirect) && errorRedirect.equals(other.errorRedirect) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.provider, this.accessToken, this.code, this.redirect, this.errorRedirect, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Get.Request{" + "provider: " + provider + ", accessToken: " + accessToken + ", code: " + code + ", redirect: " + redirect + ", errorRedirect: " + errorRedirect + ", authOverride: " + authOverride + "}"; - } - - public static ProviderStage builder() { - return new Builder(); - } - - public interface ProviderStage { - _FinalStage provider(String provider); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage accessToken(Optional accessToken); - - _FinalStage accessToken(String accessToken); - - _FinalStage code(Optional code); - - _FinalStage code(String code); - - _FinalStage redirect(Optional redirect); - - _FinalStage redirect(String redirect); - - _FinalStage errorRedirect(Optional errorRedirect); - - _FinalStage errorRedirect(String errorRedirect); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements ProviderStage, _FinalStage { - private String provider; - - private Optional authOverride = Optional.empty(); - - private Optional errorRedirect = Optional.empty(); - - private Optional redirect = Optional.empty(); - - private Optional code = Optional.empty(); - - private Optional accessToken = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - provider(other.getProvider()); - accessToken(other.getAccessToken()); - code(other.getCode()); - redirect(other.getRedirect()); - errorRedirect(other.getErrorRedirect()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

Your OAuth Provider ID

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage provider(String provider) { - this.provider = provider; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

If an error happens, redirects the user to this url, with at least query parameters code, errorName and message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage errorRedirect(String errorRedirect) { - this.errorRedirect = Optional.of(errorRedirect); - return this; - } - - @Override - public _FinalStage errorRedirect(Optional errorRedirect) { - this.errorRedirect = errorRedirect; - return this; - } - - /** - *

Override where the user will navigate to after successfully logging in.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage redirect(String redirect) { - this.redirect = Optional.of(redirect); - return this; - } - - @Override - public _FinalStage redirect(Optional redirect) { - this.redirect = redirect; - return this; - } - - /** - *

Will be passed to the OAuth token endpoint to get a token. Required if no accessToken.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage code(String code) { - this.code = Optional.of(code); - return this; - } - - @Override - public _FinalStage code(Optional code) { - this.code = code; - return this; - } - - /** - *

Will be passed through your lookup URL to get the user ID. Required if no code.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage accessToken(String accessToken) { - this.accessToken = Optional.of(accessToken); - return this; - } - - @Override - public _FinalStage accessToken(Optional accessToken) { - this.accessToken = accessToken; - return this; - } - - @Override - public Request build() { - return new Request(provider, accessToken, code, redirect, errorRedirect, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/auth/exceptions/GetException.java b/src/main/java/com/codecombat/api/client/auth/exceptions/GetException.java deleted file mode 100644 index 4a389d0..0000000 --- a/src/main/java/com/codecombat/api/client/auth/exceptions/GetException.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.codecombat.api.client.auth.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetException.Deserializer.class -) -public final class GetException extends Exception { - private final Value value; - - private int statusCode; - - private GetException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetException other(Object unknownValue, int statusCode) { - return new GetException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetException deserialize(JsonParser p, DeserializationContext ctx) throws IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/clansService.java b/src/main/java/com/codecombat/api/client/clans/clansService.java deleted file mode 100644 index 101add9..0000000 --- a/src/main/java/com/codecombat/api/client/clans/clansService.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.codecombat.api.client.clans; - -import com.codecombat.api.client.clans.exceptions.UpsertClanException; -import com.codecombat.api.client.clans.types.ClanResponse; -import com.codecombat.api.client.clans.types.UpsertClanRequest; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.ObjectMappers; -import com.fern.java.jersey.contracts.OptionalAwareContract; -import feign.Feign; -import feign.jackson.JacksonDecoder; -import feign.jackson.JacksonEncoder; -import feign.jaxrs.JAXRSContract; -import java.lang.String; -import javax.ws.rs.Consumes; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/clan/{handle}/members") -interface clansService { - @PUT - @Path("") - ClanResponse upsertClan(@HeaderParam("Authorization") BasicAuth auth, UpsertClanRequest body) - throws UpsertClanException; - - static clansService getClient(String url) { - return Feign.builder() - .contract(new OptionalAwareContract(new JAXRSContract())) - .decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER)) - .encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER)) - .errorDecoder(new clansServiceErrorDecoder()).target(clansService.class, url); - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/clansServiceClient.java b/src/main/java/com/codecombat/api/client/clans/clansServiceClient.java deleted file mode 100644 index 860f62e..0000000 --- a/src/main/java/com/codecombat/api/client/clans/clansServiceClient.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.codecombat.api.client.clans; - -import com.codecombat.api.client.clans.endpoints.UpsertClan; -import com.codecombat.api.client.clans.exceptions.UpsertClanException; -import com.codecombat.api.client.clans.types.ClanResponse; -import com.codecombat.api.core.BasicAuth; -import java.lang.RuntimeException; -import java.lang.String; -import java.util.Optional; - -public final class clansServiceClient { - private final clansService service; - - private final Optional auth; - - public clansServiceClient(String url) { - this.service = clansService.getClient(url); - this.auth = Optional.empty(); - } - - public clansServiceClient(String url, BasicAuth auth) { - this.service = clansService.getClient(url); - this.auth = Optional.of(auth); - } - - /** - *

Upserts a user into the clan.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws UpsertClanException Exception that wraps all possible endpoint errors - * @return ClanResponse - */ - public ClanResponse upsertClan(UpsertClan.Request request) throws UpsertClanException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.upsertClan(authValue, request.getBody()); - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/clansServiceErrorDecoder.java b/src/main/java/com/codecombat/api/client/clans/clansServiceErrorDecoder.java deleted file mode 100644 index 4bd98e3..0000000 --- a/src/main/java/com/codecombat/api/client/clans/clansServiceErrorDecoder.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.codecombat.api.client.clans; - -import com.codecombat.api.client.clans.exceptions.UpsertClanException; -import com.codecombat.api.core.ObjectMappers; -import feign.Response; -import feign.codec.ErrorDecoder; -import java.io.IOException; -import java.lang.Class; -import java.lang.Exception; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; - -final class clansServiceErrorDecoder implements ErrorDecoder { - @Override - public Exception decode(String methodKey, Response response) { - try { - if (methodKey.contains("upsertClan")) { - return decodeException(response, UpsertClanException.class); - } - } - catch (IOException e) { - } - return new RuntimeException("Failed to read response body. Received status " + response.status() + " for method " + methodKey); - } - - private static Exception decodeException(Response response, Class clazz) - throws IOException { - return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz); - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/endpoints/UpsertClan.java b/src/main/java/com/codecombat/api/client/clans/endpoints/UpsertClan.java deleted file mode 100644 index 667d7a8..0000000 --- a/src/main/java/com/codecombat/api/client/clans/endpoints/UpsertClan.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codecombat.api.client.clans.endpoints; - -import com.codecombat.api.client.clans.types.UpsertClanRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class UpsertClan { - private UpsertClan() { - } - - public static final class Request { - private final UpsertClanRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(UpsertClanRequest body, Optional authOverride) { - this.body = body; - this.authOverride = authOverride; - } - - public UpsertClanRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpsertClan.Request{" + "body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static BodyStage builder() { - return new Builder(); - } - - public interface BodyStage { - _FinalStage body(UpsertClanRequest body); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements BodyStage, _FinalStage { - private UpsertClanRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - @Override - public _FinalStage body(UpsertClanRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/exceptions/UpsertClanException.java b/src/main/java/com/codecombat/api/client/clans/exceptions/UpsertClanException.java deleted file mode 100644 index 869bd13..0000000 --- a/src/main/java/com/codecombat/api/client/clans/exceptions/UpsertClanException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.clans.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = UpsertClanException.Deserializer.class -) -public final class UpsertClanException extends Exception { - private final Value value; - - private int statusCode; - - private UpsertClanException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static UpsertClanException other(Object unknownValue, int statusCode) { - return new UpsertClanException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "UpsertClanException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public UpsertClanException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new UpsertClanException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/types/ClanResponse.java b/src/main/java/com/codecombat/api/client/clans/types/ClanResponse.java deleted file mode 100644 index 1146a43..0000000 --- a/src/main/java/com/codecombat/api/client/clans/types/ClanResponse.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.codecombat.api.client.clans.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = ClanResponse.Builder.class -) -public final class ClanResponse { - private final Optional id; - - private final Optional name; - - private final Optional displayName; - - private final Optional> members; - - private final Optional ownerId; - - private final Optional description; - - private final Optional type; - - private final Optional kind; - - private final Optional> metadata; - - private int _cachedHashCode; - - ClanResponse(Optional id, Optional name, Optional displayName, - Optional> members, Optional ownerId, Optional description, - Optional type, Optional kind, Optional> metadata) { - this.id = id; - this.name = name; - this.displayName = displayName; - this.members = members; - this.ownerId = ownerId; - this.description = description; - this.type = type; - this.kind = kind; - this.metadata = metadata; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("name") - public Optional getName() { - return name; - } - - @JsonProperty("displayName") - public Optional getDisplayName() { - return displayName; - } - - @JsonProperty("members") - public Optional> getMembers() { - return members; - } - - @JsonProperty("ownerID") - public Optional getOwnerId() { - return ownerId; - } - - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - @JsonProperty("type") - public Optional getType() { - return type; - } - - @JsonProperty("kind") - public Optional getKind() { - return kind; - } - - @JsonProperty("metadata") - public Optional> getMetadata() { - return metadata; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ClanResponse && equalTo((ClanResponse) other); - } - - private boolean equalTo(ClanResponse other) { - return id.equals(other.id) && name.equals(other.name) && displayName.equals(other.displayName) && members.equals(other.members) && ownerId.equals(other.ownerId) && description.equals(other.description) && type.equals(other.type) && kind.equals(other.kind) && metadata.equals(other.metadata); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.name, this.displayName, this.members, this.ownerId, this.description, this.type, this.kind, this.metadata); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ClanResponse{" + "id: " + id + ", name: " + name + ", displayName: " + displayName + ", members: " + members + ", ownerId: " + ownerId + ", description: " + description + ", type: " + type + ", kind: " + kind + ", metadata: " + metadata + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional displayName = Optional.empty(); - - private Optional> members = Optional.empty(); - - private Optional ownerId = Optional.empty(); - - private Optional description = Optional.empty(); - - private Optional type = Optional.empty(); - - private Optional kind = Optional.empty(); - - private Optional> metadata = Optional.empty(); - - private Builder() { - } - - public Builder from(ClanResponse other) { - id(other.getId()); - name(other.getName()); - displayName(other.getDisplayName()); - members(other.getMembers()); - ownerId(other.getOwnerId()); - description(other.getDescription()); - type(other.getType()); - kind(other.getKind()); - metadata(other.getMetadata()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "name", - nulls = Nulls.SKIP - ) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.of(name); - return this; - } - - @JsonSetter( - value = "displayName", - nulls = Nulls.SKIP - ) - public Builder displayName(Optional displayName) { - this.displayName = displayName; - return this; - } - - public Builder displayName(String displayName) { - this.displayName = Optional.of(displayName); - return this; - } - - @JsonSetter( - value = "members", - nulls = Nulls.SKIP - ) - public Builder members(Optional> members) { - this.members = members; - return this; - } - - public Builder members(List members) { - this.members = Optional.of(members); - return this; - } - - @JsonSetter( - value = "ownerID", - nulls = Nulls.SKIP - ) - public Builder ownerId(Optional ownerId) { - this.ownerId = ownerId; - return this; - } - - public Builder ownerId(String ownerId) { - this.ownerId = Optional.of(ownerId); - return this; - } - - @JsonSetter( - value = "description", - nulls = Nulls.SKIP - ) - public Builder description(Optional description) { - this.description = description; - return this; - } - - public Builder description(String description) { - this.description = Optional.of(description); - return this; - } - - @JsonSetter( - value = "type", - nulls = Nulls.SKIP - ) - public Builder type(Optional type) { - this.type = type; - return this; - } - - public Builder type(String type) { - this.type = Optional.of(type); - return this; - } - - @JsonSetter( - value = "kind", - nulls = Nulls.SKIP - ) - public Builder kind(Optional kind) { - this.kind = kind; - return this; - } - - public Builder kind(String kind) { - this.kind = Optional.of(kind); - return this; - } - - @JsonSetter( - value = "metadata", - nulls = Nulls.SKIP - ) - public Builder metadata(Optional> metadata) { - this.metadata = metadata; - return this; - } - - public Builder metadata(Map metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - public ClanResponse build() { - return new ClanResponse(id, name, displayName, members, ownerId, description, type, kind, metadata); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/clans/types/UpsertClanRequest.java b/src/main/java/com/codecombat/api/client/clans/types/UpsertClanRequest.java deleted file mode 100644 index 5f8efcc..0000000 --- a/src/main/java/com/codecombat/api/client/clans/types/UpsertClanRequest.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.codecombat.api.client.clans.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = UpsertClanRequest.Builder.class -) -public final class UpsertClanRequest { - private final String userId; - - private int _cachedHashCode; - - UpsertClanRequest(String userId) { - this.userId = userId; - } - - /** - * @return The _id or slug of the user to add to the clan. - */ - @JsonProperty("userId") - public String getUserId() { - return userId; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpsertClanRequest && equalTo((UpsertClanRequest) other); - } - - private boolean equalTo(UpsertClanRequest other) { - return userId.equals(other.userId); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.userId); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpsertClanRequest{" + "userId: " + userId + "}"; - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(UpsertClanRequest other); - } - - public interface _FinalStage { - UpsertClanRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - private Builder() { - } - - @Override - public Builder from(UpsertClanRequest other) { - userId(other.getUserId()); - return this; - } - - /** - *

The _id or slug of the user to add to the clan.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("userId") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @Override - public UpsertClanRequest build() { - return new UpsertClanRequest(userId); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/classroomsService.java b/src/main/java/com/codecombat/api/client/classrooms/classroomsService.java deleted file mode 100644 index c89e79b..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/classroomsService.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.codecombat.api.client.classrooms; - -import com.codecombat.api.client.classrooms.exceptions.CreateException; -import com.codecombat.api.client.classrooms.exceptions.DeleteUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.EnrollUserInCourseException; -import com.codecombat.api.client.classrooms.exceptions.GetException; -import com.codecombat.api.client.classrooms.exceptions.GetLevelSessionException; -import com.codecombat.api.client.classrooms.exceptions.GetMembersStatsException; -import com.codecombat.api.client.classrooms.exceptions.RemoveUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.UpsertFromClassroomException; -import com.codecombat.api.client.classrooms.types.CreateClassroomRequest; -import com.codecombat.api.client.classrooms.types.DeleteUserFromClassroomRequest; -import com.codecombat.api.client.classrooms.types.EnrollUserInCourseRequest; -import com.codecombat.api.client.classrooms.types.LevelSessionResponse; -import com.codecombat.api.client.classrooms.types.MemberStat; -import com.codecombat.api.client.classrooms.types.RemoveUserFromClassroomRequest; -import com.codecombat.api.client.classrooms.types.UpsertClassroomRequest; -import com.codecombat.api.client.commons.types.ClassroomResponse; -import com.codecombat.api.client.commons.types.ClassroomResponseWithCode; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.ObjectMappers; -import com.fern.java.jersey.contracts.OptionalAwareContract; -import feign.Feign; -import feign.jackson.JacksonDecoder; -import feign.jackson.JacksonEncoder; -import feign.jaxrs.JAXRSContract; -import java.lang.Double; -import java.lang.String; -import java.util.List; -import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/classrooms") -interface classroomsService { - @GET - @Path("") - ClassroomResponseWithCode get(@HeaderParam("Authorization") BasicAuth auth, - @QueryParam("code") String code, - @QueryParam("retMemberLimit") Optional retMemberLimit) throws GetException; - - @POST - @Path("") - void create(@HeaderParam("Authorization") BasicAuth auth, CreateClassroomRequest body) throws - CreateException; - - @PUT - @Path("/{handle}/members") - ClassroomResponse upsertFromClassroom(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, UpsertClassroomRequest body) throws - UpsertFromClassroomException; - - @DELETE - @Path("/{handle}/members") - ClassroomResponse deleteUserFromClassroom(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, DeleteUserFromClassroomRequest body) throws - DeleteUserFromClassroomException; - - @PUT - @Path("/{classroomHandle}/courses/{courseHandle}/enrolled") - ClassroomResponse enrollUserInCourse(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("classroomHandle") String classroomHandle, - @PathParam("courseHandle") String courseHandle, - @QueryParam("retMemberLimit") Optional retMemberLimit, EnrollUserInCourseRequest body) - throws EnrollUserInCourseException; - - @PUT - @Path("/{classroomHandle}/courses/{courseHandle}/remove-enrolled") - ClassroomResponse removeUserFromClassroom(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("classroomHandle") String classroomHandle, - @PathParam("courseHandle") String courseHandle, - @QueryParam("retMemberLimit") Optional retMemberLimit, - RemoveUserFromClassroomRequest body) throws RemoveUserFromClassroomException; - - @GET - @Path("/{classroomHandle}/stats") - List getMembersStats(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("classroomHandle") String classroomHandle, - @QueryParam("project") Optional project, - @QueryParam("memberLimit") Optional memberLimit, - @QueryParam("memberSkip") Optional memberSkip) throws GetMembersStatsException; - - @GET - @Path("/{classroomHandle}/members/{memberHandle}/sessions") - List getLevelSession(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("classroomHandle") String classroomHandle, - @PathParam("memberHandle") String memberHandle) throws GetLevelSessionException; - - static classroomsService getClient(String url) { - return Feign.builder() - .contract(new OptionalAwareContract(new JAXRSContract())) - .decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER)) - .encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER)) - .errorDecoder(new classroomsServiceErrorDecoder()).target(classroomsService.class, url); - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceClient.java b/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceClient.java deleted file mode 100644 index 8d99314..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceClient.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.codecombat.api.client.classrooms; - -import com.codecombat.api.client.classrooms.endpoints.Create; -import com.codecombat.api.client.classrooms.endpoints.DeleteUserFromClassroom; -import com.codecombat.api.client.classrooms.endpoints.EnrollUserInCourse; -import com.codecombat.api.client.classrooms.endpoints.Get; -import com.codecombat.api.client.classrooms.endpoints.GetLevelSession; -import com.codecombat.api.client.classrooms.endpoints.GetMembersStats; -import com.codecombat.api.client.classrooms.endpoints.RemoveUserFromClassroom; -import com.codecombat.api.client.classrooms.endpoints.UpsertFromClassroom; -import com.codecombat.api.client.classrooms.exceptions.CreateException; -import com.codecombat.api.client.classrooms.exceptions.DeleteUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.EnrollUserInCourseException; -import com.codecombat.api.client.classrooms.exceptions.GetException; -import com.codecombat.api.client.classrooms.exceptions.GetLevelSessionException; -import com.codecombat.api.client.classrooms.exceptions.GetMembersStatsException; -import com.codecombat.api.client.classrooms.exceptions.RemoveUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.UpsertFromClassroomException; -import com.codecombat.api.client.classrooms.types.LevelSessionResponse; -import com.codecombat.api.client.classrooms.types.MemberStat; -import com.codecombat.api.client.commons.types.ClassroomResponse; -import com.codecombat.api.client.commons.types.ClassroomResponseWithCode; -import com.codecombat.api.core.BasicAuth; -import java.lang.RuntimeException; -import java.lang.String; -import java.util.List; -import java.util.Optional; - -public final class classroomsServiceClient { - private final classroomsService service; - - private final Optional auth; - - public classroomsServiceClient(String url) { - this.service = classroomsService.getClient(url); - this.auth = Optional.empty(); - } - - public classroomsServiceClient(String url, BasicAuth auth) { - this.service = classroomsService.getClient(url); - this.auth = Optional.of(auth); - } - - /** - *

Returns the classroom details for a class code.

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetException Exception that wraps all possible endpoint errors - * @return ClassroomResponseWithCode - */ - public ClassroomResponseWithCode get(Get.Request request) throws GetException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.get(authValue, request.getCode(), request.getRetMemberLimit()); - } - - /** - *

Creates a new empty Classroom.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws CreateException Exception that wraps all possible endpoint errors - */ - public void create(Create.Request request) throws CreateException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - this.service.create(authValue, request.getBody()); - } - - /** - *

Upserts a user into the classroom.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws UpsertFromClassroomException Exception that wraps all possible endpoint errors - * @return ClassroomResponse - */ - public ClassroomResponse upsertFromClassroom(UpsertFromClassroom.Request request) throws - UpsertFromClassroomException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.upsertFromClassroom(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Remove a user from the classroom.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws DeleteUserFromClassroomException Exception that wraps all possible endpoint errors - * @return ClassroomResponse - */ - public ClassroomResponse deleteUserFromClassroom(DeleteUserFromClassroom.Request request) throws - DeleteUserFromClassroomException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.deleteUserFromClassroom(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Enrolls a user in a course in a classroom. - * If the course is paid, user must have an active license. - * User must be a member of the classroom.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws EnrollUserInCourseException Exception that wraps all possible endpoint errors - * @return ClassroomResponse - */ - public ClassroomResponse enrollUserInCourse(EnrollUserInCourse.Request request) throws - EnrollUserInCourseException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.enrollUserInCourse(authValue, request.getClassroomHandle(), request.getCourseHandle(), request.getRetMemberLimit(), request.getBody()); - } - - /** - *

Removes an enrolled user from a course in a classroom.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws RemoveUserFromClassroomException Exception that wraps all possible endpoint errors - * @return ClassroomResponse - */ - public ClassroomResponse removeUserFromClassroom(RemoveUserFromClassroom.Request request) throws - RemoveUserFromClassroomException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.removeUserFromClassroom(authValue, request.getClassroomHandle(), request.getCourseHandle(), request.getRetMemberLimit(), request.getBody()); - } - - /** - *

Returns a list of all members stats for the classroom.

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetMembersStatsException Exception that wraps all possible endpoint errors - * @return List - */ - public List getMembersStats(GetMembersStats.Request request) throws - GetMembersStatsException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getMembersStats(authValue, request.getClassroomHandle(), request.getProject(), request.getMemberLimit(), request.getMemberSkip()); - } - - /** - *

Returns a list of all levels played by the user for the classroom.

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetLevelSessionException Exception that wraps all possible endpoint errors - * @return List - */ - public List getLevelSession(GetLevelSession.Request request) throws - GetLevelSessionException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getLevelSession(authValue, request.getClassroomHandle(), request.getMemberHandle()); - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceErrorDecoder.java b/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceErrorDecoder.java deleted file mode 100644 index 7352e0b..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/classroomsServiceErrorDecoder.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.codecombat.api.client.classrooms; - -import com.codecombat.api.client.classrooms.exceptions.CreateException; -import com.codecombat.api.client.classrooms.exceptions.DeleteUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.EnrollUserInCourseException; -import com.codecombat.api.client.classrooms.exceptions.GetException; -import com.codecombat.api.client.classrooms.exceptions.GetLevelSessionException; -import com.codecombat.api.client.classrooms.exceptions.GetMembersStatsException; -import com.codecombat.api.client.classrooms.exceptions.RemoveUserFromClassroomException; -import com.codecombat.api.client.classrooms.exceptions.UpsertFromClassroomException; -import com.codecombat.api.core.ObjectMappers; -import feign.Response; -import feign.codec.ErrorDecoder; -import java.io.IOException; -import java.lang.Class; -import java.lang.Exception; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; - -final class classroomsServiceErrorDecoder implements ErrorDecoder { - @Override - public Exception decode(String methodKey, Response response) { - try { - if (methodKey.contains("get")) { - return decodeException(response, GetException.class); - } - if (methodKey.contains("create")) { - return decodeException(response, CreateException.class); - } - if (methodKey.contains("upsertFromClassroom")) { - return decodeException(response, UpsertFromClassroomException.class); - } - if (methodKey.contains("deleteUserFromClassroom")) { - return decodeException(response, DeleteUserFromClassroomException.class); - } - if (methodKey.contains("enrollUserInCourse")) { - return decodeException(response, EnrollUserInCourseException.class); - } - if (methodKey.contains("removeUserFromClassroom")) { - return decodeException(response, RemoveUserFromClassroomException.class); - } - if (methodKey.contains("getMembersStats")) { - return decodeException(response, GetMembersStatsException.class); - } - if (methodKey.contains("getLevelSession")) { - return decodeException(response, GetLevelSessionException.class); - } - } - catch (IOException e) { - } - return new RuntimeException("Failed to read response body. Received status " + response.status() + " for method " + methodKey); - } - - private static Exception decodeException(Response response, Class clazz) - throws IOException { - return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz); - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/Create.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/Create.java deleted file mode 100644 index fdb3b76..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/Create.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.client.classrooms.types.CreateClassroomRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Create { - private Create() { - } - - public static final class Request { - private final CreateClassroomRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(CreateClassroomRequest body, Optional authOverride) { - this.body = body; - this.authOverride = authOverride; - } - - public CreateClassroomRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Create.Request{" + "body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static BodyStage builder() { - return new Builder(); - } - - public interface BodyStage { - _FinalStage body(CreateClassroomRequest body); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements BodyStage, _FinalStage { - private CreateClassroomRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - @Override - public _FinalStage body(CreateClassroomRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/DeleteUserFromClassroom.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/DeleteUserFromClassroom.java deleted file mode 100644 index 3defefa..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/DeleteUserFromClassroom.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.client.classrooms.types.DeleteUserFromClassroomRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class DeleteUserFromClassroom { - private DeleteUserFromClassroom() { - } - - public static final class Request { - private final String handle; - - private final DeleteUserFromClassroomRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, DeleteUserFromClassroomRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public DeleteUserFromClassroomRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "DeleteUserFromClassroom.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(DeleteUserFromClassroomRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private DeleteUserFromClassroomRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(DeleteUserFromClassroomRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/EnrollUserInCourse.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/EnrollUserInCourse.java deleted file mode 100644 index bec40e3..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/EnrollUserInCourse.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.client.classrooms.types.EnrollUserInCourseRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class EnrollUserInCourse { - private EnrollUserInCourse() { - } - - public static final class Request { - private final String classroomHandle; - - private final String courseHandle; - - private final Optional retMemberLimit; - - private final EnrollUserInCourseRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String classroomHandle, String courseHandle, Optional retMemberLimit, - EnrollUserInCourseRequest body, Optional authOverride) { - this.classroomHandle = classroomHandle; - this.courseHandle = courseHandle; - this.retMemberLimit = retMemberLimit; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The classroom's _id. - */ - public String getClassroomHandle() { - return classroomHandle; - } - - /** - * @return The course's _id. - */ - public String getCourseHandle() { - return courseHandle; - } - - /** - * @return limit the return number of members for the classroom, the default value is 1000 - */ - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - public EnrollUserInCourseRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return classroomHandle.equals(other.classroomHandle) && courseHandle.equals(other.courseHandle) && retMemberLimit.equals(other.retMemberLimit) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.classroomHandle, this.courseHandle, this.retMemberLimit, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "EnrollUserInCourse.Request{" + "classroomHandle: " + classroomHandle + ", courseHandle: " + courseHandle + ", retMemberLimit: " + retMemberLimit + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static ClassroomHandleStage builder() { - return new Builder(); - } - - public interface ClassroomHandleStage { - CourseHandleStage classroomHandle(String classroomHandle); - - Builder from(Request other); - } - - public interface CourseHandleStage { - BodyStage courseHandle(String courseHandle); - } - - public interface BodyStage { - _FinalStage body(EnrollUserInCourseRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements ClassroomHandleStage, CourseHandleStage, BodyStage, _FinalStage { - private String classroomHandle; - - private String courseHandle; - - private EnrollUserInCourseRequest body; - - private Optional authOverride = Optional.empty(); - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - classroomHandle(other.getClassroomHandle()); - courseHandle(other.getCourseHandle()); - retMemberLimit(other.getRetMemberLimit()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The classroom's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public CourseHandleStage classroomHandle(String classroomHandle) { - this.classroomHandle = classroomHandle; - return this; - } - - /** - *

The course's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage courseHandle(String courseHandle) { - this.courseHandle = courseHandle; - return this; - } - - @Override - public _FinalStage body(EnrollUserInCourseRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

limit the return number of members for the classroom, the default value is 1000

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public Request build() { - return new Request(classroomHandle, courseHandle, retMemberLimit, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/Get.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/Get.java deleted file mode 100644 index 99e3fd1..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/Get.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Get { - private Get() { - } - - public static final class Request { - private final String code; - - private final Optional retMemberLimit; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String code, Optional retMemberLimit, Optional authOverride) { - this.code = code; - this.retMemberLimit = retMemberLimit; - this.authOverride = authOverride; - } - - /** - * @return The classroom's code. - */ - public String getCode() { - return code; - } - - /** - * @return limit the return number of members for the classroom - */ - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return code.equals(other.code) && retMemberLimit.equals(other.retMemberLimit) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.code, this.retMemberLimit, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Get.Request{" + "code: " + code + ", retMemberLimit: " + retMemberLimit + ", authOverride: " + authOverride + "}"; - } - - public static CodeStage builder() { - return new Builder(); - } - - public interface CodeStage { - _FinalStage code(String code); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements CodeStage, _FinalStage { - private String code; - - private Optional authOverride = Optional.empty(); - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - code(other.getCode()); - retMemberLimit(other.getRetMemberLimit()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The classroom's code.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage code(String code) { - this.code = code; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

limit the return number of members for the classroom

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public Request build() { - return new Request(code, retMemberLimit, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetLevelSession.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetLevelSession.java deleted file mode 100644 index 005862d..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetLevelSession.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetLevelSession { - private GetLevelSession() { - } - - public static final class Request { - private final String classroomHandle; - - private final String memberHandle; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String classroomHandle, String memberHandle, Optional authOverride) { - this.classroomHandle = classroomHandle; - this.memberHandle = memberHandle; - this.authOverride = authOverride; - } - - /** - * @return The classroom's _id. - */ - public String getClassroomHandle() { - return classroomHandle; - } - - /** - * @return The classroom member's _id. - */ - public String getMemberHandle() { - return memberHandle; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return classroomHandle.equals(other.classroomHandle) && memberHandle.equals(other.memberHandle) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.classroomHandle, this.memberHandle, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetLevelSession.Request{" + "classroomHandle: " + classroomHandle + ", memberHandle: " + memberHandle + ", authOverride: " + authOverride + "}"; - } - - public static ClassroomHandleStage builder() { - return new Builder(); - } - - public interface ClassroomHandleStage { - MemberHandleStage classroomHandle(String classroomHandle); - - Builder from(Request other); - } - - public interface MemberHandleStage { - _FinalStage memberHandle(String memberHandle); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements ClassroomHandleStage, MemberHandleStage, _FinalStage { - private String classroomHandle; - - private String memberHandle; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - classroomHandle(other.getClassroomHandle()); - memberHandle(other.getMemberHandle()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The classroom's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public MemberHandleStage classroomHandle(String classroomHandle) { - this.classroomHandle = classroomHandle; - return this; - } - - /** - *

The classroom member's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage memberHandle(String memberHandle) { - this.memberHandle = memberHandle; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(classroomHandle, memberHandle, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetMembersStats.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetMembersStats.java deleted file mode 100644 index 0de2485..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/GetMembersStats.java +++ /dev/null @@ -1,222 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetMembersStats { - private GetMembersStats() { - } - - public static final class Request { - private final String classroomHandle; - - private final Optional project; - - private final Optional memberLimit; - - private final Optional memberSkip; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String classroomHandle, Optional project, Optional memberLimit, - Optional memberSkip, Optional authOverride) { - this.classroomHandle = classroomHandle; - this.project = project; - this.memberLimit = memberLimit; - this.memberSkip = memberSkip; - this.authOverride = authOverride; - } - - /** - * @return The classroom's _id. - */ - public String getClassroomHandle() { - return classroomHandle; - } - - /** - * @return If specified, include only the specified projection of returned stats; else, return all stats. Format as a comma-separated list, like creator,playtime,state.complete. - */ - public Optional getProject() { - return project; - } - - /** - * @return Limit the return member number. the default value is 10, and the max value is 100 - */ - public Optional getMemberLimit() { - return memberLimit; - } - - /** - * @return Skip the members that doesn't need to return, for pagination - */ - public Optional getMemberSkip() { - return memberSkip; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return classroomHandle.equals(other.classroomHandle) && project.equals(other.project) && memberLimit.equals(other.memberLimit) && memberSkip.equals(other.memberSkip) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.classroomHandle, this.project, this.memberLimit, this.memberSkip, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetMembersStats.Request{" + "classroomHandle: " + classroomHandle + ", project: " + project + ", memberLimit: " + memberLimit + ", memberSkip: " + memberSkip + ", authOverride: " + authOverride + "}"; - } - - public static ClassroomHandleStage builder() { - return new Builder(); - } - - public interface ClassroomHandleStage { - _FinalStage classroomHandle(String classroomHandle); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage project(Optional project); - - _FinalStage project(String project); - - _FinalStage memberLimit(Optional memberLimit); - - _FinalStage memberLimit(Double memberLimit); - - _FinalStage memberSkip(Optional memberSkip); - - _FinalStage memberSkip(Double memberSkip); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements ClassroomHandleStage, _FinalStage { - private String classroomHandle; - - private Optional authOverride = Optional.empty(); - - private Optional memberSkip = Optional.empty(); - - private Optional memberLimit = Optional.empty(); - - private Optional project = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - classroomHandle(other.getClassroomHandle()); - project(other.getProject()); - memberLimit(other.getMemberLimit()); - memberSkip(other.getMemberSkip()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The classroom's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage classroomHandle(String classroomHandle) { - this.classroomHandle = classroomHandle; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

Skip the members that doesn't need to return, for pagination

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage memberSkip(Double memberSkip) { - this.memberSkip = Optional.of(memberSkip); - return this; - } - - @Override - public _FinalStage memberSkip(Optional memberSkip) { - this.memberSkip = memberSkip; - return this; - } - - /** - *

Limit the return member number. the default value is 10, and the max value is 100

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage memberLimit(Double memberLimit) { - this.memberLimit = Optional.of(memberLimit); - return this; - } - - @Override - public _FinalStage memberLimit(Optional memberLimit) { - this.memberLimit = memberLimit; - return this; - } - - /** - *

If specified, include only the specified projection of returned stats; else, return all stats. Format as a comma-separated list, like creator,playtime,state.complete.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage project(String project) { - this.project = Optional.of(project); - return this; - } - - @Override - public _FinalStage project(Optional project) { - this.project = project; - return this; - } - - @Override - public Request build() { - return new Request(classroomHandle, project, memberLimit, memberSkip, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/RemoveUserFromClassroom.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/RemoveUserFromClassroom.java deleted file mode 100644 index db3de66..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/RemoveUserFromClassroom.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.client.classrooms.types.RemoveUserFromClassroomRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class RemoveUserFromClassroom { - private RemoveUserFromClassroom() { - } - - public static final class Request { - private final String classroomHandle; - - private final String courseHandle; - - private final Optional retMemberLimit; - - private final RemoveUserFromClassroomRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String classroomHandle, String courseHandle, Optional retMemberLimit, - RemoveUserFromClassroomRequest body, Optional authOverride) { - this.classroomHandle = classroomHandle; - this.courseHandle = courseHandle; - this.retMemberLimit = retMemberLimit; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The classroom's _id. - */ - public String getClassroomHandle() { - return classroomHandle; - } - - /** - * @return The course's _id. - */ - public String getCourseHandle() { - return courseHandle; - } - - /** - * @return limit the return number of members for the classroom, the default value is 1000 - */ - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - public RemoveUserFromClassroomRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return classroomHandle.equals(other.classroomHandle) && courseHandle.equals(other.courseHandle) && retMemberLimit.equals(other.retMemberLimit) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.classroomHandle, this.courseHandle, this.retMemberLimit, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "RemoveUserFromClassroom.Request{" + "classroomHandle: " + classroomHandle + ", courseHandle: " + courseHandle + ", retMemberLimit: " + retMemberLimit + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static ClassroomHandleStage builder() { - return new Builder(); - } - - public interface ClassroomHandleStage { - CourseHandleStage classroomHandle(String classroomHandle); - - Builder from(Request other); - } - - public interface CourseHandleStage { - BodyStage courseHandle(String courseHandle); - } - - public interface BodyStage { - _FinalStage body(RemoveUserFromClassroomRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements ClassroomHandleStage, CourseHandleStage, BodyStage, _FinalStage { - private String classroomHandle; - - private String courseHandle; - - private RemoveUserFromClassroomRequest body; - - private Optional authOverride = Optional.empty(); - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - classroomHandle(other.getClassroomHandle()); - courseHandle(other.getCourseHandle()); - retMemberLimit(other.getRetMemberLimit()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The classroom's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public CourseHandleStage classroomHandle(String classroomHandle) { - this.classroomHandle = classroomHandle; - return this; - } - - /** - *

The course's _id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage courseHandle(String courseHandle) { - this.courseHandle = courseHandle; - return this; - } - - @Override - public _FinalStage body(RemoveUserFromClassroomRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

limit the return number of members for the classroom, the default value is 1000

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public Request build() { - return new Request(classroomHandle, courseHandle, retMemberLimit, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/endpoints/UpsertFromClassroom.java b/src/main/java/com/codecombat/api/client/classrooms/endpoints/UpsertFromClassroom.java deleted file mode 100644 index 5fb093e..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/endpoints/UpsertFromClassroom.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.classrooms.endpoints; - -import com.codecombat.api.client.classrooms.types.UpsertClassroomRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class UpsertFromClassroom { - private UpsertFromClassroom() { - } - - public static final class Request { - private final String handle; - - private final UpsertClassroomRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, UpsertClassroomRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public UpsertClassroomRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpsertFromClassroom.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(UpsertClassroomRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private UpsertClassroomRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(UpsertClassroomRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/CreateException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/CreateException.java deleted file mode 100644 index 32f2491..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/CreateException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = CreateException.Deserializer.class -) -public final class CreateException extends Exception { - private final Value value; - - private int statusCode; - - private CreateException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static CreateException other(Object unknownValue, int statusCode) { - return new CreateException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "CreateException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public CreateException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new CreateException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/DeleteUserFromClassroomException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/DeleteUserFromClassroomException.java deleted file mode 100644 index 14064aa..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/DeleteUserFromClassroomException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = DeleteUserFromClassroomException.Deserializer.class -) -public final class DeleteUserFromClassroomException extends Exception { - private final Value value; - - private int statusCode; - - private DeleteUserFromClassroomException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static DeleteUserFromClassroomException other(Object unknownValue, int statusCode) { - return new DeleteUserFromClassroomException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "DeleteUserFromClassroomException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public DeleteUserFromClassroomException deserialize(JsonParser p, DeserializationContext ctx) - throws IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new DeleteUserFromClassroomException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/EnrollUserInCourseException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/EnrollUserInCourseException.java deleted file mode 100644 index 5a1179b..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/EnrollUserInCourseException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = EnrollUserInCourseException.Deserializer.class -) -public final class EnrollUserInCourseException extends Exception { - private final Value value; - - private int statusCode; - - private EnrollUserInCourseException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static EnrollUserInCourseException other(Object unknownValue, int statusCode) { - return new EnrollUserInCourseException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "EnrollUserInCourseException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public EnrollUserInCourseException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new EnrollUserInCourseException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetException.java deleted file mode 100644 index d10160b..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetException.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetException.Deserializer.class -) -public final class GetException extends Exception { - private final Value value; - - private int statusCode; - - private GetException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetException other(Object unknownValue, int statusCode) { - return new GetException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetException deserialize(JsonParser p, DeserializationContext ctx) throws IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetLevelSessionException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetLevelSessionException.java deleted file mode 100644 index 0853010..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetLevelSessionException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetLevelSessionException.Deserializer.class -) -public final class GetLevelSessionException extends Exception { - private final Value value; - - private int statusCode; - - private GetLevelSessionException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetLevelSessionException other(Object unknownValue, int statusCode) { - return new GetLevelSessionException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetLevelSessionException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetLevelSessionException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetLevelSessionException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetMembersStatsException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetMembersStatsException.java deleted file mode 100644 index b72210a..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/GetMembersStatsException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetMembersStatsException.Deserializer.class -) -public final class GetMembersStatsException extends Exception { - private final Value value; - - private int statusCode; - - private GetMembersStatsException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetMembersStatsException other(Object unknownValue, int statusCode) { - return new GetMembersStatsException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetMembersStatsException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetMembersStatsException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetMembersStatsException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/RemoveUserFromClassroomException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/RemoveUserFromClassroomException.java deleted file mode 100644 index 302c7dd..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/RemoveUserFromClassroomException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = RemoveUserFromClassroomException.Deserializer.class -) -public final class RemoveUserFromClassroomException extends Exception { - private final Value value; - - private int statusCode; - - private RemoveUserFromClassroomException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static RemoveUserFromClassroomException other(Object unknownValue, int statusCode) { - return new RemoveUserFromClassroomException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "RemoveUserFromClassroomException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public RemoveUserFromClassroomException deserialize(JsonParser p, DeserializationContext ctx) - throws IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new RemoveUserFromClassroomException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/exceptions/UpsertFromClassroomException.java b/src/main/java/com/codecombat/api/client/classrooms/exceptions/UpsertFromClassroomException.java deleted file mode 100644 index a5a71f0..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/exceptions/UpsertFromClassroomException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.classrooms.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = UpsertFromClassroomException.Deserializer.class -) -public final class UpsertFromClassroomException extends Exception { - private final Value value; - - private int statusCode; - - private UpsertFromClassroomException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static UpsertFromClassroomException other(Object unknownValue, int statusCode) { - return new UpsertFromClassroomException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "UpsertFromClassroomException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public UpsertFromClassroomException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new UpsertFromClassroomException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/AceConfig.java b/src/main/java/com/codecombat/api/client/classrooms/types/AceConfig.java deleted file mode 100644 index 62a4b16..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/AceConfig.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = AceConfig.Builder.class -) -public final class AceConfig { - private final Optional language; - - private int _cachedHashCode; - - AceConfig(Optional language) { - this.language = language; - } - - /** - * @return Programming language for the classroom - */ - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AceConfig && equalTo((AceConfig) other); - } - - private boolean equalTo(AceConfig other) { - return language.equals(other.language); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.language); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "AceConfig{" + "language: " + language + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional language = Optional.empty(); - - private Builder() { - } - - public Builder from(AceConfig other) { - language(other.getLanguage()); - return this; - } - - @JsonSetter( - value = "language", - nulls = Nulls.SKIP - ) - public Builder language(Optional language) { - this.language = language; - return this; - } - - public Builder language(String language) { - this.language = Optional.of(language); - return this; - } - - public AceConfig build() { - return new AceConfig(language); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/CreateClassroomRequest.java b/src/main/java/com/codecombat/api/client/classrooms/types/CreateClassroomRequest.java deleted file mode 100644 index 46ff29b..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/CreateClassroomRequest.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = CreateClassroomRequest.Builder.class -) -public final class CreateClassroomRequest { - private final String name; - - private final String ownerId; - - private final AceConfig aceConfig; - - private int _cachedHashCode; - - CreateClassroomRequest(String name, String ownerId, AceConfig aceConfig) { - this.name = name; - this.ownerId = ownerId; - this.aceConfig = aceConfig; - } - - /** - * @return Name of the classroom - */ - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("ownerID") - public String getOwnerId() { - return ownerId; - } - - @JsonProperty("aceConfig") - public AceConfig getAceConfig() { - return aceConfig; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreateClassroomRequest && equalTo((CreateClassroomRequest) other); - } - - private boolean equalTo(CreateClassroomRequest other) { - return name.equals(other.name) && ownerId.equals(other.ownerId) && aceConfig.equals(other.aceConfig); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.name, this.ownerId, this.aceConfig); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "CreateClassroomRequest{" + "name: " + name + ", ownerId: " + ownerId + ", aceConfig: " + aceConfig + "}"; - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - OwnerIdStage name(String name); - - Builder from(CreateClassroomRequest other); - } - - public interface OwnerIdStage { - AceConfigStage ownerId(String ownerId); - } - - public interface AceConfigStage { - _FinalStage aceConfig(AceConfig aceConfig); - } - - public interface _FinalStage { - CreateClassroomRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements NameStage, OwnerIdStage, AceConfigStage, _FinalStage { - private String name; - - private String ownerId; - - private AceConfig aceConfig; - - private Builder() { - } - - @Override - public Builder from(CreateClassroomRequest other) { - name(other.getName()); - ownerId(other.getOwnerId()); - aceConfig(other.getAceConfig()); - return this; - } - - /** - *

Name of the classroom

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("name") - public OwnerIdStage name(String name) { - this.name = name; - return this; - } - - @Override - @JsonSetter("ownerID") - public AceConfigStage ownerId(String ownerId) { - this.ownerId = ownerId; - return this; - } - - @Override - @JsonSetter("aceConfig") - public _FinalStage aceConfig(AceConfig aceConfig) { - this.aceConfig = aceConfig; - return this; - } - - @Override - public CreateClassroomRequest build() { - return new CreateClassroomRequest(name, ownerId, aceConfig); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/DeleteUserFromClassroomRequest.java b/src/main/java/com/codecombat/api/client/classrooms/types/DeleteUserFromClassroomRequest.java deleted file mode 100644 index 38cb409..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/DeleteUserFromClassroomRequest.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = DeleteUserFromClassroomRequest.Builder.class -) -public final class DeleteUserFromClassroomRequest { - private final String userId; - - private final Optional retMemberLimit; - - private int _cachedHashCode; - - DeleteUserFromClassroomRequest(String userId, Optional retMemberLimit) { - this.userId = userId; - this.retMemberLimit = retMemberLimit; - } - - /** - * @return The _id or slug of the user to remove from the class. - */ - @JsonProperty("userId") - public String getUserId() { - return userId; - } - - /** - * @return limit the return number of members for the classroom, the default value is 1000 - */ - @JsonProperty("retMemberLimit") - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeleteUserFromClassroomRequest && equalTo((DeleteUserFromClassroomRequest) other); - } - - private boolean equalTo(DeleteUserFromClassroomRequest other) { - return userId.equals(other.userId) && retMemberLimit.equals(other.retMemberLimit); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.userId, this.retMemberLimit); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "DeleteUserFromClassroomRequest{" + "userId: " + userId + ", retMemberLimit: " + retMemberLimit + "}"; - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(DeleteUserFromClassroomRequest other); - } - - public interface _FinalStage { - DeleteUserFromClassroomRequest build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(DeleteUserFromClassroomRequest other) { - userId(other.getUserId()); - retMemberLimit(other.getRetMemberLimit()); - return this; - } - - /** - *

The _id or slug of the user to remove from the class.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("userId") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - /** - *

limit the return number of members for the classroom, the default value is 1000

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - @JsonSetter( - value = "retMemberLimit", - nulls = Nulls.SKIP - ) - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public DeleteUserFromClassroomRequest build() { - return new DeleteUserFromClassroomRequest(userId, retMemberLimit); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/EnrollUserInCourseRequest.java b/src/main/java/com/codecombat/api/client/classrooms/types/EnrollUserInCourseRequest.java deleted file mode 100644 index 2b7511c..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/EnrollUserInCourseRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = EnrollUserInCourseRequest.Builder.class -) -public final class EnrollUserInCourseRequest { - private final String userId; - - private int _cachedHashCode; - - EnrollUserInCourseRequest(String userId) { - this.userId = userId; - } - - @JsonProperty("userId") - public String getUserId() { - return userId; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EnrollUserInCourseRequest && equalTo((EnrollUserInCourseRequest) other); - } - - private boolean equalTo(EnrollUserInCourseRequest other) { - return userId.equals(other.userId); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.userId); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "EnrollUserInCourseRequest{" + "userId: " + userId + "}"; - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(EnrollUserInCourseRequest other); - } - - public interface _FinalStage { - EnrollUserInCourseRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - private Builder() { - } - - @Override - public Builder from(EnrollUserInCourseRequest other) { - userId(other.getUserId()); - return this; - } - - @Override - @JsonSetter("userId") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @Override - public EnrollUserInCourseRequest build() { - return new EnrollUserInCourseRequest(userId); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/Level.java b/src/main/java/com/codecombat/api/client/classrooms/types/Level.java deleted file mode 100644 index 29b4276..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/Level.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = Level.Builder.class -) -public final class Level { - private final Optional original; - - private int _cachedHashCode; - - Level(Optional original) { - this.original = original; - } - - /** - * @return The id for the level. - */ - @JsonProperty("original") - public Optional getOriginal() { - return original; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Level && equalTo((Level) other); - } - - private boolean equalTo(Level other) { - return original.equals(other.original); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.original); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Level{" + "original: " + original + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional original = Optional.empty(); - - private Builder() { - } - - public Builder from(Level other) { - original(other.getOriginal()); - return this; - } - - @JsonSetter( - value = "original", - nulls = Nulls.SKIP - ) - public Builder original(Optional original) { - this.original = original; - return this; - } - - public Builder original(String original) { - this.original = Optional.of(original); - return this; - } - - public Level build() { - return new Level(original); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/LevelSessionResponse.java b/src/main/java/com/codecombat/api/client/classrooms/types/LevelSessionResponse.java deleted file mode 100644 index 5303deb..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/LevelSessionResponse.java +++ /dev/null @@ -1,332 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Boolean; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = LevelSessionResponse.Builder.class -) -public final class LevelSessionResponse { - private final Optional state; - - private final Optional level; - - private final Optional levelId; - - private final Optional creator; - - private final Optional playtime; - - private final Optional changed; - - private final Optional created; - - private final Optional dateFirstCompleted; - - private final Optional submitted; - - private final Optional published; - - private int _cachedHashCode; - - LevelSessionResponse(Optional state, Optional level, Optional levelId, - Optional creator, Optional playtime, Optional changed, - Optional created, Optional dateFirstCompleted, Optional submitted, - Optional published) { - this.state = state; - this.level = level; - this.levelId = levelId; - this.creator = creator; - this.playtime = playtime; - this.changed = changed; - this.created = created; - this.dateFirstCompleted = dateFirstCompleted; - this.submitted = submitted; - this.published = published; - } - - @JsonProperty("state") - public Optional getState() { - return state; - } - - @JsonProperty("level") - public Optional getLevel() { - return level; - } - - /** - * @return Level slug like wakka-maul - */ - @JsonProperty("levelID") - public Optional getLevelId() { - return levelId; - } - - @JsonProperty("creator") - public Optional getCreator() { - return creator; - } - - /** - * @return Time played in seconds. - */ - @JsonProperty("playtime") - public Optional getPlaytime() { - return playtime; - } - - @JsonProperty("changed") - public Optional getChanged() { - return changed; - } - - @JsonProperty("created") - public Optional getCreated() { - return created; - } - - @JsonProperty("dateFirstCompleted") - public Optional getDateFirstCompleted() { - return dateFirstCompleted; - } - - /** - * @return For arenas. Whether or not the level has been added to the ladder. - */ - @JsonProperty("submitted") - public Optional getSubmitted() { - return submitted; - } - - /** - * @return For shareable projects. Whether or not the project has been shared with classmates. - */ - @JsonProperty("published") - public Optional getPublished() { - return published; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof LevelSessionResponse && equalTo((LevelSessionResponse) other); - } - - private boolean equalTo(LevelSessionResponse other) { - return state.equals(other.state) && level.equals(other.level) && levelId.equals(other.levelId) && creator.equals(other.creator) && playtime.equals(other.playtime) && changed.equals(other.changed) && created.equals(other.created) && dateFirstCompleted.equals(other.dateFirstCompleted) && submitted.equals(other.submitted) && published.equals(other.published); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.state, this.level, this.levelId, this.creator, this.playtime, this.changed, this.created, this.dateFirstCompleted, this.submitted, this.published); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "LevelSessionResponse{" + "state: " + state + ", level: " + level + ", levelId: " + levelId + ", creator: " + creator + ", playtime: " + playtime + ", changed: " + changed + ", created: " + created + ", dateFirstCompleted: " + dateFirstCompleted + ", submitted: " + submitted + ", published: " + published + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional state = Optional.empty(); - - private Optional level = Optional.empty(); - - private Optional levelId = Optional.empty(); - - private Optional creator = Optional.empty(); - - private Optional playtime = Optional.empty(); - - private Optional changed = Optional.empty(); - - private Optional created = Optional.empty(); - - private Optional dateFirstCompleted = Optional.empty(); - - private Optional submitted = Optional.empty(); - - private Optional published = Optional.empty(); - - private Builder() { - } - - public Builder from(LevelSessionResponse other) { - state(other.getState()); - level(other.getLevel()); - levelId(other.getLevelId()); - creator(other.getCreator()); - playtime(other.getPlaytime()); - changed(other.getChanged()); - created(other.getCreated()); - dateFirstCompleted(other.getDateFirstCompleted()); - submitted(other.getSubmitted()); - published(other.getPublished()); - return this; - } - - @JsonSetter( - value = "state", - nulls = Nulls.SKIP - ) - public Builder state(Optional state) { - this.state = state; - return this; - } - - public Builder state(State state) { - this.state = Optional.of(state); - return this; - } - - @JsonSetter( - value = "level", - nulls = Nulls.SKIP - ) - public Builder level(Optional level) { - this.level = level; - return this; - } - - public Builder level(Level level) { - this.level = Optional.of(level); - return this; - } - - @JsonSetter( - value = "levelID", - nulls = Nulls.SKIP - ) - public Builder levelId(Optional levelId) { - this.levelId = levelId; - return this; - } - - public Builder levelId(String levelId) { - this.levelId = Optional.of(levelId); - return this; - } - - @JsonSetter( - value = "creator", - nulls = Nulls.SKIP - ) - public Builder creator(Optional creator) { - this.creator = creator; - return this; - } - - public Builder creator(String creator) { - this.creator = Optional.of(creator); - return this; - } - - @JsonSetter( - value = "playtime", - nulls = Nulls.SKIP - ) - public Builder playtime(Optional playtime) { - this.playtime = playtime; - return this; - } - - public Builder playtime(Integer playtime) { - this.playtime = Optional.of(playtime); - return this; - } - - @JsonSetter( - value = "changed", - nulls = Nulls.SKIP - ) - public Builder changed(Optional changed) { - this.changed = changed; - return this; - } - - public Builder changed(String changed) { - this.changed = Optional.of(changed); - return this; - } - - @JsonSetter( - value = "created", - nulls = Nulls.SKIP - ) - public Builder created(Optional created) { - this.created = created; - return this; - } - - public Builder created(String created) { - this.created = Optional.of(created); - return this; - } - - @JsonSetter( - value = "dateFirstCompleted", - nulls = Nulls.SKIP - ) - public Builder dateFirstCompleted(Optional dateFirstCompleted) { - this.dateFirstCompleted = dateFirstCompleted; - return this; - } - - public Builder dateFirstCompleted(String dateFirstCompleted) { - this.dateFirstCompleted = Optional.of(dateFirstCompleted); - return this; - } - - @JsonSetter( - value = "submitted", - nulls = Nulls.SKIP - ) - public Builder submitted(Optional submitted) { - this.submitted = submitted; - return this; - } - - public Builder submitted(Boolean submitted) { - this.submitted = Optional.of(submitted); - return this; - } - - @JsonSetter( - value = "published", - nulls = Nulls.SKIP - ) - public Builder published(Optional published) { - this.published = published; - return this; - } - - public Builder published(Boolean published) { - this.published = Optional.of(published); - return this; - } - - public LevelSessionResponse build() { - return new LevelSessionResponse(state, level, levelId, creator, playtime, changed, created, dateFirstCompleted, submitted, published); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/MemberStat.java b/src/main/java/com/codecombat/api/client/classrooms/types/MemberStat.java deleted file mode 100644 index ca03274..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/MemberStat.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = MemberStat.Builder.class -) -public final class MemberStat { - private final Optional id; - - private final Optional stats; - - private int _cachedHashCode; - - MemberStat(Optional id, Optional stats) { - this.id = id; - this.stats = stats; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("stats") - public Optional getStats() { - return stats; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MemberStat && equalTo((MemberStat) other); - } - - private boolean equalTo(MemberStat other) { - return id.equals(other.id) && stats.equals(other.stats); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.stats); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "MemberStat{" + "id: " + id + ", stats: " + stats + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional stats = Optional.empty(); - - private Builder() { - } - - public Builder from(MemberStat other) { - id(other.getId()); - stats(other.getStats()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "stats", - nulls = Nulls.SKIP - ) - public Builder stats(Optional stats) { - this.stats = stats; - return this; - } - - public Builder stats(PlayStats stats) { - this.stats = Optional.of(stats); - return this; - } - - public MemberStat build() { - return new MemberStat(id, stats); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/PlayStats.java b/src/main/java/com/codecombat/api/client/classrooms/types/PlayStats.java deleted file mode 100644 index 15a8ec7..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/PlayStats.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = PlayStats.Builder.class -) -public final class PlayStats { - private final Optional gamesCompleted; - - private final Optional playtime; - - private int _cachedHashCode; - - PlayStats(Optional gamesCompleted, Optional playtime) { - this.gamesCompleted = gamesCompleted; - this.playtime = playtime; - } - - @JsonProperty("gamesCompleted") - public Optional getGamesCompleted() { - return gamesCompleted; - } - - /** - * @return Total play time in seconds - */ - @JsonProperty("playtime") - public Optional getPlaytime() { - return playtime; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PlayStats && equalTo((PlayStats) other); - } - - private boolean equalTo(PlayStats other) { - return gamesCompleted.equals(other.gamesCompleted) && playtime.equals(other.playtime); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.gamesCompleted, this.playtime); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "PlayStats{" + "gamesCompleted: " + gamesCompleted + ", playtime: " + playtime + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional gamesCompleted = Optional.empty(); - - private Optional playtime = Optional.empty(); - - private Builder() { - } - - public Builder from(PlayStats other) { - gamesCompleted(other.getGamesCompleted()); - playtime(other.getPlaytime()); - return this; - } - - @JsonSetter( - value = "gamesCompleted", - nulls = Nulls.SKIP - ) - public Builder gamesCompleted(Optional gamesCompleted) { - this.gamesCompleted = gamesCompleted; - return this; - } - - public Builder gamesCompleted(Double gamesCompleted) { - this.gamesCompleted = Optional.of(gamesCompleted); - return this; - } - - @JsonSetter( - value = "playtime", - nulls = Nulls.SKIP - ) - public Builder playtime(Optional playtime) { - this.playtime = playtime; - return this; - } - - public Builder playtime(Double playtime) { - this.playtime = Optional.of(playtime); - return this; - } - - public PlayStats build() { - return new PlayStats(gamesCompleted, playtime); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/RemoveUserFromClassroomRequest.java b/src/main/java/com/codecombat/api/client/classrooms/types/RemoveUserFromClassroomRequest.java deleted file mode 100644 index 7bf2f19..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/RemoveUserFromClassroomRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = RemoveUserFromClassroomRequest.Builder.class -) -public final class RemoveUserFromClassroomRequest { - private final String userId; - - private int _cachedHashCode; - - RemoveUserFromClassroomRequest(String userId) { - this.userId = userId; - } - - @JsonProperty("userId") - public String getUserId() { - return userId; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RemoveUserFromClassroomRequest && equalTo((RemoveUserFromClassroomRequest) other); - } - - private boolean equalTo(RemoveUserFromClassroomRequest other) { - return userId.equals(other.userId); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.userId); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "RemoveUserFromClassroomRequest{" + "userId: " + userId + "}"; - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(RemoveUserFromClassroomRequest other); - } - - public interface _FinalStage { - RemoveUserFromClassroomRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - private Builder() { - } - - @Override - public Builder from(RemoveUserFromClassroomRequest other) { - userId(other.getUserId()); - return this; - } - - @Override - @JsonSetter("userId") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @Override - public RemoveUserFromClassroomRequest build() { - return new RemoveUserFromClassroomRequest(userId); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/State.java b/src/main/java/com/codecombat/api/client/classrooms/types/State.java deleted file mode 100644 index e52d9c6..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/State.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Boolean; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = State.Builder.class -) -public final class State { - private final Optional complete; - - private int _cachedHashCode; - - State(Optional complete) { - this.complete = complete; - } - - @JsonProperty("complete") - public Optional getComplete() { - return complete; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof State && equalTo((State) other); - } - - private boolean equalTo(State other) { - return complete.equals(other.complete); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.complete); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "State{" + "complete: " + complete + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional complete = Optional.empty(); - - private Builder() { - } - - public Builder from(State other) { - complete(other.getComplete()); - return this; - } - - @JsonSetter( - value = "complete", - nulls = Nulls.SKIP - ) - public Builder complete(Optional complete) { - this.complete = complete; - return this; - } - - public Builder complete(Boolean complete) { - this.complete = Optional.of(complete); - return this; - } - - public State build() { - return new State(complete); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/classrooms/types/UpsertClassroomRequest.java b/src/main/java/com/codecombat/api/client/classrooms/types/UpsertClassroomRequest.java deleted file mode 100644 index 71f438c..0000000 --- a/src/main/java/com/codecombat/api/client/classrooms/types/UpsertClassroomRequest.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.codecombat.api.client.classrooms.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = UpsertClassroomRequest.Builder.class -) -public final class UpsertClassroomRequest { - private final String code; - - private final String userId; - - private final Optional retMemberLimit; - - private int _cachedHashCode; - - UpsertClassroomRequest(String code, String userId, Optional retMemberLimit) { - this.code = code; - this.userId = userId; - this.retMemberLimit = retMemberLimit; - } - - /** - * @return The code for joining this classroom - */ - @JsonProperty("code") - public String getCode() { - return code; - } - - /** - * @return The _id or slug of the user to add to the class. - */ - @JsonProperty("userId") - public String getUserId() { - return userId; - } - - /** - * @return limit the return number of members for the classroom, the default value is 1000 - */ - @JsonProperty("retMemberLimit") - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpsertClassroomRequest && equalTo((UpsertClassroomRequest) other); - } - - private boolean equalTo(UpsertClassroomRequest other) { - return code.equals(other.code) && userId.equals(other.userId) && retMemberLimit.equals(other.retMemberLimit); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.code, this.userId, this.retMemberLimit); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpsertClassroomRequest{" + "code: " + code + ", userId: " + userId + ", retMemberLimit: " + retMemberLimit + "}"; - } - - public static CodeStage builder() { - return new Builder(); - } - - public interface CodeStage { - UserIdStage code(String code); - - Builder from(UpsertClassroomRequest other); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - } - - public interface _FinalStage { - UpsertClassroomRequest build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements CodeStage, UserIdStage, _FinalStage { - private String code; - - private String userId; - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(UpsertClassroomRequest other) { - code(other.getCode()); - userId(other.getUserId()); - retMemberLimit(other.getRetMemberLimit()); - return this; - } - - /** - *

The code for joining this classroom

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("code") - public UserIdStage code(String code) { - this.code = code; - return this; - } - - /** - *

The _id or slug of the user to add to the class.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("userId") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - /** - *

limit the return number of members for the classroom, the default value is 1000

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - @JsonSetter( - value = "retMemberLimit", - nulls = Nulls.SKIP - ) - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public UpsertClassroomRequest build() { - return new UpsertClassroomRequest(code, userId, retMemberLimit); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/AuthIdentity.java b/src/main/java/com/codecombat/api/client/commons/types/AuthIdentity.java deleted file mode 100644 index 149a25a..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/AuthIdentity.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = AuthIdentity.Builder.class -) -public final class AuthIdentity { - private final Optional provider; - - private final Optional id; - - private int _cachedHashCode; - - AuthIdentity(Optional provider, Optional id) { - this.provider = provider; - this.id = id; - } - - @JsonProperty("provider") - public Optional getProvider() { - return provider; - } - - @JsonProperty("id") - public Optional getId() { - return id; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuthIdentity && equalTo((AuthIdentity) other); - } - - private boolean equalTo(AuthIdentity other) { - return provider.equals(other.provider) && id.equals(other.id); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.provider, this.id); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "AuthIdentity{" + "provider: " + provider + ", id: " + id + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional provider = Optional.empty(); - - private Optional id = Optional.empty(); - - private Builder() { - } - - public Builder from(AuthIdentity other) { - provider(other.getProvider()); - id(other.getId()); - return this; - } - - @JsonSetter( - value = "provider", - nulls = Nulls.SKIP - ) - public Builder provider(Optional provider) { - this.provider = provider; - return this; - } - - public Builder provider(String provider) { - this.provider = Optional.of(provider); - return this; - } - - @JsonSetter( - value = "id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - public AuthIdentity build() { - return new AuthIdentity(provider, id); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponse.java b/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponse.java deleted file mode 100644 index 4690573..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponse.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = ClassroomResponse.Builder.class -) -public final class ClassroomResponse { - private final Optional id; - - private final Optional name; - - private final Optional> members; - - private final Optional ownerId; - - private final Optional description; - - private final Optional> courses; - - private int _cachedHashCode; - - ClassroomResponse(Optional id, Optional name, Optional> members, - Optional ownerId, Optional description, Optional> courses) { - this.id = id; - this.name = name; - this.members = members; - this.ownerId = ownerId; - this.description = description; - this.courses = courses; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("name") - public Optional getName() { - return name; - } - - @JsonProperty("members") - public Optional> getMembers() { - return members; - } - - @JsonProperty("ownerID") - public Optional getOwnerId() { - return ownerId; - } - - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - @JsonProperty("courses") - public Optional> getCourses() { - return courses; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ClassroomResponse && equalTo((ClassroomResponse) other); - } - - private boolean equalTo(ClassroomResponse other) { - return id.equals(other.id) && name.equals(other.name) && members.equals(other.members) && ownerId.equals(other.ownerId) && description.equals(other.description) && courses.equals(other.courses); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.name, this.members, this.ownerId, this.description, this.courses); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ClassroomResponse{" + "id: " + id + ", name: " + name + ", members: " + members + ", ownerId: " + ownerId + ", description: " + description + ", courses: " + courses + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional> members = Optional.empty(); - - private Optional ownerId = Optional.empty(); - - private Optional description = Optional.empty(); - - private Optional> courses = Optional.empty(); - - private Builder() { - } - - public Builder from(ClassroomResponse other) { - id(other.getId()); - name(other.getName()); - members(other.getMembers()); - ownerId(other.getOwnerId()); - description(other.getDescription()); - courses(other.getCourses()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "name", - nulls = Nulls.SKIP - ) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.of(name); - return this; - } - - @JsonSetter( - value = "members", - nulls = Nulls.SKIP - ) - public Builder members(Optional> members) { - this.members = members; - return this; - } - - public Builder members(List members) { - this.members = Optional.of(members); - return this; - } - - @JsonSetter( - value = "ownerID", - nulls = Nulls.SKIP - ) - public Builder ownerId(Optional ownerId) { - this.ownerId = ownerId; - return this; - } - - public Builder ownerId(String ownerId) { - this.ownerId = Optional.of(ownerId); - return this; - } - - @JsonSetter( - value = "description", - nulls = Nulls.SKIP - ) - public Builder description(Optional description) { - this.description = description; - return this; - } - - public Builder description(String description) { - this.description = Optional.of(description); - return this; - } - - @JsonSetter( - value = "courses", - nulls = Nulls.SKIP - ) - public Builder courses(Optional> courses) { - this.courses = courses; - return this; - } - - public Builder courses(List courses) { - this.courses = Optional.of(courses); - return this; - } - - public ClassroomResponse build() { - return new ClassroomResponse(id, name, members, ownerId, description, courses); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponseWithCode.java b/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponseWithCode.java deleted file mode 100644 index e7e4919..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/ClassroomResponseWithCode.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = ClassroomResponseWithCode.Builder.class -) -public final class ClassroomResponseWithCode { - private final Optional id; - - private final Optional name; - - private final Optional> members; - - private final Optional ownerId; - - private final Optional description; - - private final Optional code; - - private final Optional codeCamel; - - private final Optional> courses; - - private final Optional clanId; - - private int _cachedHashCode; - - ClassroomResponseWithCode(Optional id, Optional name, - Optional> members, Optional ownerId, Optional description, - Optional code, Optional codeCamel, Optional> courses, - Optional clanId) { - this.id = id; - this.name = name; - this.members = members; - this.ownerId = ownerId; - this.description = description; - this.code = code; - this.codeCamel = codeCamel; - this.courses = courses; - this.clanId = clanId; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("name") - public Optional getName() { - return name; - } - - @JsonProperty("members") - public Optional> getMembers() { - return members; - } - - @JsonProperty("ownerID") - public Optional getOwnerId() { - return ownerId; - } - - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - @JsonProperty("code") - public Optional getCode() { - return code; - } - - @JsonProperty("codeCamel") - public Optional getCodeCamel() { - return codeCamel; - } - - @JsonProperty("courses") - public Optional> getCourses() { - return courses; - } - - @JsonProperty("clanId") - public Optional getClanId() { - return clanId; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ClassroomResponseWithCode && equalTo((ClassroomResponseWithCode) other); - } - - private boolean equalTo(ClassroomResponseWithCode other) { - return id.equals(other.id) && name.equals(other.name) && members.equals(other.members) && ownerId.equals(other.ownerId) && description.equals(other.description) && code.equals(other.code) && codeCamel.equals(other.codeCamel) && courses.equals(other.courses) && clanId.equals(other.clanId); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.name, this.members, this.ownerId, this.description, this.code, this.codeCamel, this.courses, this.clanId); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ClassroomResponseWithCode{" + "id: " + id + ", name: " + name + ", members: " + members + ", ownerId: " + ownerId + ", description: " + description + ", code: " + code + ", codeCamel: " + codeCamel + ", courses: " + courses + ", clanId: " + clanId + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional> members = Optional.empty(); - - private Optional ownerId = Optional.empty(); - - private Optional description = Optional.empty(); - - private Optional code = Optional.empty(); - - private Optional codeCamel = Optional.empty(); - - private Optional> courses = Optional.empty(); - - private Optional clanId = Optional.empty(); - - private Builder() { - } - - public Builder from(ClassroomResponseWithCode other) { - id(other.getId()); - name(other.getName()); - members(other.getMembers()); - ownerId(other.getOwnerId()); - description(other.getDescription()); - code(other.getCode()); - codeCamel(other.getCodeCamel()); - courses(other.getCourses()); - clanId(other.getClanId()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "name", - nulls = Nulls.SKIP - ) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.of(name); - return this; - } - - @JsonSetter( - value = "members", - nulls = Nulls.SKIP - ) - public Builder members(Optional> members) { - this.members = members; - return this; - } - - public Builder members(List members) { - this.members = Optional.of(members); - return this; - } - - @JsonSetter( - value = "ownerID", - nulls = Nulls.SKIP - ) - public Builder ownerId(Optional ownerId) { - this.ownerId = ownerId; - return this; - } - - public Builder ownerId(String ownerId) { - this.ownerId = Optional.of(ownerId); - return this; - } - - @JsonSetter( - value = "description", - nulls = Nulls.SKIP - ) - public Builder description(Optional description) { - this.description = description; - return this; - } - - public Builder description(String description) { - this.description = Optional.of(description); - return this; - } - - @JsonSetter( - value = "code", - nulls = Nulls.SKIP - ) - public Builder code(Optional code) { - this.code = code; - return this; - } - - public Builder code(String code) { - this.code = Optional.of(code); - return this; - } - - @JsonSetter( - value = "codeCamel", - nulls = Nulls.SKIP - ) - public Builder codeCamel(Optional codeCamel) { - this.codeCamel = codeCamel; - return this; - } - - public Builder codeCamel(String codeCamel) { - this.codeCamel = Optional.of(codeCamel); - return this; - } - - @JsonSetter( - value = "courses", - nulls = Nulls.SKIP - ) - public Builder courses(Optional> courses) { - this.courses = courses; - return this; - } - - public Builder courses(List courses) { - this.courses = Optional.of(courses); - return this; - } - - @JsonSetter( - value = "clanId", - nulls = Nulls.SKIP - ) - public Builder clanId(Optional clanId) { - this.clanId = clanId; - return this; - } - - public Builder clanId(String clanId) { - this.clanId = Optional.of(clanId); - return this; - } - - public ClassroomResponseWithCode build() { - return new ClassroomResponseWithCode(id, name, members, ownerId, description, code, codeCamel, courses, clanId); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/Course.java b/src/main/java/com/codecombat/api/client/commons/types/Course.java deleted file mode 100644 index 1d7d908..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/Course.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = Course.Builder.class -) -public final class Course { - private final Optional id; - - private final Optional>> levels; - - private final Optional> enrolled; - - private final Optional instanceId; - - private int _cachedHashCode; - - Course(Optional id, Optional>> levels, - Optional> enrolled, Optional instanceId) { - this.id = id; - this.levels = levels; - this.enrolled = enrolled; - this.instanceId = instanceId; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("levels") - public Optional>> getLevels() { - return levels; - } - - @JsonProperty("enrolled") - public Optional> getEnrolled() { - return enrolled; - } - - @JsonProperty("instance_id") - public Optional getInstanceId() { - return instanceId; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Course && equalTo((Course) other); - } - - private boolean equalTo(Course other) { - return id.equals(other.id) && levels.equals(other.levels) && enrolled.equals(other.enrolled) && instanceId.equals(other.instanceId); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.levels, this.enrolled, this.instanceId); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Course{" + "id: " + id + ", levels: " + levels + ", enrolled: " + enrolled + ", instanceId: " + instanceId + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional>> levels = Optional.empty(); - - private Optional> enrolled = Optional.empty(); - - private Optional instanceId = Optional.empty(); - - private Builder() { - } - - public Builder from(Course other) { - id(other.getId()); - levels(other.getLevels()); - enrolled(other.getEnrolled()); - instanceId(other.getInstanceId()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "levels", - nulls = Nulls.SKIP - ) - public Builder levels(Optional>> levels) { - this.levels = levels; - return this; - } - - public Builder levels(List> levels) { - this.levels = Optional.of(levels); - return this; - } - - @JsonSetter( - value = "enrolled", - nulls = Nulls.SKIP - ) - public Builder enrolled(Optional> enrolled) { - this.enrolled = enrolled; - return this; - } - - public Builder enrolled(List enrolled) { - this.enrolled = Optional.of(enrolled); - return this; - } - - @JsonSetter( - value = "instance_id", - nulls = Nulls.SKIP - ) - public Builder instanceId(Optional instanceId) { - this.instanceId = instanceId; - return this; - } - - public Builder instanceId(String instanceId) { - this.instanceId = Optional.of(instanceId); - return this; - } - - public Course build() { - return new Course(id, levels, enrolled, instanceId); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/License.java b/src/main/java/com/codecombat/api/client/commons/types/License.java deleted file mode 100644 index 947dee3..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/License.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Boolean; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = License.Builder.class -) -public final class License { - private final Optional ends; - - private final Optional active; - - private int _cachedHashCode; - - License(Optional ends, Optional active) { - this.ends = ends; - this.active = active; - } - - @JsonProperty("ends") - public Optional getEnds() { - return ends; - } - - @JsonProperty("active") - public Optional getActive() { - return active; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof License && equalTo((License) other); - } - - private boolean equalTo(License other) { - return ends.equals(other.ends) && active.equals(other.active); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends, this.active); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "License{" + "ends: " + ends + ", active: " + active + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional ends = Optional.empty(); - - private Optional active = Optional.empty(); - - private Builder() { - } - - public Builder from(License other) { - ends(other.getEnds()); - active(other.getActive()); - return this; - } - - @JsonSetter( - value = "ends", - nulls = Nulls.SKIP - ) - public Builder ends(Optional ends) { - this.ends = ends; - return this; - } - - public Builder ends(String ends) { - this.ends = Optional.of(ends); - return this; - } - - @JsonSetter( - value = "active", - nulls = Nulls.SKIP - ) - public Builder active(Optional active) { - this.active = active; - return this; - } - - public Builder active(Boolean active) { - this.active = Optional.of(active); - return this; - } - - public License build() { - return new License(ends, active); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/Subscription.java b/src/main/java/com/codecombat/api/client/commons/types/Subscription.java deleted file mode 100644 index bf2cbe7..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/Subscription.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Boolean; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = Subscription.Builder.class -) -public final class Subscription { - private final Optional ends; - - private final Optional active; - - private int _cachedHashCode; - - Subscription(Optional ends, Optional active) { - this.ends = ends; - this.active = active; - } - - @JsonProperty("ends") - public Optional getEnds() { - return ends; - } - - @JsonProperty("active") - public Optional getActive() { - return active; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Subscription && equalTo((Subscription) other); - } - - private boolean equalTo(Subscription other) { - return ends.equals(other.ends) && active.equals(other.active); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends, this.active); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Subscription{" + "ends: " + ends + ", active: " + active + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional ends = Optional.empty(); - - private Optional active = Optional.empty(); - - private Builder() { - } - - public Builder from(Subscription other) { - ends(other.getEnds()); - active(other.getActive()); - return this; - } - - @JsonSetter( - value = "ends", - nulls = Nulls.SKIP - ) - public Builder ends(Optional ends) { - this.ends = ends; - return this; - } - - public Builder ends(String ends) { - this.ends = Optional.of(ends); - return this; - } - - @JsonSetter( - value = "active", - nulls = Nulls.SKIP - ) - public Builder active(Optional active) { - this.active = active; - return this; - } - - public Builder active(Boolean active) { - this.active = Optional.of(active); - return this; - } - - public Subscription build() { - return new Subscription(ends, active); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/UserResponse.java b/src/main/java/com/codecombat/api/client/commons/types/UserResponse.java deleted file mode 100644 index f9b7453..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/UserResponse.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = UserResponse.Builder.class -) -public final class UserResponse { - private final Optional id; - - private final Optional email; - - private final Optional name; - - private final Optional slug; - - private final Optional role; - - private final Optional stats; - - private final Optional> oAuthIdentities; - - private final Optional subscription; - - private final Optional license; - - private int _cachedHashCode; - - UserResponse(Optional id, Optional email, Optional name, - Optional slug, Optional role, Optional stats, - Optional> oAuthIdentities, Optional subscription, - Optional license) { - this.id = id; - this.email = email; - this.name = name; - this.slug = slug; - this.role = role; - this.stats = stats; - this.oAuthIdentities = oAuthIdentities; - this.subscription = subscription; - this.license = license; - } - - @JsonProperty("_id") - public Optional getId() { - return id; - } - - @JsonProperty("email") - public Optional getEmail() { - return email; - } - - @JsonProperty("name") - public Optional getName() { - return name; - } - - @JsonProperty("slug") - public Optional getSlug() { - return slug; - } - - @JsonProperty("role") - public Optional getRole() { - return role; - } - - @JsonProperty("stats") - public Optional getStats() { - return stats; - } - - @JsonProperty("oAuthIdentities") - public Optional> getOAuthIdentities() { - return oAuthIdentities; - } - - @JsonProperty("subscription") - public Optional getSubscription() { - return subscription; - } - - @JsonProperty("license") - public Optional getLicense() { - return license; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserResponse && equalTo((UserResponse) other); - } - - private boolean equalTo(UserResponse other) { - return id.equals(other.id) && email.equals(other.email) && name.equals(other.name) && slug.equals(other.slug) && role.equals(other.role) && stats.equals(other.stats) && oAuthIdentities.equals(other.oAuthIdentities) && subscription.equals(other.subscription) && license.equals(other.license); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.id, this.email, this.name, this.slug, this.role, this.stats, this.oAuthIdentities, this.subscription, this.license); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UserResponse{" + "id: " + id + ", email: " + email + ", name: " + name + ", slug: " + slug + ", role: " + role + ", stats: " + stats + ", oAuthIdentities: " + oAuthIdentities + ", subscription: " + subscription + ", license: " + license + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional email = Optional.empty(); - - private Optional name = Optional.empty(); - - private Optional slug = Optional.empty(); - - private Optional role = Optional.empty(); - - private Optional stats = Optional.empty(); - - private Optional> oAuthIdentities = Optional.empty(); - - private Optional subscription = Optional.empty(); - - private Optional license = Optional.empty(); - - private Builder() { - } - - public Builder from(UserResponse other) { - id(other.getId()); - email(other.getEmail()); - name(other.getName()); - slug(other.getSlug()); - role(other.getRole()); - stats(other.getStats()); - oAuthIdentities(other.getOAuthIdentities()); - subscription(other.getSubscription()); - license(other.getLicense()); - return this; - } - - @JsonSetter( - value = "_id", - nulls = Nulls.SKIP - ) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter( - value = "email", - nulls = Nulls.SKIP - ) - public Builder email(Optional email) { - this.email = email; - return this; - } - - public Builder email(String email) { - this.email = Optional.of(email); - return this; - } - - @JsonSetter( - value = "name", - nulls = Nulls.SKIP - ) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.of(name); - return this; - } - - @JsonSetter( - value = "slug", - nulls = Nulls.SKIP - ) - public Builder slug(Optional slug) { - this.slug = slug; - return this; - } - - public Builder slug(String slug) { - this.slug = Optional.of(slug); - return this; - } - - @JsonSetter( - value = "role", - nulls = Nulls.SKIP - ) - public Builder role(Optional role) { - this.role = role; - return this; - } - - public Builder role(String role) { - this.role = Optional.of(role); - return this; - } - - @JsonSetter( - value = "stats", - nulls = Nulls.SKIP - ) - public Builder stats(Optional stats) { - this.stats = stats; - return this; - } - - public Builder stats(UserStats stats) { - this.stats = Optional.of(stats); - return this; - } - - @JsonSetter( - value = "oAuthIdentities", - nulls = Nulls.SKIP - ) - public Builder oAuthIdentities(Optional> oAuthIdentities) { - this.oAuthIdentities = oAuthIdentities; - return this; - } - - public Builder oAuthIdentities(List oAuthIdentities) { - this.oAuthIdentities = Optional.of(oAuthIdentities); - return this; - } - - @JsonSetter( - value = "subscription", - nulls = Nulls.SKIP - ) - public Builder subscription(Optional subscription) { - this.subscription = subscription; - return this; - } - - public Builder subscription(Subscription subscription) { - this.subscription = Optional.of(subscription); - return this; - } - - @JsonSetter( - value = "license", - nulls = Nulls.SKIP - ) - public Builder license(Optional license) { - this.license = license; - return this; - } - - public Builder license(License license) { - this.license = Optional.of(license); - return this; - } - - public UserResponse build() { - return new UserResponse(id, email, name, slug, role, stats, oAuthIdentities, subscription, license); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/commons/types/UserStats.java b/src/main/java/com/codecombat/api/client/commons/types/UserStats.java deleted file mode 100644 index 85b2be8..0000000 --- a/src/main/java/com/codecombat/api/client/commons/types/UserStats.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.codecombat.api.client.commons.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = UserStats.Builder.class -) -public final class UserStats { - private final Optional gamesCompleted; - - private final Optional> concepts; - - private final Optional playTime; - - private int _cachedHashCode; - - UserStats(Optional gamesCompleted, Optional> concepts, - Optional playTime) { - this.gamesCompleted = gamesCompleted; - this.concepts = concepts; - this.playTime = playTime; - } - - @JsonProperty("gamesCompleted") - public Optional getGamesCompleted() { - return gamesCompleted; - } - - @JsonProperty("concepts") - public Optional> getConcepts() { - return concepts; - } - - /** - * @return Included only when specifically requested on the endpoint - */ - @JsonProperty("playTime") - public Optional getPlayTime() { - return playTime; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserStats && equalTo((UserStats) other); - } - - private boolean equalTo(UserStats other) { - return gamesCompleted.equals(other.gamesCompleted) && concepts.equals(other.concepts) && playTime.equals(other.playTime); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.gamesCompleted, this.concepts, this.playTime); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UserStats{" + "gamesCompleted: " + gamesCompleted + ", concepts: " + concepts + ", playTime: " + playTime + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional gamesCompleted = Optional.empty(); - - private Optional> concepts = Optional.empty(); - - private Optional playTime = Optional.empty(); - - private Builder() { - } - - public Builder from(UserStats other) { - gamesCompleted(other.getGamesCompleted()); - concepts(other.getConcepts()); - playTime(other.getPlayTime()); - return this; - } - - @JsonSetter( - value = "gamesCompleted", - nulls = Nulls.SKIP - ) - public Builder gamesCompleted(Optional gamesCompleted) { - this.gamesCompleted = gamesCompleted; - return this; - } - - public Builder gamesCompleted(Double gamesCompleted) { - this.gamesCompleted = Optional.of(gamesCompleted); - return this; - } - - @JsonSetter( - value = "concepts", - nulls = Nulls.SKIP - ) - public Builder concepts(Optional> concepts) { - this.concepts = concepts; - return this; - } - - public Builder concepts(Map concepts) { - this.concepts = Optional.of(concepts); - return this; - } - - @JsonSetter( - value = "playTime", - nulls = Nulls.SKIP - ) - public Builder playTime(Optional playTime) { - this.playTime = playTime; - return this; - } - - public Builder playTime(Double playTime) { - this.playTime = Optional.of(playTime); - return this; - } - - public UserStats build() { - return new UserStats(gamesCompleted, concepts, playTime); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/endpoints/GetLicenseStats.java b/src/main/java/com/codecombat/api/client/stats/endpoints/GetLicenseStats.java deleted file mode 100644 index 9cf716a..0000000 --- a/src/main/java/com/codecombat/api/client/stats/endpoints/GetLicenseStats.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.codecombat.api.client.stats.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetLicenseStats { - private GetLicenseStats() { - } - - public static final class Request { - private final Optional authOverride; - - private int _cachedHashCode; - - Request(Optional authOverride) { - this.authOverride = authOverride; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetLicenseStats.Request{" + "authOverride: " + authOverride + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - public Builder from(Request other) { - authOverride(other.getAuthOverride()); - return this; - } - - public Builder authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - public Builder authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - public Request build() { - return new Request(authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/endpoints/GetPlaytimeStats.java b/src/main/java/com/codecombat/api/client/stats/endpoints/GetPlaytimeStats.java deleted file mode 100644 index 229ac76..0000000 --- a/src/main/java/com/codecombat/api/client/stats/endpoints/GetPlaytimeStats.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.codecombat.api.client.stats.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetPlaytimeStats { - private GetPlaytimeStats() { - } - - public static final class Request { - private final Optional startDate; - - private final Optional endDate; - - private final Optional country; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(Optional startDate, Optional endDate, Optional country, - Optional authOverride) { - this.startDate = startDate; - this.endDate = endDate; - this.country = country; - this.authOverride = authOverride; - } - - /** - * @return Earliest an included user was created - */ - public Optional getStartDate() { - return startDate; - } - - /** - * @return Latest an included user was created - */ - public Optional getEndDate() { - return endDate; - } - - /** - * @return Filter by country string - */ - public Optional getCountry() { - return country; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return startDate.equals(other.startDate) && endDate.equals(other.endDate) && country.equals(other.country) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.startDate, this.endDate, this.country, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetPlaytimeStats.Request{" + "startDate: " + startDate + ", endDate: " + endDate + ", country: " + country + ", authOverride: " + authOverride + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Optional startDate = Optional.empty(); - - private Optional endDate = Optional.empty(); - - private Optional country = Optional.empty(); - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - public Builder from(Request other) { - startDate(other.getStartDate()); - endDate(other.getEndDate()); - country(other.getCountry()); - authOverride(other.getAuthOverride()); - return this; - } - - public Builder startDate(Optional startDate) { - this.startDate = startDate; - return this; - } - - public Builder startDate(String startDate) { - this.startDate = Optional.of(startDate); - return this; - } - - public Builder endDate(Optional endDate) { - this.endDate = endDate; - return this; - } - - public Builder endDate(String endDate) { - this.endDate = Optional.of(endDate); - return this; - } - - public Builder country(Optional country) { - this.country = country; - return this; - } - - public Builder country(String country) { - this.country = Optional.of(country); - return this; - } - - public Builder authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - public Builder authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - public Request build() { - return new Request(startDate, endDate, country, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/exceptions/GetLicenseStatsException.java b/src/main/java/com/codecombat/api/client/stats/exceptions/GetLicenseStatsException.java deleted file mode 100644 index d03ca37..0000000 --- a/src/main/java/com/codecombat/api/client/stats/exceptions/GetLicenseStatsException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.stats.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetLicenseStatsException.Deserializer.class -) -public final class GetLicenseStatsException extends Exception { - private final Value value; - - private int statusCode; - - private GetLicenseStatsException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetLicenseStatsException other(Object unknownValue, int statusCode) { - return new GetLicenseStatsException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetLicenseStatsException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetLicenseStatsException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetLicenseStatsException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/exceptions/GetPlaytimeStatsException.java b/src/main/java/com/codecombat/api/client/stats/exceptions/GetPlaytimeStatsException.java deleted file mode 100644 index f577465..0000000 --- a/src/main/java/com/codecombat/api/client/stats/exceptions/GetPlaytimeStatsException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.stats.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetPlaytimeStatsException.Deserializer.class -) -public final class GetPlaytimeStatsException extends Exception { - private final Value value; - - private int statusCode; - - private GetPlaytimeStatsException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetPlaytimeStatsException other(Object unknownValue, int statusCode) { - return new GetPlaytimeStatsException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetPlaytimeStatsException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetPlaytimeStatsException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetPlaytimeStatsException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/statsService.java b/src/main/java/com/codecombat/api/client/stats/statsService.java deleted file mode 100644 index 503d428..0000000 --- a/src/main/java/com/codecombat/api/client/stats/statsService.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.codecombat.api.client.stats; - -import com.codecombat.api.client.stats.exceptions.GetLicenseStatsException; -import com.codecombat.api.client.stats.exceptions.GetPlaytimeStatsException; -import com.codecombat.api.client.stats.types.LicenseStatsResponse; -import com.codecombat.api.client.stats.types.PlaytimeStatsResponse; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.ObjectMappers; -import com.fern.java.jersey.contracts.OptionalAwareContract; -import feign.Feign; -import feign.jackson.JacksonDecoder; -import feign.jackson.JacksonEncoder; -import feign.jaxrs.JAXRSContract; -import java.lang.String; -import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/") -interface statsService { - @GET - @Path("/playtime-stats") - PlaytimeStatsResponse getPlaytimeStats(@HeaderParam("Authorization") BasicAuth auth, - @QueryParam("startDate") Optional startDate, - @QueryParam("endDate") Optional endDate, - @QueryParam("country") Optional country) throws GetPlaytimeStatsException; - - @GET - @Path("/license-stats") - LicenseStatsResponse getLicenseStats(@HeaderParam("Authorization") BasicAuth auth) throws - GetLicenseStatsException; - - static statsService getClient(String url) { - return Feign.builder() - .contract(new OptionalAwareContract(new JAXRSContract())) - .decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER)) - .encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER)) - .errorDecoder(new statsServiceErrorDecoder()).target(statsService.class, url); - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/statsServiceClient.java b/src/main/java/com/codecombat/api/client/stats/statsServiceClient.java deleted file mode 100644 index c23ec25..0000000 --- a/src/main/java/com/codecombat/api/client/stats/statsServiceClient.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.codecombat.api.client.stats; - -import com.codecombat.api.client.stats.endpoints.GetLicenseStats; -import com.codecombat.api.client.stats.endpoints.GetPlaytimeStats; -import com.codecombat.api.client.stats.exceptions.GetLicenseStatsException; -import com.codecombat.api.client.stats.exceptions.GetPlaytimeStatsException; -import com.codecombat.api.client.stats.types.LicenseStatsResponse; -import com.codecombat.api.client.stats.types.PlaytimeStatsResponse; -import com.codecombat.api.core.BasicAuth; -import java.lang.RuntimeException; -import java.lang.String; -import java.util.Optional; - -public final class statsServiceClient { - private final statsService service; - - private final Optional auth; - - public statsServiceClient(String url) { - this.service = statsService.getClient(url); - this.auth = Optional.empty(); - } - - public statsServiceClient(String url, BasicAuth auth) { - this.service = statsService.getClient(url); - this.auth = Optional.of(auth); - } - - /** - *

Returns the playtime stats

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetPlaytimeStatsException Exception that wraps all possible endpoint errors - * @return PlaytimeStatsResponse - */ - public PlaytimeStatsResponse getPlaytimeStats(GetPlaytimeStats.Request request) throws - GetPlaytimeStatsException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getPlaytimeStats(authValue, request.getStartDate(), request.getEndDate(), request.getCountry()); - } - - /** - *

Returns the license stats

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetLicenseStatsException Exception that wraps all possible endpoint errors - * @return LicenseStatsResponse - */ - public LicenseStatsResponse getLicenseStats(GetLicenseStats.Request request) throws - GetLicenseStatsException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getLicenseStats(authValue); - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/statsServiceErrorDecoder.java b/src/main/java/com/codecombat/api/client/stats/statsServiceErrorDecoder.java deleted file mode 100644 index 88d8803..0000000 --- a/src/main/java/com/codecombat/api/client/stats/statsServiceErrorDecoder.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.codecombat.api.client.stats; - -import com.codecombat.api.client.stats.exceptions.GetLicenseStatsException; -import com.codecombat.api.client.stats.exceptions.GetPlaytimeStatsException; -import com.codecombat.api.core.ObjectMappers; -import feign.Response; -import feign.codec.ErrorDecoder; -import java.io.IOException; -import java.lang.Class; -import java.lang.Exception; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; - -final class statsServiceErrorDecoder implements ErrorDecoder { - @Override - public Exception decode(String methodKey, Response response) { - try { - if (methodKey.contains("getPlaytimeStats")) { - return decodeException(response, GetPlaytimeStatsException.class); - } - if (methodKey.contains("getLicenseStats")) { - return decodeException(response, GetLicenseStatsException.class); - } - } - catch (IOException e) { - } - return new RuntimeException("Failed to read response body. Received status " + response.status() + " for method " + methodKey); - } - - private static Exception decodeException(Response response, Class clazz) - throws IOException { - return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz); - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/types/LicenseStatsResponse.java b/src/main/java/com/codecombat/api/client/stats/types/LicenseStatsResponse.java deleted file mode 100644 index 337fa9f..0000000 --- a/src/main/java/com/codecombat/api/client/stats/types/LicenseStatsResponse.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.codecombat.api.client.stats.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = LicenseStatsResponse.Builder.class -) -public final class LicenseStatsResponse { - private final Optional licenseDaysGranted; - - private final Optional licenseDaysUsed; - - private final Optional licenseDaysRemaining; - - private final Optional activeLicenses; - - private int _cachedHashCode; - - LicenseStatsResponse(Optional licenseDaysGranted, Optional licenseDaysUsed, - Optional licenseDaysRemaining, Optional activeLicenses) { - this.licenseDaysGranted = licenseDaysGranted; - this.licenseDaysUsed = licenseDaysUsed; - this.licenseDaysRemaining = licenseDaysRemaining; - this.activeLicenses = activeLicenses; - } - - /** - * @return Total number of license days granted - */ - @JsonProperty("licenseDaysGranted") - public Optional getLicenseDaysGranted() { - return licenseDaysGranted; - } - - /** - * @return Number of license days used - */ - @JsonProperty("licenseDaysUsed") - public Optional getLicenseDaysUsed() { - return licenseDaysUsed; - } - - /** - * @return Number of license days remaining - */ - @JsonProperty("licenseDaysRemaining") - public Optional getLicenseDaysRemaining() { - return licenseDaysRemaining; - } - - /** - * @return Number of active/valid licenses - */ - @JsonProperty("activeLicenses") - public Optional getActiveLicenses() { - return activeLicenses; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof LicenseStatsResponse && equalTo((LicenseStatsResponse) other); - } - - private boolean equalTo(LicenseStatsResponse other) { - return licenseDaysGranted.equals(other.licenseDaysGranted) && licenseDaysUsed.equals(other.licenseDaysUsed) && licenseDaysRemaining.equals(other.licenseDaysRemaining) && activeLicenses.equals(other.activeLicenses); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.licenseDaysGranted, this.licenseDaysUsed, this.licenseDaysRemaining, this.activeLicenses); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "LicenseStatsResponse{" + "licenseDaysGranted: " + licenseDaysGranted + ", licenseDaysUsed: " + licenseDaysUsed + ", licenseDaysRemaining: " + licenseDaysRemaining + ", activeLicenses: " + activeLicenses + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional licenseDaysGranted = Optional.empty(); - - private Optional licenseDaysUsed = Optional.empty(); - - private Optional licenseDaysRemaining = Optional.empty(); - - private Optional activeLicenses = Optional.empty(); - - private Builder() { - } - - public Builder from(LicenseStatsResponse other) { - licenseDaysGranted(other.getLicenseDaysGranted()); - licenseDaysUsed(other.getLicenseDaysUsed()); - licenseDaysRemaining(other.getLicenseDaysRemaining()); - activeLicenses(other.getActiveLicenses()); - return this; - } - - @JsonSetter( - value = "licenseDaysGranted", - nulls = Nulls.SKIP - ) - public Builder licenseDaysGranted(Optional licenseDaysGranted) { - this.licenseDaysGranted = licenseDaysGranted; - return this; - } - - public Builder licenseDaysGranted(Double licenseDaysGranted) { - this.licenseDaysGranted = Optional.of(licenseDaysGranted); - return this; - } - - @JsonSetter( - value = "licenseDaysUsed", - nulls = Nulls.SKIP - ) - public Builder licenseDaysUsed(Optional licenseDaysUsed) { - this.licenseDaysUsed = licenseDaysUsed; - return this; - } - - public Builder licenseDaysUsed(Double licenseDaysUsed) { - this.licenseDaysUsed = Optional.of(licenseDaysUsed); - return this; - } - - @JsonSetter( - value = "licenseDaysRemaining", - nulls = Nulls.SKIP - ) - public Builder licenseDaysRemaining(Optional licenseDaysRemaining) { - this.licenseDaysRemaining = licenseDaysRemaining; - return this; - } - - public Builder licenseDaysRemaining(Double licenseDaysRemaining) { - this.licenseDaysRemaining = Optional.of(licenseDaysRemaining); - return this; - } - - @JsonSetter( - value = "activeLicenses", - nulls = Nulls.SKIP - ) - public Builder activeLicenses(Optional activeLicenses) { - this.activeLicenses = activeLicenses; - return this; - } - - public Builder activeLicenses(Double activeLicenses) { - this.activeLicenses = Optional.of(activeLicenses); - return this; - } - - public LicenseStatsResponse build() { - return new LicenseStatsResponse(licenseDaysGranted, licenseDaysUsed, licenseDaysRemaining, activeLicenses); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/stats/types/PlaytimeStatsResponse.java b/src/main/java/com/codecombat/api/client/stats/types/PlaytimeStatsResponse.java deleted file mode 100644 index 222f16f..0000000 --- a/src/main/java/com/codecombat/api/client/stats/types/PlaytimeStatsResponse.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.codecombat.api.client.stats.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = PlaytimeStatsResponse.Builder.class -) -public final class PlaytimeStatsResponse { - private final Optional playTime; - - private final Optional gamesPlayed; - - private int _cachedHashCode; - - PlaytimeStatsResponse(Optional playTime, Optional gamesPlayed) { - this.playTime = playTime; - this.gamesPlayed = gamesPlayed; - } - - /** - * @return Total play time in seconds - */ - @JsonProperty("playTime") - public Optional getPlayTime() { - return playTime; - } - - /** - * @return Number of levels played - */ - @JsonProperty("gamesPlayed") - public Optional getGamesPlayed() { - return gamesPlayed; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PlaytimeStatsResponse && equalTo((PlaytimeStatsResponse) other); - } - - private boolean equalTo(PlaytimeStatsResponse other) { - return playTime.equals(other.playTime) && gamesPlayed.equals(other.gamesPlayed); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.playTime, this.gamesPlayed); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "PlaytimeStatsResponse{" + "playTime: " + playTime + ", gamesPlayed: " + gamesPlayed + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional playTime = Optional.empty(); - - private Optional gamesPlayed = Optional.empty(); - - private Builder() { - } - - public Builder from(PlaytimeStatsResponse other) { - playTime(other.getPlayTime()); - gamesPlayed(other.getGamesPlayed()); - return this; - } - - @JsonSetter( - value = "playTime", - nulls = Nulls.SKIP - ) - public Builder playTime(Optional playTime) { - this.playTime = playTime; - return this; - } - - public Builder playTime(Double playTime) { - this.playTime = Optional.of(playTime); - return this; - } - - @JsonSetter( - value = "gamesPlayed", - nulls = Nulls.SKIP - ) - public Builder gamesPlayed(Optional gamesPlayed) { - this.gamesPlayed = gamesPlayed; - return this; - } - - public Builder gamesPlayed(Double gamesPlayed) { - this.gamesPlayed = Optional.of(gamesPlayed); - return this; - } - - public PlaytimeStatsResponse build() { - return new PlaytimeStatsResponse(playTime, gamesPlayed); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/AddOAuthIdentity.java b/src/main/java/com/codecombat/api/client/users/endpoints/AddOAuthIdentity.java deleted file mode 100644 index 37d81e7..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/AddOAuthIdentity.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.AddOAuthIdentityRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class AddOAuthIdentity { - private AddOAuthIdentity() { - } - - public static final class Request { - private final String handle; - - private final AddOAuthIdentityRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, AddOAuthIdentityRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public AddOAuthIdentityRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "AddOAuthIdentity.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(AddOAuthIdentityRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private AddOAuthIdentityRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(AddOAuthIdentityRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/Create.java b/src/main/java/com/codecombat/api/client/users/endpoints/Create.java deleted file mode 100644 index fcf5fd6..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/Create.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.CreateUserRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Create { - private Create() { - } - - public static final class Request { - private final CreateUserRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(CreateUserRequest body, Optional authOverride) { - this.body = body; - this.authOverride = authOverride; - } - - public CreateUserRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Create.Request{" + "body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static BodyStage builder() { - return new Builder(); - } - - public interface BodyStage { - _FinalStage body(CreateUserRequest body); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements BodyStage, _FinalStage { - private CreateUserRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - @Override - public _FinalStage body(CreateUserRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/FindUser.java b/src/main/java/com/codecombat/api/client/users/endpoints/FindUser.java deleted file mode 100644 index 8c961b5..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/FindUser.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class FindUser { - private FindUser() { - } - - public static final class Request { - private final String property; - - private final String value; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String property, String value, Optional authOverride) { - this.property = property; - this.value = value; - this.authOverride = authOverride; - } - - /** - * @return The property to lookup by. May either be "israel-id" or "name". - */ - public String getProperty() { - return property; - } - - /** - * @return The value to be looked up. - */ - public String getValue() { - return value; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return property.equals(other.property) && value.equals(other.value) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.property, this.value, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "FindUser.Request{" + "property: " + property + ", value: " + value + ", authOverride: " + authOverride + "}"; - } - - public static PropertyStage builder() { - return new Builder(); - } - - public interface PropertyStage { - ValueStage property(String property); - - Builder from(Request other); - } - - public interface ValueStage { - _FinalStage value(String value); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements PropertyStage, ValueStage, _FinalStage { - private String property; - - private String value; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - property(other.getProperty()); - value(other.getValue()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The property to lookup by. May either be "israel-id" or "name".

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public ValueStage property(String property) { - this.property = property; - return this; - } - - /** - *

The value to be looked up.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage value(String value) { - this.value = value; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(property, value, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/Get.java b/src/main/java/com/codecombat/api/client/users/endpoints/Get.java deleted file mode 100644 index 35dc39e..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/Get.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Get { - private Get() { - } - - public static final class Request { - private final String handle; - - private final Optional includePlayTime; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, Optional includePlayTime, Optional authOverride) { - this.handle = handle; - this.includePlayTime = includePlayTime; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - /** - * @return Set to non-empty string to include stats.playTime in response - */ - public Optional getIncludePlayTime() { - return includePlayTime; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && includePlayTime.equals(other.includePlayTime) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.includePlayTime, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Get.Request{" + "handle: " + handle + ", includePlayTime: " + includePlayTime + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - _FinalStage handle(String handle); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage includePlayTime(Optional includePlayTime); - - _FinalStage includePlayTime(String includePlayTime); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, _FinalStage { - private String handle; - - private Optional authOverride = Optional.empty(); - - private Optional includePlayTime = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - includePlayTime(other.getIncludePlayTime()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

Set to non-empty string to include stats.playTime in response

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage includePlayTime(String includePlayTime) { - this.includePlayTime = Optional.of(includePlayTime); - return this; - } - - @Override - public _FinalStage includePlayTime(Optional includePlayTime) { - this.includePlayTime = includePlayTime; - return this; - } - - @Override - public Request build() { - return new Request(handle, includePlayTime, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/GetClassrooms.java b/src/main/java/com/codecombat/api/client/users/endpoints/GetClassrooms.java deleted file mode 100644 index 089cd33..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/GetClassrooms.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetClassrooms { - private GetClassrooms() { - } - - public static final class Request { - private final String handle; - - private final Optional retMemberLimit; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, Optional retMemberLimit, Optional authOverride) { - this.handle = handle; - this.retMemberLimit = retMemberLimit; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - /** - * @return limit the return number of members for each classroom - */ - public Optional getRetMemberLimit() { - return retMemberLimit; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && retMemberLimit.equals(other.retMemberLimit) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.retMemberLimit, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetClassrooms.Request{" + "handle: " + handle + ", retMemberLimit: " + retMemberLimit + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - _FinalStage handle(String handle); - - Builder from(Request other); - } - - public interface _FinalStage { - Request build(); - - _FinalStage retMemberLimit(Optional retMemberLimit); - - _FinalStage retMemberLimit(Double retMemberLimit); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, _FinalStage { - private String handle; - - private Optional authOverride = Optional.empty(); - - private Optional retMemberLimit = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - retMemberLimit(other.getRetMemberLimit()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - /** - *

limit the return number of members for each classroom

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage retMemberLimit(Double retMemberLimit) { - this.retMemberLimit = Optional.of(retMemberLimit); - return this; - } - - @Override - public _FinalStage retMemberLimit(Optional retMemberLimit) { - this.retMemberLimit = retMemberLimit; - return this; - } - - @Override - public Request build() { - return new Request(handle, retMemberLimit, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/GetHero.java b/src/main/java/com/codecombat/api/client/users/endpoints/GetHero.java deleted file mode 100644 index 25a7b1c..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/GetHero.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.GetHeroRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GetHero { - private GetHero() { - } - - public static final class Request { - private final String handle; - - private final GetHeroRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, GetHeroRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public GetHeroRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetHero.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(GetHeroRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private GetHeroRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(GetHeroRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/GrantLicense.java b/src/main/java/com/codecombat/api/client/users/endpoints/GrantLicense.java deleted file mode 100644 index f1a94bc..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/GrantLicense.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.GrantLicenseRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class GrantLicense { - private GrantLicense() { - } - - public static final class Request { - private final String handle; - - private final GrantLicenseRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, GrantLicenseRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public GrantLicenseRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GrantLicense.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(GrantLicenseRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private GrantLicenseRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(GrantLicenseRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/SetAceConfig.java b/src/main/java/com/codecombat/api/client/users/endpoints/SetAceConfig.java deleted file mode 100644 index e157fae..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/SetAceConfig.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class SetAceConfig { - private SetAceConfig() { - } - - public static final class Request { - private final String handle; - - private final com.codecombat.api.client.users.types.SetAceConfig body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, com.codecombat.api.client.users.types.SetAceConfig body, - Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public com.codecombat.api.client.users.types.SetAceConfig getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "SetAceConfig.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(com.codecombat.api.client.users.types.SetAceConfig body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private com.codecombat.api.client.users.types.SetAceConfig body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(com.codecombat.api.client.users.types.SetAceConfig body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/ShortenLicense.java b/src/main/java/com/codecombat/api/client/users/endpoints/ShortenLicense.java deleted file mode 100644 index 3b0a25e..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/ShortenLicense.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.ShortenLicenseRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class ShortenLicense { - private ShortenLicense() { - } - - public static final class Request { - private final String handle; - - private final ShortenLicenseRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, ShortenLicenseRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public ShortenLicenseRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ShortenLicense.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(ShortenLicenseRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private ShortenLicenseRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(ShortenLicenseRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/ShortenSubscription.java b/src/main/java/com/codecombat/api/client/users/endpoints/ShortenSubscription.java deleted file mode 100644 index 187afe8..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/ShortenSubscription.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.ShortenSubscriptionRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class ShortenSubscription { - private ShortenSubscription() { - } - - public static final class Request { - private final String handle; - - private final ShortenSubscriptionRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, ShortenSubscriptionRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public ShortenSubscriptionRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ShortenSubscription.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(ShortenSubscriptionRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private ShortenSubscriptionRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(ShortenSubscriptionRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/Update.java b/src/main/java/com/codecombat/api/client/users/endpoints/Update.java deleted file mode 100644 index fecb17a..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/Update.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.UpdateUserRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class Update { - private Update() { - } - - public static final class Request { - private final String handle; - - private final UpdateUserRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, UpdateUserRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public UpdateUserRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "Update.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(UpdateUserRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private UpdateUserRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(UpdateUserRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/endpoints/UpdateSubscription.java b/src/main/java/com/codecombat/api/client/users/endpoints/UpdateSubscription.java deleted file mode 100644 index cc56295..0000000 --- a/src/main/java/com/codecombat/api/client/users/endpoints/UpdateSubscription.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.codecombat.api.client.users.endpoints; - -import com.codecombat.api.client.users.types.UpdateSubscriptionRequest; -import com.codecombat.api.core.BasicAuth; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -public final class UpdateSubscription { - private UpdateSubscription() { - } - - public static final class Request { - private final String handle; - - private final UpdateSubscriptionRequest body; - - private final Optional authOverride; - - private int _cachedHashCode; - - Request(String handle, UpdateSubscriptionRequest body, Optional authOverride) { - this.handle = handle; - this.body = body; - this.authOverride = authOverride; - } - - /** - * @return The document's _id or slug. - */ - public String getHandle() { - return handle; - } - - public UpdateSubscriptionRequest getBody() { - return body; - } - - public Optional getAuthOverride() { - return authOverride; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Request && equalTo((Request) other); - } - - private boolean equalTo(Request other) { - return handle.equals(other.handle) && body.equals(other.body) && authOverride.equals(other.authOverride); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.handle, this.body, this.authOverride); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpdateSubscription.Request{" + "handle: " + handle + ", body: " + body + ", authOverride: " + authOverride + "}"; - } - - public static HandleStage builder() { - return new Builder(); - } - - public interface HandleStage { - BodyStage handle(String handle); - - Builder from(Request other); - } - - public interface BodyStage { - _FinalStage body(UpdateSubscriptionRequest body); - } - - public interface _FinalStage { - Request build(); - - _FinalStage authOverride(Optional authOverride); - - _FinalStage authOverride(BasicAuth authOverride); - } - - public static final class Builder implements HandleStage, BodyStage, _FinalStage { - private String handle; - - private UpdateSubscriptionRequest body; - - private Optional authOverride = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(Request other) { - handle(other.getHandle()); - body(other.getBody()); - authOverride(other.getAuthOverride()); - return this; - } - - /** - *

The document's _id or slug.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public BodyStage handle(String handle) { - this.handle = handle; - return this; - } - - @Override - public _FinalStage body(UpdateSubscriptionRequest body) { - this.body = body; - return this; - } - - @Override - public _FinalStage authOverride(BasicAuth authOverride) { - this.authOverride = Optional.of(authOverride); - return this; - } - - @Override - public _FinalStage authOverride(Optional authOverride) { - this.authOverride = authOverride; - return this; - } - - @Override - public Request build() { - return new Request(handle, body, authOverride); - } - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/AddOAuthIdentityException.java b/src/main/java/com/codecombat/api/client/users/exceptions/AddOAuthIdentityException.java deleted file mode 100644 index 1382834..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/AddOAuthIdentityException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = AddOAuthIdentityException.Deserializer.class -) -public final class AddOAuthIdentityException extends Exception { - private final Value value; - - private int statusCode; - - private AddOAuthIdentityException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static AddOAuthIdentityException other(Object unknownValue, int statusCode) { - return new AddOAuthIdentityException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "AddOAuthIdentityException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public AddOAuthIdentityException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new AddOAuthIdentityException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/CreateException.java b/src/main/java/com/codecombat/api/client/users/exceptions/CreateException.java deleted file mode 100644 index b4c3b6a..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/CreateException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = CreateException.Deserializer.class -) -public final class CreateException extends Exception { - private final Value value; - - private int statusCode; - - private CreateException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static CreateException other(Object unknownValue, int statusCode) { - return new CreateException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "CreateException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public CreateException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new CreateException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/FindUserException.java b/src/main/java/com/codecombat/api/client/users/exceptions/FindUserException.java deleted file mode 100644 index cb561d5..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/FindUserException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = FindUserException.Deserializer.class -) -public final class FindUserException extends Exception { - private final Value value; - - private int statusCode; - - private FindUserException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static FindUserException other(Object unknownValue, int statusCode) { - return new FindUserException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "FindUserException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public FindUserException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new FindUserException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/GetClassroomsException.java b/src/main/java/com/codecombat/api/client/users/exceptions/GetClassroomsException.java deleted file mode 100644 index 2f02479..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/GetClassroomsException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetClassroomsException.Deserializer.class -) -public final class GetClassroomsException extends Exception { - private final Value value; - - private int statusCode; - - private GetClassroomsException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetClassroomsException other(Object unknownValue, int statusCode) { - return new GetClassroomsException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetClassroomsException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetClassroomsException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetClassroomsException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/GetException.java b/src/main/java/com/codecombat/api/client/users/exceptions/GetException.java deleted file mode 100644 index 6be5d48..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/GetException.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetException.Deserializer.class -) -public final class GetException extends Exception { - private final Value value; - - private int statusCode; - - private GetException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetException other(Object unknownValue, int statusCode) { - return new GetException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetException deserialize(JsonParser p, DeserializationContext ctx) throws IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/GetHeroException.java b/src/main/java/com/codecombat/api/client/users/exceptions/GetHeroException.java deleted file mode 100644 index f33fbf1..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/GetHeroException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GetHeroException.Deserializer.class -) -public final class GetHeroException extends Exception { - private final Value value; - - private int statusCode; - - private GetHeroException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GetHeroException other(Object unknownValue, int statusCode) { - return new GetHeroException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GetHeroException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GetHeroException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GetHeroException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/GrantLicenseException.java b/src/main/java/com/codecombat/api/client/users/exceptions/GrantLicenseException.java deleted file mode 100644 index d72671d..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/GrantLicenseException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = GrantLicenseException.Deserializer.class -) -public final class GrantLicenseException extends Exception { - private final Value value; - - private int statusCode; - - private GrantLicenseException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static GrantLicenseException other(Object unknownValue, int statusCode) { - return new GrantLicenseException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "GrantLicenseException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public GrantLicenseException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new GrantLicenseException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/SetAceConfigException.java b/src/main/java/com/codecombat/api/client/users/exceptions/SetAceConfigException.java deleted file mode 100644 index 1508a77..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/SetAceConfigException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = SetAceConfigException.Deserializer.class -) -public final class SetAceConfigException extends Exception { - private final Value value; - - private int statusCode; - - private SetAceConfigException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static SetAceConfigException other(Object unknownValue, int statusCode) { - return new SetAceConfigException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "SetAceConfigException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public SetAceConfigException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new SetAceConfigException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/ShortenLicenseException.java b/src/main/java/com/codecombat/api/client/users/exceptions/ShortenLicenseException.java deleted file mode 100644 index 92264b5..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/ShortenLicenseException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = ShortenLicenseException.Deserializer.class -) -public final class ShortenLicenseException extends Exception { - private final Value value; - - private int statusCode; - - private ShortenLicenseException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static ShortenLicenseException other(Object unknownValue, int statusCode) { - return new ShortenLicenseException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "ShortenLicenseException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public ShortenLicenseException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new ShortenLicenseException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/ShortenSubscriptionException.java b/src/main/java/com/codecombat/api/client/users/exceptions/ShortenSubscriptionException.java deleted file mode 100644 index 7502606..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/ShortenSubscriptionException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = ShortenSubscriptionException.Deserializer.class -) -public final class ShortenSubscriptionException extends Exception { - private final Value value; - - private int statusCode; - - private ShortenSubscriptionException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static ShortenSubscriptionException other(Object unknownValue, int statusCode) { - return new ShortenSubscriptionException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "ShortenSubscriptionException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public ShortenSubscriptionException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new ShortenSubscriptionException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/UpdateException.java b/src/main/java/com/codecombat/api/client/users/exceptions/UpdateException.java deleted file mode 100644 index 41aefaa..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/UpdateException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = UpdateException.Deserializer.class -) -public final class UpdateException extends Exception { - private final Value value; - - private int statusCode; - - private UpdateException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static UpdateException other(Object unknownValue, int statusCode) { - return new UpdateException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "UpdateException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public UpdateException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new UpdateException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/exceptions/UpdateSubscriptionException.java b/src/main/java/com/codecombat/api/client/users/exceptions/UpdateSubscriptionException.java deleted file mode 100644 index 5fa24b5..0000000 --- a/src/main/java/com/codecombat/api/client/users/exceptions/UpdateSubscriptionException.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.codecombat.api.client.users.exceptions; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.io.IOException; -import java.lang.Exception; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - using = UpdateSubscriptionException.Deserializer.class -) -public final class UpdateSubscriptionException extends Exception { - private final Value value; - - private int statusCode; - - private UpdateSubscriptionException(Value value, int statusCode) { - this.value = value; - this.statusCode = statusCode; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public int getStatusCode() { - return this.statusCode; - } - - public static UpdateSubscriptionException other(Object unknownValue, int statusCode) { - return new UpdateSubscriptionException(new UnknownErrorValue(unknownValue), statusCode); - } - - public boolean _isOther() { - return value instanceof UnknownErrorValue; - } - - public Optional _getOther() { - if (_isOther()) { - return Optional.of(((UnknownErrorValue) value).unknownValue); - } - return Optional.empty(); - } - - public interface Visitor { - T _visitOther(Object otherType); - } - - @JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "_error", - visible = true, - defaultImpl = UnknownErrorValue.class - ) - @JsonIgnoreProperties( - ignoreUnknown = true - ) - private interface Value { - T visit(Visitor visitor); - } - - private static final class UnknownErrorValue implements Value { - private Object unknownValue; - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - UnknownErrorValue(@JsonProperty("unknownValue") Object unknownValue) { - this.unknownValue = unknownValue; - } - - @Override - public T visit(Visitor visitor) { - return visitor._visitOther(unknownValue); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UnknownErrorValue && equalTo((UnknownErrorValue) other); - } - - private boolean equalTo(UnknownErrorValue other) { - return unknownValue.equals(other.unknownValue); - } - - @Override - public int hashCode() { - return Objects.hash(this.unknownValue); - } - - @Override - public String toString() { - return "UpdateSubscriptionException{" + "unknownValue: " + unknownValue + "}"; - } - } - - static final class Deserializer extends JsonDeserializer { - @Override - public UpdateSubscriptionException deserialize(JsonParser p, DeserializationContext ctx) throws - IOException { - Value value = ctx.readValue(p, Value.class); - int statusCode = (int) ctx.getAttribute("statusCode"); - return new UpdateSubscriptionException(value, statusCode); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/AddOAuthIdentityRequest.java b/src/main/java/com/codecombat/api/client/users/types/AddOAuthIdentityRequest.java deleted file mode 100644 index b9580cb..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/AddOAuthIdentityRequest.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = AddOAuthIdentityRequest.Builder.class -) -public final class AddOAuthIdentityRequest { - private final String provider; - - private final Optional accessToken; - - private final Optional code; - - private int _cachedHashCode; - - AddOAuthIdentityRequest(String provider, Optional accessToken, Optional code) { - this.provider = provider; - this.accessToken = accessToken; - this.code = code; - } - - /** - * @return Your OAuth Provider ID. - */ - @JsonProperty("provider") - public String getProvider() { - return provider; - } - - /** - * @return Will be passed through your lookup URL to get the user ID. Required if no code. - */ - @JsonProperty("accessToken") - public Optional getAccessToken() { - return accessToken; - } - - /** - * @return Will be passed to the OAuth token endpoint to get a token. Required if no accessToken. - */ - @JsonProperty("code") - public Optional getCode() { - return code; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddOAuthIdentityRequest && equalTo((AddOAuthIdentityRequest) other); - } - - private boolean equalTo(AddOAuthIdentityRequest other) { - return provider.equals(other.provider) && accessToken.equals(other.accessToken) && code.equals(other.code); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.provider, this.accessToken, this.code); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "AddOAuthIdentityRequest{" + "provider: " + provider + ", accessToken: " + accessToken + ", code: " + code + "}"; - } - - public static ProviderStage builder() { - return new Builder(); - } - - public interface ProviderStage { - _FinalStage provider(String provider); - - Builder from(AddOAuthIdentityRequest other); - } - - public interface _FinalStage { - AddOAuthIdentityRequest build(); - - _FinalStage accessToken(Optional accessToken); - - _FinalStage accessToken(String accessToken); - - _FinalStage code(Optional code); - - _FinalStage code(String code); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements ProviderStage, _FinalStage { - private String provider; - - private Optional code = Optional.empty(); - - private Optional accessToken = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(AddOAuthIdentityRequest other) { - provider(other.getProvider()); - accessToken(other.getAccessToken()); - code(other.getCode()); - return this; - } - - /** - *

Your OAuth Provider ID.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("provider") - public _FinalStage provider(String provider) { - this.provider = provider; - return this; - } - - /** - *

Will be passed to the OAuth token endpoint to get a token. Required if no accessToken.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage code(String code) { - this.code = Optional.of(code); - return this; - } - - @Override - @JsonSetter( - value = "code", - nulls = Nulls.SKIP - ) - public _FinalStage code(Optional code) { - this.code = code; - return this; - } - - /** - *

Will be passed through your lookup URL to get the user ID. Required if no code.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage accessToken(String accessToken) { - this.accessToken = Optional.of(accessToken); - return this; - } - - @Override - @JsonSetter( - value = "accessToken", - nulls = Nulls.SKIP - ) - public _FinalStage accessToken(Optional accessToken) { - this.accessToken = accessToken; - return this; - } - - @Override - public AddOAuthIdentityRequest build() { - return new AddOAuthIdentityRequest(provider, accessToken, code); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/CreateUserRequest.java b/src/main/java/com/codecombat/api/client/users/types/CreateUserRequest.java deleted file mode 100644 index c5560e8..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/CreateUserRequest.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = CreateUserRequest.Builder.class -) -public final class CreateUserRequest { - private final String name; - - private final String email; - - private final Optional role; - - private final Optional preferredLanguage; - - private final Optional heroConfig; - - private final Optional birthday; - - private int _cachedHashCode; - - CreateUserRequest(String name, String email, Optional role, - Optional preferredLanguage, Optional heroConfig, - Optional birthday) { - this.name = name; - this.email = email; - this.role = role; - this.preferredLanguage = preferredLanguage; - this.heroConfig = heroConfig; - this.birthday = birthday; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - /** - * @return A "student" or "teacher". If unset, a home user will be created, unable to join classrooms. - */ - @JsonProperty("role") - public Optional getRole() { - return role; - } - - @JsonProperty("preferredLanguage") - public Optional getPreferredLanguage() { - return preferredLanguage; - } - - @JsonProperty("heroConfig") - public Optional getHeroConfig() { - return heroConfig; - } - - @JsonProperty("birthday") - public Optional getBirthday() { - return birthday; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof CreateUserRequest && equalTo((CreateUserRequest) other); - } - - private boolean equalTo(CreateUserRequest other) { - return name.equals(other.name) && email.equals(other.email) && role.equals(other.role) && preferredLanguage.equals(other.preferredLanguage) && heroConfig.equals(other.heroConfig) && birthday.equals(other.birthday); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.name, this.email, this.role, this.preferredLanguage, this.heroConfig, this.birthday); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "CreateUserRequest{" + "name: " + name + ", email: " + email + ", role: " + role + ", preferredLanguage: " + preferredLanguage + ", heroConfig: " + heroConfig + ", birthday: " + birthday + "}"; - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - EmailStage name(String name); - - Builder from(CreateUserRequest other); - } - - public interface EmailStage { - _FinalStage email(String email); - } - - public interface _FinalStage { - CreateUserRequest build(); - - _FinalStage role(Optional role); - - _FinalStage role(UserRole role); - - _FinalStage preferredLanguage(Optional preferredLanguage); - - _FinalStage preferredLanguage(String preferredLanguage); - - _FinalStage heroConfig(Optional heroConfig); - - _FinalStage heroConfig(HeroConfig heroConfig); - - _FinalStage birthday(Optional birthday); - - _FinalStage birthday(String birthday); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements NameStage, EmailStage, _FinalStage { - private String name; - - private String email; - - private Optional birthday = Optional.empty(); - - private Optional heroConfig = Optional.empty(); - - private Optional preferredLanguage = Optional.empty(); - - private Optional role = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(CreateUserRequest other) { - name(other.getName()); - email(other.getEmail()); - role(other.getRole()); - preferredLanguage(other.getPreferredLanguage()); - heroConfig(other.getHeroConfig()); - birthday(other.getBirthday()); - return this; - } - - @Override - @JsonSetter("name") - public EmailStage name(String name) { - this.name = name; - return this; - } - - @Override - @JsonSetter("email") - public _FinalStage email(String email) { - this.email = email; - return this; - } - - @Override - public _FinalStage birthday(String birthday) { - this.birthday = Optional.of(birthday); - return this; - } - - @Override - @JsonSetter( - value = "birthday", - nulls = Nulls.SKIP - ) - public _FinalStage birthday(Optional birthday) { - this.birthday = birthday; - return this; - } - - @Override - public _FinalStage heroConfig(HeroConfig heroConfig) { - this.heroConfig = Optional.of(heroConfig); - return this; - } - - @Override - @JsonSetter( - value = "heroConfig", - nulls = Nulls.SKIP - ) - public _FinalStage heroConfig(Optional heroConfig) { - this.heroConfig = heroConfig; - return this; - } - - @Override - public _FinalStage preferredLanguage(String preferredLanguage) { - this.preferredLanguage = Optional.of(preferredLanguage); - return this; - } - - @Override - @JsonSetter( - value = "preferredLanguage", - nulls = Nulls.SKIP - ) - public _FinalStage preferredLanguage(Optional preferredLanguage) { - this.preferredLanguage = preferredLanguage; - return this; - } - - /** - *

A "student" or "teacher". If unset, a home user will be created, unable to join classrooms.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage role(UserRole role) { - this.role = Optional.of(role); - return this; - } - - @Override - @JsonSetter( - value = "role", - nulls = Nulls.SKIP - ) - public _FinalStage role(Optional role) { - this.role = role; - return this; - } - - @Override - public CreateUserRequest build() { - return new CreateUserRequest(name, email, role, preferredLanguage, heroConfig, birthday); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/GetHeroRequest.java b/src/main/java/com/codecombat/api/client/users/types/GetHeroRequest.java deleted file mode 100644 index 0ac54b3..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/GetHeroRequest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = GetHeroRequest.Builder.class -) -public final class GetHeroRequest { - private final Optional thangType; - - private int _cachedHashCode; - - GetHeroRequest(Optional thangType) { - this.thangType = thangType; - } - - @JsonProperty("thangType") - public Optional getThangType() { - return thangType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetHeroRequest && equalTo((GetHeroRequest) other); - } - - private boolean equalTo(GetHeroRequest other) { - return thangType.equals(other.thangType); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.thangType); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GetHeroRequest{" + "thangType: " + thangType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional thangType = Optional.empty(); - - private Builder() { - } - - public Builder from(GetHeroRequest other) { - thangType(other.getThangType()); - return this; - } - - @JsonSetter( - value = "thangType", - nulls = Nulls.SKIP - ) - public Builder thangType(Optional thangType) { - this.thangType = thangType; - return this; - } - - public Builder thangType(String thangType) { - this.thangType = Optional.of(thangType); - return this; - } - - public GetHeroRequest build() { - return new GetHeroRequest(thangType); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/GrantLicenseRequest.java b/src/main/java/com/codecombat/api/client/users/types/GrantLicenseRequest.java deleted file mode 100644 index 5cdebf8..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/GrantLicenseRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = GrantLicenseRequest.Builder.class -) -public final class GrantLicenseRequest { - private final String ends; - - private int _cachedHashCode; - - GrantLicenseRequest(String ends) { - this.ends = ends; - } - - @JsonProperty("ends") - public String getEnds() { - return ends; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GrantLicenseRequest && equalTo((GrantLicenseRequest) other); - } - - private boolean equalTo(GrantLicenseRequest other) { - return ends.equals(other.ends); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "GrantLicenseRequest{" + "ends: " + ends + "}"; - } - - public static EndsStage builder() { - return new Builder(); - } - - public interface EndsStage { - _FinalStage ends(String ends); - - Builder from(GrantLicenseRequest other); - } - - public interface _FinalStage { - GrantLicenseRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements EndsStage, _FinalStage { - private String ends; - - private Builder() { - } - - @Override - public Builder from(GrantLicenseRequest other) { - ends(other.getEnds()); - return this; - } - - @Override - @JsonSetter("ends") - public _FinalStage ends(String ends) { - this.ends = ends; - return this; - } - - @Override - public GrantLicenseRequest build() { - return new GrantLicenseRequest(ends); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/HeroConfig.java b/src/main/java/com/codecombat/api/client/users/types/HeroConfig.java deleted file mode 100644 index ff843d7..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/HeroConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = HeroConfig.Builder.class -) -public final class HeroConfig { - private final Optional thangType; - - private int _cachedHashCode; - - HeroConfig(Optional thangType) { - this.thangType = thangType; - } - - @JsonProperty("thangType") - public Optional getThangType() { - return thangType; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof HeroConfig && equalTo((HeroConfig) other); - } - - private boolean equalTo(HeroConfig other) { - return thangType.equals(other.thangType); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.thangType); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "HeroConfig{" + "thangType: " + thangType + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional thangType = Optional.empty(); - - private Builder() { - } - - public Builder from(HeroConfig other) { - thangType(other.getThangType()); - return this; - } - - @JsonSetter( - value = "thangType", - nulls = Nulls.SKIP - ) - public Builder thangType(Optional thangType) { - this.thangType = thangType; - return this; - } - - public Builder thangType(String thangType) { - this.thangType = Optional.of(thangType); - return this; - } - - public HeroConfig build() { - return new HeroConfig(thangType); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/SetAceConfig.java b/src/main/java/com/codecombat/api/client/users/types/SetAceConfig.java deleted file mode 100644 index 62408bb..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/SetAceConfig.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Boolean; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = SetAceConfig.Builder.class -) -public final class SetAceConfig { - private final Optional liveCompletion; - - private final Optional behaviors; - - private final Optional language; - - private int _cachedHashCode; - - SetAceConfig(Optional liveCompletion, Optional behaviors, - Optional language) { - this.liveCompletion = liveCompletion; - this.behaviors = behaviors; - this.language = language; - } - - /** - * @return controls whether autocompletion snippets show up, the default value is true - */ - @JsonProperty("liveCompletion") - public Optional getLiveCompletion() { - return liveCompletion; - } - - /** - * @return controls whether things like automatic parenthesis and quote completion happens, the default value is false - */ - @JsonProperty("behaviors") - public Optional getBehaviors() { - return behaviors; - } - - /** - * @return only for home users, should be one of ["python", "javascript", "cpp", "lua", "coffeescript"] right now - */ - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SetAceConfig && equalTo((SetAceConfig) other); - } - - private boolean equalTo(SetAceConfig other) { - return liveCompletion.equals(other.liveCompletion) && behaviors.equals(other.behaviors) && language.equals(other.language); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.liveCompletion, this.behaviors, this.language); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "SetAceConfig{" + "liveCompletion: " + liveCompletion + ", behaviors: " + behaviors + ", language: " + language + "}"; - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder { - private Optional liveCompletion = Optional.empty(); - - private Optional behaviors = Optional.empty(); - - private Optional language = Optional.empty(); - - private Builder() { - } - - public Builder from(SetAceConfig other) { - liveCompletion(other.getLiveCompletion()); - behaviors(other.getBehaviors()); - language(other.getLanguage()); - return this; - } - - @JsonSetter( - value = "liveCompletion", - nulls = Nulls.SKIP - ) - public Builder liveCompletion(Optional liveCompletion) { - this.liveCompletion = liveCompletion; - return this; - } - - public Builder liveCompletion(Boolean liveCompletion) { - this.liveCompletion = Optional.of(liveCompletion); - return this; - } - - @JsonSetter( - value = "behaviors", - nulls = Nulls.SKIP - ) - public Builder behaviors(Optional behaviors) { - this.behaviors = behaviors; - return this; - } - - public Builder behaviors(Boolean behaviors) { - this.behaviors = Optional.of(behaviors); - return this; - } - - @JsonSetter( - value = "language", - nulls = Nulls.SKIP - ) - public Builder language(Optional language) { - this.language = language; - return this; - } - - public Builder language(String language) { - this.language = Optional.of(language); - return this; - } - - public SetAceConfig build() { - return new SetAceConfig(liveCompletion, behaviors, language); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/ShortenLicenseRequest.java b/src/main/java/com/codecombat/api/client/users/types/ShortenLicenseRequest.java deleted file mode 100644 index 62d7378..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/ShortenLicenseRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = ShortenLicenseRequest.Builder.class -) -public final class ShortenLicenseRequest { - private final String ends; - - private int _cachedHashCode; - - ShortenLicenseRequest(String ends) { - this.ends = ends; - } - - @JsonProperty("ends") - public String getEnds() { - return ends; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ShortenLicenseRequest && equalTo((ShortenLicenseRequest) other); - } - - private boolean equalTo(ShortenLicenseRequest other) { - return ends.equals(other.ends); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ShortenLicenseRequest{" + "ends: " + ends + "}"; - } - - public static EndsStage builder() { - return new Builder(); - } - - public interface EndsStage { - _FinalStage ends(String ends); - - Builder from(ShortenLicenseRequest other); - } - - public interface _FinalStage { - ShortenLicenseRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements EndsStage, _FinalStage { - private String ends; - - private Builder() { - } - - @Override - public Builder from(ShortenLicenseRequest other) { - ends(other.getEnds()); - return this; - } - - @Override - @JsonSetter("ends") - public _FinalStage ends(String ends) { - this.ends = ends; - return this; - } - - @Override - public ShortenLicenseRequest build() { - return new ShortenLicenseRequest(ends); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/ShortenSubscriptionRequest.java b/src/main/java/com/codecombat/api/client/users/types/ShortenSubscriptionRequest.java deleted file mode 100644 index 6c0ccb6..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/ShortenSubscriptionRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = ShortenSubscriptionRequest.Builder.class -) -public final class ShortenSubscriptionRequest { - private final String ends; - - private int _cachedHashCode; - - ShortenSubscriptionRequest(String ends) { - this.ends = ends; - } - - @JsonProperty("ends") - public String getEnds() { - return ends; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ShortenSubscriptionRequest && equalTo((ShortenSubscriptionRequest) other); - } - - private boolean equalTo(ShortenSubscriptionRequest other) { - return ends.equals(other.ends); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "ShortenSubscriptionRequest{" + "ends: " + ends + "}"; - } - - public static EndsStage builder() { - return new Builder(); - } - - public interface EndsStage { - _FinalStage ends(String ends); - - Builder from(ShortenSubscriptionRequest other); - } - - public interface _FinalStage { - ShortenSubscriptionRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements EndsStage, _FinalStage { - private String ends; - - private Builder() { - } - - @Override - public Builder from(ShortenSubscriptionRequest other) { - ends(other.getEnds()); - return this; - } - - @Override - @JsonSetter("ends") - public _FinalStage ends(String ends) { - this.ends = ends; - return this; - } - - @Override - public ShortenSubscriptionRequest build() { - return new ShortenSubscriptionRequest(ends); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/UpdateSubscriptionRequest.java b/src/main/java/com/codecombat/api/client/users/types/UpdateSubscriptionRequest.java deleted file mode 100644 index 184932b..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/UpdateSubscriptionRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; - -@JsonDeserialize( - builder = UpdateSubscriptionRequest.Builder.class -) -public final class UpdateSubscriptionRequest { - private final String ends; - - private int _cachedHashCode; - - UpdateSubscriptionRequest(String ends) { - this.ends = ends; - } - - @JsonProperty("ends") - public String getEnds() { - return ends; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpdateSubscriptionRequest && equalTo((UpdateSubscriptionRequest) other); - } - - private boolean equalTo(UpdateSubscriptionRequest other) { - return ends.equals(other.ends); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.ends); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpdateSubscriptionRequest{" + "ends: " + ends + "}"; - } - - public static EndsStage builder() { - return new Builder(); - } - - public interface EndsStage { - _FinalStage ends(String ends); - - Builder from(UpdateSubscriptionRequest other); - } - - public interface _FinalStage { - UpdateSubscriptionRequest build(); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements EndsStage, _FinalStage { - private String ends; - - private Builder() { - } - - @Override - public Builder from(UpdateSubscriptionRequest other) { - ends(other.getEnds()); - return this; - } - - @Override - @JsonSetter("ends") - public _FinalStage ends(String ends) { - this.ends = ends; - return this; - } - - @Override - public UpdateSubscriptionRequest build() { - return new UpdateSubscriptionRequest(ends); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/UpdateUserRequest.java b/src/main/java/com/codecombat/api/client/users/types/UpdateUserRequest.java deleted file mode 100644 index a209290..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/UpdateUserRequest.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Optional; - -@JsonDeserialize( - builder = UpdateUserRequest.Builder.class -) -public final class UpdateUserRequest { - private final String name; - - private final Optional birthday; - - private int _cachedHashCode; - - UpdateUserRequest(String name, Optional birthday) { - this.name = name; - this.birthday = birthday; - } - - /** - * @return Set to new name string - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return Set the birthday - */ - @JsonProperty("birthday") - public Optional getBirthday() { - return birthday; - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UpdateUserRequest && equalTo((UpdateUserRequest) other); - } - - private boolean equalTo(UpdateUserRequest other) { - return name.equals(other.name) && birthday.equals(other.birthday); - } - - @Override - public int hashCode() { - if (_cachedHashCode == 0) { - _cachedHashCode = Objects.hash(this.name, this.birthday); - } - return _cachedHashCode; - } - - @Override - public String toString() { - return "UpdateUserRequest{" + "name: " + name + ", birthday: " + birthday + "}"; - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - _FinalStage name(String name); - - Builder from(UpdateUserRequest other); - } - - public interface _FinalStage { - UpdateUserRequest build(); - - _FinalStage birthday(Optional birthday); - - _FinalStage birthday(String birthday); - } - - @JsonIgnoreProperties( - ignoreUnknown = true - ) - public static final class Builder implements NameStage, _FinalStage { - private String name; - - private Optional birthday = Optional.empty(); - - private Builder() { - } - - @Override - public Builder from(UpdateUserRequest other) { - name(other.getName()); - birthday(other.getBirthday()); - return this; - } - - /** - *

Set to new name string

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - /** - *

Set the birthday

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @Override - public _FinalStage birthday(String birthday) { - this.birthday = Optional.of(birthday); - return this; - } - - @Override - @JsonSetter( - value = "birthday", - nulls = Nulls.SKIP - ) - public _FinalStage birthday(Optional birthday) { - this.birthday = birthday; - return this; - } - - @Override - public UpdateUserRequest build() { - return new UpdateUserRequest(name, birthday); - } - } -} diff --git a/src/main/java/com/codecombat/api/client/users/types/UserRole.java b/src/main/java/com/codecombat/api/client/users/types/UserRole.java deleted file mode 100644 index 30bcad7..0000000 --- a/src/main/java/com/codecombat/api/client/users/types/UserRole.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.codecombat.api.client.users.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Locale; - -public final class UserRole { - public static final UserRole TEACHER = new UserRole(Value.TEACHER, "teacher"); - - public static final UserRole STUDENT = new UserRole(Value.STUDENT, "student"); - - private final Value value; - - private final String string; - - UserRole(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @Override - @JsonValue - public String toString() { - return this.string; - } - - @Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof UserRole && this.string.equals(((UserRole) other).string)); - } - - @Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case TEACHER: - return visitor.visitTeacher(); - case STUDENT: - return visitor.visitStudent(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator( - mode = JsonCreator.Mode.DELEGATING - ) - public static UserRole valueOf(String value) { - String upperCasedValue = value.toUpperCase(Locale.ROOT); - switch (upperCasedValue) { - case "teacher": - return TEACHER; - case "student": - return STUDENT; - default: - return new UserRole(Value.UNKNOWN, upperCasedValue); - } - } - - public enum Value { - STUDENT, - - TEACHER, - - UNKNOWN - } - - public interface Visitor { - T visitStudent(); - - T visitTeacher(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/codecombat/api/client/users/usersService.java b/src/main/java/com/codecombat/api/client/users/usersService.java deleted file mode 100644 index 02061bf..0000000 --- a/src/main/java/com/codecombat/api/client/users/usersService.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.codecombat.api.client.users; - -import com.codecombat.api.client.commons.types.ClassroomResponseWithCode; -import com.codecombat.api.client.commons.types.UserResponse; -import com.codecombat.api.client.users.exceptions.AddOAuthIdentityException; -import com.codecombat.api.client.users.exceptions.CreateException; -import com.codecombat.api.client.users.exceptions.FindUserException; -import com.codecombat.api.client.users.exceptions.GetClassroomsException; -import com.codecombat.api.client.users.exceptions.GetException; -import com.codecombat.api.client.users.exceptions.GetHeroException; -import com.codecombat.api.client.users.exceptions.GrantLicenseException; -import com.codecombat.api.client.users.exceptions.SetAceConfigException; -import com.codecombat.api.client.users.exceptions.ShortenLicenseException; -import com.codecombat.api.client.users.exceptions.ShortenSubscriptionException; -import com.codecombat.api.client.users.exceptions.UpdateException; -import com.codecombat.api.client.users.exceptions.UpdateSubscriptionException; -import com.codecombat.api.client.users.types.AddOAuthIdentityRequest; -import com.codecombat.api.client.users.types.CreateUserRequest; -import com.codecombat.api.client.users.types.GetHeroRequest; -import com.codecombat.api.client.users.types.GrantLicenseRequest; -import com.codecombat.api.client.users.types.SetAceConfig; -import com.codecombat.api.client.users.types.ShortenLicenseRequest; -import com.codecombat.api.client.users.types.ShortenSubscriptionRequest; -import com.codecombat.api.client.users.types.UpdateSubscriptionRequest; -import com.codecombat.api.client.users.types.UpdateUserRequest; -import com.codecombat.api.core.BasicAuth; -import com.codecombat.api.core.ObjectMappers; -import com.fern.java.jersey.contracts.OptionalAwareContract; -import feign.Feign; -import feign.jackson.JacksonDecoder; -import feign.jackson.JacksonEncoder; -import feign.jaxrs.JAXRSContract; -import java.lang.Double; -import java.lang.String; -import java.util.List; -import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Path("/") -interface usersService { - @POST - @Path("/users") - void create(@HeaderParam("Authorization") BasicAuth auth, CreateUserRequest body) throws - CreateException; - - @GET - @Path("/users/{handle}") - UserResponse get(@HeaderParam("Authorization") BasicAuth auth, @PathParam("handle") String handle, - @QueryParam("includePlayTime") Optional includePlayTime) throws GetException; - - @PUT - @Path("/users/{handle}") - UserResponse update(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, UpdateUserRequest body) throws UpdateException; - - @GET - @Path("/users/{handle}/classrooms") - List getClassrooms(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, - @QueryParam("retMemberLimit") Optional retMemberLimit) throws GetClassroomsException; - - @PUT - @Path("/users/{handle}/hero-config") - UserResponse getHero(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, GetHeroRequest body) throws GetHeroException; - - @PUT - @Path("/users/{handle}/ace-config") - UserResponse setAceConfig(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, SetAceConfig body) throws SetAceConfigException; - - @POST - @Path("/users/{handle}/o-auth-identities") - UserResponse addOAuthIdentity(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, AddOAuthIdentityRequest body) throws - AddOAuthIdentityException; - - @PUT - @Path("/users/{handle}/subscription") - UserResponse updateSubscription(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, UpdateSubscriptionRequest body) throws - UpdateSubscriptionException; - - @PUT - @Path("/users/{handle}/shorten-subscription") - UserResponse shortenSubscription(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, ShortenSubscriptionRequest body) throws - ShortenSubscriptionException; - - @PUT - @Path("/users/{handle}/license") - UserResponse grantLicense(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, GrantLicenseRequest body) throws GrantLicenseException; - - @PUT - @Path("/users/{handle}/shorten-license") - UserResponse shortenLicense(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("handle") String handle, ShortenLicenseRequest body) throws - ShortenLicenseException; - - @GET - @Path("/user-lookup/{property}/{value}") - void findUser(@HeaderParam("Authorization") BasicAuth auth, - @PathParam("property") String property, @PathParam("value") String value) throws - FindUserException; - - static usersService getClient(String url) { - return Feign.builder() - .contract(new OptionalAwareContract(new JAXRSContract())) - .decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER)) - .encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER)) - .errorDecoder(new usersServiceErrorDecoder()).target(usersService.class, url); - } -} diff --git a/src/main/java/com/codecombat/api/client/users/usersServiceClient.java b/src/main/java/com/codecombat/api/client/users/usersServiceClient.java deleted file mode 100644 index 50b3a3c..0000000 --- a/src/main/java/com/codecombat/api/client/users/usersServiceClient.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.codecombat.api.client.users; - -import com.codecombat.api.client.commons.types.ClassroomResponseWithCode; -import com.codecombat.api.client.commons.types.UserResponse; -import com.codecombat.api.client.users.endpoints.AddOAuthIdentity; -import com.codecombat.api.client.users.endpoints.Create; -import com.codecombat.api.client.users.endpoints.FindUser; -import com.codecombat.api.client.users.endpoints.Get; -import com.codecombat.api.client.users.endpoints.GetClassrooms; -import com.codecombat.api.client.users.endpoints.GetHero; -import com.codecombat.api.client.users.endpoints.GrantLicense; -import com.codecombat.api.client.users.endpoints.SetAceConfig; -import com.codecombat.api.client.users.endpoints.ShortenLicense; -import com.codecombat.api.client.users.endpoints.ShortenSubscription; -import com.codecombat.api.client.users.endpoints.Update; -import com.codecombat.api.client.users.endpoints.UpdateSubscription; -import com.codecombat.api.client.users.exceptions.AddOAuthIdentityException; -import com.codecombat.api.client.users.exceptions.CreateException; -import com.codecombat.api.client.users.exceptions.FindUserException; -import com.codecombat.api.client.users.exceptions.GetClassroomsException; -import com.codecombat.api.client.users.exceptions.GetException; -import com.codecombat.api.client.users.exceptions.GetHeroException; -import com.codecombat.api.client.users.exceptions.GrantLicenseException; -import com.codecombat.api.client.users.exceptions.SetAceConfigException; -import com.codecombat.api.client.users.exceptions.ShortenLicenseException; -import com.codecombat.api.client.users.exceptions.ShortenSubscriptionException; -import com.codecombat.api.client.users.exceptions.UpdateException; -import com.codecombat.api.client.users.exceptions.UpdateSubscriptionException; -import com.codecombat.api.core.BasicAuth; -import java.lang.RuntimeException; -import java.lang.String; -import java.util.List; -import java.util.Optional; - -public final class usersServiceClient { - private final usersService service; - - private final Optional auth; - - public usersServiceClient(String url) { - this.service = usersService.getClient(url); - this.auth = Optional.empty(); - } - - public usersServiceClient(String url, BasicAuth auth) { - this.service = usersService.getClient(url); - this.auth = Optional.of(auth); - } - - /** - *

Creates a User.

- *

Example

- *
url = 'https://codecombat.com/api/users'
-   * json = { email: 'an@email.com', name: 'Some Username', role: 'student' }
-   * request.post({ url, json, auth })
-   * 
- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws CreateException Exception that wraps all possible endpoint errors - */ - public void create(Create.Request request) throws CreateException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - this.service.create(authValue, request.getBody()); - } - - /** - *

Returns a User.

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse get(Get.Request request) throws GetException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.get(authValue, request.getHandle(), request.getIncludePlayTime()); - } - - /** - *

Modify name of a User

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws UpdateException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse update(Update.Request request) throws UpdateException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.update(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Returns a list of Classrooms this user is in (if a student) or owns (if a teacher).

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws GetClassroomsException Exception that wraps all possible endpoint errors - * @return List - */ - public List getClassrooms(GetClassrooms.Request request) throws - GetClassroomsException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getClassrooms(authValue, request.getHandle(), request.getRetMemberLimit()); - } - - /** - *

Set the user's hero.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws GetHeroException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse getHero(GetHero.Request request) throws GetHeroException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.getHero(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Set the user's aceConfig (the settings for the in-game Ace code editor), such as whether to enable autocomplete.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws SetAceConfigException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse setAceConfig(SetAceConfig.Request request) throws SetAceConfigException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.setAceConfig(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Adds an OAuth2 identity to the user, so that they can be logged in with that identity. You need to send the OAuth code or the access token to this endpoint. 1. If no access token is provided, it will use your OAuth2 token URL to exchange the given code for an access token. 1. Then it will use the access token (given by you, or received from step 1) to look up the user on your service using the lookup URL, and expects a JSON object in response with an id property. 1. It will then save that user id to the user in our db as a new OAuthIdentity. #### Example javascript url = `https://codecombat.com/api/users/${userID}/o-auth-identities` OAUTH_PROVIDER_ID = 'xyz' json = { provider: OAUTH_PROVIDER_ID, accessToken: '1234' } request.post({ url, json, auth}, (err, res) => { console.log(res.body.oAuthIdentities) // [ { provider: 'xyx', id: 'abcd' } ] }) In this example, we call your lookup URL (let's say, https://oauth.provider/user?t=<%= accessToken %>) with the access token (1234). The lookup URL returns { id: 'abcd' } in this case, which we save to the user in our db.

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws AddOAuthIdentityException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse addOAuthIdentity(AddOAuthIdentity.Request request) throws - AddOAuthIdentityException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.addOAuthIdentity(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Grants a user premium access to the "Home" version up to a certain time.

- *

Example

- *
url = `https://codecombat.com/api/users/${userID}/subscription`
-   * json = { ends: new Date('2017-01-01').toISOString() }
-   * request.put({ url, json, auth }, (err, res) => {
-   *   console.log(res.body.subscription) // { ends: '2017-01-01T00:00:00.000Z', active: true }
-   * })
-   * 
- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws UpdateSubscriptionException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse updateSubscription(UpdateSubscription.Request request) throws - UpdateSubscriptionException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.updateSubscription(authValue, request.getHandle(), request.getBody()); - } - - /** - *

If the user already has a premium access up to a certain time, this shortens/revokes his/her premium access. If the ends is less than or equal to the current time, it revokes the subscription and sets the end date to be the current time, else it just shortens the subscription. #### Example javascript url = `https://codecombat.com/api/users/${userID}/shorten-subscription` json = { ends: new Date().toISOString() } request.put({ url, json, auth }, (err, res) => { console.log(res.body.subscription.active) // false })

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws ShortenSubscriptionException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse shortenSubscription(ShortenSubscription.Request request) throws - ShortenSubscriptionException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.shortenSubscription(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Grants a user access to the "Classroom" version up to a certain time. - * Sets their role to "student".

- *

Example

- *
url = `https://codecombat.com/api/users/${userID}/license`
-   * json = { ends: new Date('2017-01-01').toISOString() }
-   * request.put({ url, json, auth }, (err, res) => {
-   *   console.log(res.body.license) // { ends: '2017-01-01T00:00:00.000Z', active: true }
-   * })
-   * 
- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws GrantLicenseException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse grantLicense(GrantLicense.Request request) throws GrantLicenseException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.grantLicense(authValue, request.getHandle(), request.getBody()); - } - - /** - *

If the user already has access to the "Classroom" version up to a certain time, this shortens/revokes his/her access. If the ends is less than or equal to the current time, it revokes the enrollment and sets the end date to be the current time, else it just shortens the enrollment. #### Example javascript url = `https://codecombat.com/api/users/${userID}/shorten-license` json = { ends: new Date().toISOString() } request.put({ url, json, auth }, (err, res) => { console.log(res.body.license.active) // false })

- * @param request Wrapper object for the request body that includes any path parameters, query parameters, and headers - * @throws ShortenLicenseException Exception that wraps all possible endpoint errors - * @return UserResponse - */ - public UserResponse shortenLicense(ShortenLicense.Request request) throws - ShortenLicenseException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - return this.service.shortenLicense(authValue, request.getHandle(), request.getBody()); - } - - /** - *

Redirects to /users/{handle} given a unique, identifying property

- * @param request Wrapper object that includes any path parameters, query parameters, and headers - * @throws FindUserException Exception that wraps all possible endpoint errors - */ - public void findUser(FindUser.Request request) throws FindUserException { - BasicAuth authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required"))); - this.service.findUser(authValue, request.getProperty(), request.getValue()); - } -} diff --git a/src/main/java/com/codecombat/api/client/users/usersServiceErrorDecoder.java b/src/main/java/com/codecombat/api/client/users/usersServiceErrorDecoder.java deleted file mode 100644 index e65ab10..0000000 --- a/src/main/java/com/codecombat/api/client/users/usersServiceErrorDecoder.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.codecombat.api.client.users; - -import com.codecombat.api.client.users.exceptions.AddOAuthIdentityException; -import com.codecombat.api.client.users.exceptions.CreateException; -import com.codecombat.api.client.users.exceptions.FindUserException; -import com.codecombat.api.client.users.exceptions.GetClassroomsException; -import com.codecombat.api.client.users.exceptions.GetException; -import com.codecombat.api.client.users.exceptions.GetHeroException; -import com.codecombat.api.client.users.exceptions.GrantLicenseException; -import com.codecombat.api.client.users.exceptions.SetAceConfigException; -import com.codecombat.api.client.users.exceptions.ShortenLicenseException; -import com.codecombat.api.client.users.exceptions.ShortenSubscriptionException; -import com.codecombat.api.client.users.exceptions.UpdateException; -import com.codecombat.api.client.users.exceptions.UpdateSubscriptionException; -import com.codecombat.api.core.ObjectMappers; -import feign.Response; -import feign.codec.ErrorDecoder; -import java.io.IOException; -import java.lang.Class; -import java.lang.Exception; -import java.lang.Override; -import java.lang.RuntimeException; -import java.lang.String; - -final class usersServiceErrorDecoder implements ErrorDecoder { - @Override - public Exception decode(String methodKey, Response response) { - try { - if (methodKey.contains("create")) { - return decodeException(response, CreateException.class); - } - if (methodKey.contains("get")) { - return decodeException(response, GetException.class); - } - if (methodKey.contains("update")) { - return decodeException(response, UpdateException.class); - } - if (methodKey.contains("getClassrooms")) { - return decodeException(response, GetClassroomsException.class); - } - if (methodKey.contains("getHero")) { - return decodeException(response, GetHeroException.class); - } - if (methodKey.contains("setAceConfig")) { - return decodeException(response, SetAceConfigException.class); - } - if (methodKey.contains("addOAuthIdentity")) { - return decodeException(response, AddOAuthIdentityException.class); - } - if (methodKey.contains("updateSubscription")) { - return decodeException(response, UpdateSubscriptionException.class); - } - if (methodKey.contains("shortenSubscription")) { - return decodeException(response, ShortenSubscriptionException.class); - } - if (methodKey.contains("grantLicense")) { - return decodeException(response, GrantLicenseException.class); - } - if (methodKey.contains("shortenLicense")) { - return decodeException(response, ShortenLicenseException.class); - } - if (methodKey.contains("findUser")) { - return decodeException(response, FindUserException.class); - } - } - catch (IOException e) { - } - return new RuntimeException("Failed to read response body. Received status " + response.status() + " for method " + methodKey); - } - - private static Exception decodeException(Response response, Class clazz) - throws IOException { - return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz); - } -} diff --git a/src/main/java/com/codecombat/api/core/ApiError.java b/src/main/java/com/codecombat/api/core/ApiError.java new file mode 100644 index 0000000..df294d7 --- /dev/null +++ b/src/main/java/com/codecombat/api/core/ApiError.java @@ -0,0 +1,25 @@ +package com.codecombat.api.core; + +public final class ApiError extends RuntimeException { + private final int statusCode; + + private final Object body; + + public ApiError(int statusCode, Object body) { + this.statusCode = statusCode; + this.body = body; + } + + public int statusCode() { + return this.statusCode; + } + + public Object body() { + return this.body; + } + + @Override + public String toString() { + return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}"; + } +} diff --git a/src/main/java/com/codecombat/api/core/BasicAuth.java b/src/main/java/com/codecombat/api/core/BasicAuth.java deleted file mode 100644 index 5ee60ed..0000000 --- a/src/main/java/com/codecombat/api/core/BasicAuth.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.codecombat.api.core; - -import com.fasterxml.jackson.annotation.JsonValue; -import java.lang.IllegalStateException; -import java.lang.Override; -import java.lang.String; -import java.nio.charset.StandardCharsets; -import java.util.Base64; - -public final class BasicAuth { - private final String token; - - private String username = null; - - private String password = null; - - private BasicAuth(String token) { - this.token = token; - } - - @JsonValue - public String getToken() { - return this.token; - } - - public final String username() { - decode(); - return this.username; - } - - public final String password() { - decode(); - return this.password; - } - - void decode() { - if (this.username == null || this.password == null) { - byte[] decodedToken = Base64.getDecoder().decode(getToken()); - String credentials = new String(decodedToken, StandardCharsets.UTF_8); - String[] values = credentials.split(":", 2); - if (values.length != 2) { - throw new IllegalStateException("Failed to decode basic token"); - } - this.username = values[0]; - this.password = values[1]; - } - } - - @Override - public String toString() { - return "Basic " + getToken(); - } - - public static BasicAuth of(String username, String password) { - String unencodedToken = username + ":" + password; - return new BasicAuth(Base64.getEncoder().encodeToString(unencodedToken.getBytes())); - } -} diff --git a/src/main/java/com/codecombat/api/core/ClientOptions.java b/src/main/java/com/codecombat/api/core/ClientOptions.java new file mode 100644 index 0000000..3596446 --- /dev/null +++ b/src/main/java/com/codecombat/api/core/ClientOptions.java @@ -0,0 +1,86 @@ +package com.codecombat.api.core; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(Map.of( + "X-Fern-SDK-Name", + "com.codecombat.fern:api-sdk", + "X-Fern-SDK-Version", + "0.1.5", + "X-Fern-Language", + "JAVA")); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + ; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + this.headers.put(key, value); + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + public ClientOptions build() { + return new ClientOptions(environment, headers, headerSuppliers, new OkHttpClient()); + } + } +} diff --git a/src/main/java/com/codecombat/api/core/Environment.java b/src/main/java/com/codecombat/api/core/Environment.java index 8f60b0a..8a06674 100644 --- a/src/main/java/com/codecombat/api/core/Environment.java +++ b/src/main/java/com/codecombat/api/core/Environment.java @@ -1,21 +1,19 @@ package com.codecombat.api.core; -import java.lang.String; - public final class Environment { - public static final Environment PRODUCTION = new Environment("https://codecombat.com/api"); + public static final Environment DEFAULT = new Environment("https://codecombat.com/api"); - private final String url; + private final String url; - private Environment(String url) { - this.url = url; - } + private Environment(String url) { + this.url = url; + } - public String getUrl() { - return this.url; - } + public String getUrl() { + return this.url; + } - public static Environment custom(String url) { - return new Environment(url); - } + public static Environment custom(String url) { + return new Environment(url); + } } diff --git a/src/main/java/com/codecombat/api/core/ObjectMappers.java b/src/main/java/com/codecombat/api/core/ObjectMappers.java index 1a3dda9..1471f75 100644 --- a/src/main/java/com/codecombat/api/core/ObjectMappers.java +++ b/src/main/java/com/codecombat/api/core/ObjectMappers.java @@ -1,16 +1,32 @@ package com.codecombat.api.core; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import java.io.IOException; public final class ObjectMappers { - public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() - .addModule(new Jdk8Module()) - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .build(); + public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .addModule(new JavaTimeModule()) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .build(); - private ObjectMappers() { + private ObjectMappers() {} + + public static String stringify(Object o) { + try { + return JSON_MAPPER + .setSerializationInclusion(JsonInclude.Include.ALWAYS) + .writerWithDefaultPrettyPrinter() + .writeValueAsString(o); + } catch (IOException e) { + return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); + } } - } +} diff --git a/src/main/java/com/codecombat/api/core/RequestOptions.java b/src/main/java/com/codecombat/api/core/RequestOptions.java new file mode 100644 index 0000000..4e8f46a --- /dev/null +++ b/src/main/java/com/codecombat/api/core/RequestOptions.java @@ -0,0 +1,23 @@ +package com.codecombat.api.core; + +import java.util.HashMap; +import java.util.Map; + +public final class RequestOptions { + private RequestOptions() {} + + public Map getHeaders() { + Map headers = new HashMap<>(); + return headers; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + public RequestOptions build() { + return new RequestOptions(); + } + } +} diff --git a/src/main/java/com/codecombat/api/core/Suppliers.java b/src/main/java/com/codecombat/api/core/Suppliers.java new file mode 100644 index 0000000..643d564 --- /dev/null +++ b/src/main/java/com/codecombat/api/core/Suppliers.java @@ -0,0 +1,20 @@ +package com.codecombat.api.core; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public final class Suppliers { + private Suppliers() {} + + public static Supplier memoize(Supplier delegate) { + AtomicReference value = new AtomicReference<>(); + return () -> { + T val = value.get(); + if (val == null) { + val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); + } + return val; + }; + } +} diff --git a/src/main/java/com/codecombat/api/requests/PostUsersHandleOAuthIdentitiesRequest.java b/src/main/java/com/codecombat/api/requests/PostUsersHandleOAuthIdentitiesRequest.java new file mode 100644 index 0000000..fc37976 --- /dev/null +++ b/src/main/java/com/codecombat/api/requests/PostUsersHandleOAuthIdentitiesRequest.java @@ -0,0 +1,164 @@ +package com.codecombat.api.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = PostUsersHandleOAuthIdentitiesRequest.Builder.class) +public final class PostUsersHandleOAuthIdentitiesRequest { + private final String provider; + + private final Optional accessToken; + + private final Optional code; + + private PostUsersHandleOAuthIdentitiesRequest( + String provider, Optional accessToken, Optional code) { + this.provider = provider; + this.accessToken = accessToken; + this.code = code; + } + + /** + * @return Your OAuth Provider ID. + */ + @JsonProperty("provider") + public String getProvider() { + return provider; + } + + /** + * @return Will be passed through your lookup URL to get the user ID. Required if no code. + */ + @JsonProperty("accessToken") + public Optional getAccessToken() { + return accessToken; + } + + /** + * @return Will be passed to the OAuth token endpoint to get a token. Required if no accessToken. + */ + @JsonProperty("code") + public Optional getCode() { + return code; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PostUsersHandleOAuthIdentitiesRequest + && equalTo((PostUsersHandleOAuthIdentitiesRequest) other); + } + + private boolean equalTo(PostUsersHandleOAuthIdentitiesRequest other) { + return provider.equals(other.provider) && accessToken.equals(other.accessToken) && code.equals(other.code); + } + + @Override + public int hashCode() { + return Objects.hash(this.provider, this.accessToken, this.code); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProviderStage builder() { + return new Builder(); + } + + public interface ProviderStage { + _FinalStage provider(String provider); + + Builder from(PostUsersHandleOAuthIdentitiesRequest other); + } + + public interface _FinalStage { + PostUsersHandleOAuthIdentitiesRequest build(); + + _FinalStage accessToken(Optional accessToken); + + _FinalStage accessToken(String accessToken); + + _FinalStage code(Optional code); + + _FinalStage code(String code); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProviderStage, _FinalStage { + private String provider; + + private Optional code = Optional.empty(); + + private Optional accessToken = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(PostUsersHandleOAuthIdentitiesRequest other) { + provider(other.getProvider()); + accessToken(other.getAccessToken()); + code(other.getCode()); + return this; + } + + /** + *

Your OAuth Provider ID.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("provider") + public _FinalStage provider(String provider) { + this.provider = provider; + return this; + } + + /** + *

Will be passed to the OAuth token endpoint to get a token. Required if no accessToken.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage code(String code) { + this.code = Optional.of(code); + return this; + } + + @Override + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public _FinalStage code(Optional code) { + this.code = code; + return this; + } + + /** + *

Will be passed through your lookup URL to get the user ID. Required if no code.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage accessToken(String accessToken) { + this.accessToken = Optional.of(accessToken); + return this; + } + + @Override + @JsonSetter(value = "accessToken", nulls = Nulls.SKIP) + public _FinalStage accessToken(Optional accessToken) { + this.accessToken = accessToken; + return this; + } + + @Override + public PostUsersHandleOAuthIdentitiesRequest build() { + return new PostUsersHandleOAuthIdentitiesRequest(provider, accessToken, code); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/auth/AuthClient.java b/src/main/java/com/codecombat/api/resources/auth/AuthClient.java new file mode 100644 index 0000000..d9be136 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/auth/AuthClient.java @@ -0,0 +1,63 @@ +package com.codecombat.api.resources.auth; + +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.resources.auth.requests.LoginOauthRequest; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class AuthClient { + protected final ClientOptions clientOptions; + + public AuthClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public void loginOauth(LoginOauthRequest request) { + loginOauth(request, null); + } + + public void loginOauth(LoginOauthRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("auth/login-o-auth"); + _httpUrl.addQueryParameter("provider", request.getProvider()); + if (request.getAccessToken().isPresent()) { + _httpUrl.addQueryParameter("accessToken", request.getAccessToken().get()); + } + if (request.getCode().isPresent()) { + _httpUrl.addQueryParameter("code", request.getCode().get()); + } + if (request.getRedirect().isPresent()) { + _httpUrl.addQueryParameter("redirect", request.getRedirect().get()); + } + if (request.getErrorRedirect().isPresent()) { + _httpUrl.addQueryParameter( + "errorRedirect", request.getErrorRedirect().get()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return; + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/auth/requests/LoginOauthRequest.java b/src/main/java/com/codecombat/api/resources/auth/requests/LoginOauthRequest.java new file mode 100644 index 0000000..b8b805c --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/auth/requests/LoginOauthRequest.java @@ -0,0 +1,241 @@ +package com.codecombat.api.resources.auth.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LoginOauthRequest.Builder.class) +public final class LoginOauthRequest { + private final String provider; + + private final Optional accessToken; + + private final Optional code; + + private final Optional redirect; + + private final Optional errorRedirect; + + private LoginOauthRequest( + String provider, + Optional accessToken, + Optional code, + Optional redirect, + Optional errorRedirect) { + this.provider = provider; + this.accessToken = accessToken; + this.code = code; + this.redirect = redirect; + this.errorRedirect = errorRedirect; + } + + /** + * @return Your OAuth Provider ID + */ + @JsonProperty("provider") + public String getProvider() { + return provider; + } + + /** + * @return Will be passed through your lookup URL to get the user ID. Required if no code. + */ + @JsonProperty("accessToken") + public Optional getAccessToken() { + return accessToken; + } + + /** + * @return Will be passed to the OAuth token endpoint to get a token. Required if no accessToken. + */ + @JsonProperty("code") + public Optional getCode() { + return code; + } + + /** + * @return Override where the user will navigate to after successfully logging in. + */ + @JsonProperty("redirect") + public Optional getRedirect() { + return redirect; + } + + /** + * @return If an error happens, redirects the user to this url, with at least query parameters code, errorName and message. + */ + @JsonProperty("errorRedirect") + public Optional getErrorRedirect() { + return errorRedirect; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LoginOauthRequest && equalTo((LoginOauthRequest) other); + } + + private boolean equalTo(LoginOauthRequest other) { + return provider.equals(other.provider) + && accessToken.equals(other.accessToken) + && code.equals(other.code) + && redirect.equals(other.redirect) + && errorRedirect.equals(other.errorRedirect); + } + + @Override + public int hashCode() { + return Objects.hash(this.provider, this.accessToken, this.code, this.redirect, this.errorRedirect); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ProviderStage builder() { + return new Builder(); + } + + public interface ProviderStage { + _FinalStage provider(String provider); + + Builder from(LoginOauthRequest other); + } + + public interface _FinalStage { + LoginOauthRequest build(); + + _FinalStage accessToken(Optional accessToken); + + _FinalStage accessToken(String accessToken); + + _FinalStage code(Optional code); + + _FinalStage code(String code); + + _FinalStage redirect(Optional redirect); + + _FinalStage redirect(String redirect); + + _FinalStage errorRedirect(Optional errorRedirect); + + _FinalStage errorRedirect(String errorRedirect); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ProviderStage, _FinalStage { + private String provider; + + private Optional errorRedirect = Optional.empty(); + + private Optional redirect = Optional.empty(); + + private Optional code = Optional.empty(); + + private Optional accessToken = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(LoginOauthRequest other) { + provider(other.getProvider()); + accessToken(other.getAccessToken()); + code(other.getCode()); + redirect(other.getRedirect()); + errorRedirect(other.getErrorRedirect()); + return this; + } + + /** + *

Your OAuth Provider ID

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("provider") + public _FinalStage provider(String provider) { + this.provider = provider; + return this; + } + + /** + *

If an error happens, redirects the user to this url, with at least query parameters code, errorName and message.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage errorRedirect(String errorRedirect) { + this.errorRedirect = Optional.of(errorRedirect); + return this; + } + + @Override + @JsonSetter(value = "errorRedirect", nulls = Nulls.SKIP) + public _FinalStage errorRedirect(Optional errorRedirect) { + this.errorRedirect = errorRedirect; + return this; + } + + /** + *

Override where the user will navigate to after successfully logging in.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage redirect(String redirect) { + this.redirect = Optional.of(redirect); + return this; + } + + @Override + @JsonSetter(value = "redirect", nulls = Nulls.SKIP) + public _FinalStage redirect(Optional redirect) { + this.redirect = redirect; + return this; + } + + /** + *

Will be passed to the OAuth token endpoint to get a token. Required if no accessToken.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage code(String code) { + this.code = Optional.of(code); + return this; + } + + @Override + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public _FinalStage code(Optional code) { + this.code = code; + return this; + } + + /** + *

Will be passed through your lookup URL to get the user ID. Required if no code.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage accessToken(String accessToken) { + this.accessToken = Optional.of(accessToken); + return this; + } + + @Override + @JsonSetter(value = "accessToken", nulls = Nulls.SKIP) + public _FinalStage accessToken(Optional accessToken) { + this.accessToken = accessToken; + return this; + } + + @Override + public LoginOauthRequest build() { + return new LoginOauthRequest(provider, accessToken, code, redirect, errorRedirect); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/clans/ClansClient.java b/src/main/java/com/codecombat/api/resources/clans/ClansClient.java new file mode 100644 index 0000000..43e9f27 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/clans/ClansClient.java @@ -0,0 +1,65 @@ +package com.codecombat.api.resources.clans; + +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.resources.clans.requests.ClansUpsertMemberRequest; +import com.codecombat.api.types.ClanResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class ClansClient { + protected final ClientOptions clientOptions; + + public ClansClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public ClanResponse upsertMember(String handle, ClansUpsertMemberRequest request) { + return upsertMember(handle, request, null); + } + + public ClanResponse upsertMember(String handle, ClansUpsertMemberRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("clan") + .addPathSegment(handle) + .addPathSegments("members") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("userId", request.getUserId()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClanResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/clans/requests/ClansUpsertMemberRequest.java b/src/main/java/com/codecombat/api/resources/clans/requests/ClansUpsertMemberRequest.java new file mode 100644 index 0000000..1fb124b --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/clans/requests/ClansUpsertMemberRequest.java @@ -0,0 +1,90 @@ +package com.codecombat.api.resources.clans.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClansUpsertMemberRequest.Builder.class) +public final class ClansUpsertMemberRequest { + private final String userId; + + private ClansUpsertMemberRequest(String userId) { + this.userId = userId; + } + + /** + * @return The _id or slug of the user to add to the clan. + */ + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClansUpsertMemberRequest && equalTo((ClansUpsertMemberRequest) other); + } + + private boolean equalTo(ClansUpsertMemberRequest other) { + return userId.equals(other.userId); + } + + @Override + public int hashCode() { + return Objects.hash(this.userId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(String userId); + + Builder from(ClansUpsertMemberRequest other); + } + + public interface _FinalStage { + ClansUpsertMemberRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Builder() {} + + @Override + public Builder from(ClansUpsertMemberRequest other) { + userId(other.getUserId()); + return this; + } + + /** + *

The _id or slug of the user to add to the clan.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("userId") + public _FinalStage userId(String userId) { + this.userId = userId; + return this; + } + + @Override + public ClansUpsertMemberRequest build() { + return new ClansUpsertMemberRequest(userId); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/ClassroomsClient.java b/src/main/java/com/codecombat/api/resources/classrooms/ClassroomsClient.java new file mode 100644 index 0000000..bbb1231 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/ClassroomsClient.java @@ -0,0 +1,385 @@ +package com.codecombat.api.resources.classrooms; + +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.resources.classrooms.requests.ClassroomsCreateRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsEnrollUserInCourseRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsGetMembersStatsRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsGetRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsRemoveEnrolledUserRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsRemoveMemberRequest; +import com.codecombat.api.resources.classrooms.requests.ClassroomsUpsertMemberRequest; +import com.codecombat.api.types.ClassroomResponse; +import com.codecombat.api.types.ClassroomResponseWithCode; +import com.codecombat.api.types.ClassroomsGetMembersStatsResponseItem; +import com.codecombat.api.types.LevelSessionResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class ClassroomsClient { + protected final ClientOptions clientOptions; + + public ClassroomsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public ClassroomResponseWithCode get(ClassroomsGetRequest request) { + return get(request, null); + } + + public ClassroomResponseWithCode get(ClassroomsGetRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms"); + _httpUrl.addQueryParameter("code", request.getCode()); + if (request.getRetMemberLimit().isPresent()) { + _httpUrl.addQueryParameter( + "retMemberLimit", request.getRetMemberLimit().get().toString()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponseWithCode.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ClassroomResponseWithCode create(ClassroomsCreateRequest request) { + return create(request, null); + } + + public ClassroomResponseWithCode create(ClassroomsCreateRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("name", request.getName()); + _requestBodyProperties.put("ownerID", request.getOwnerId()); + _requestBodyProperties.put("aceConfig", request.getAceConfig()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("POST", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponseWithCode.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ClassroomResponse upsertMember(String handle, ClassroomsUpsertMemberRequest request) { + return upsertMember(handle, request, null); + } + + public ClassroomResponse upsertMember( + String handle, ClassroomsUpsertMemberRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(handle) + .addPathSegments("members") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("code", request.getCode()); + _requestBodyProperties.put("userId", request.getUserId()); + if (request.getRetMemberLimit().isPresent()) { + _requestBodyProperties.put("retMemberLimit", request.getRetMemberLimit()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ClassroomResponse removeMember(String handle, ClassroomsRemoveMemberRequest request) { + return removeMember(handle, request, null); + } + + public ClassroomResponse removeMember( + String handle, ClassroomsRemoveMemberRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(handle) + .addPathSegments("members") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("userId", request.getUserId()); + if (request.getRetMemberLimit().isPresent()) { + _requestBodyProperties.put("retMemberLimit", request.getRetMemberLimit()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("DELETE", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ClassroomResponse enrollUserInCourse( + String classroomHandle, String courseHandle, ClassroomsEnrollUserInCourseRequest request) { + return enrollUserInCourse(classroomHandle, courseHandle, request, null); + } + + public ClassroomResponse enrollUserInCourse( + String classroomHandle, + String courseHandle, + ClassroomsEnrollUserInCourseRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(classroomHandle) + .addPathSegments("courses") + .addPathSegment(courseHandle) + .addPathSegments("enrolled"); + if (request.getRetMemberLimit().isPresent()) { + _httpUrl.addQueryParameter( + "retMemberLimit", request.getRetMemberLimit().get().toString()); + } + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("userId", request.getUserId()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public ClassroomResponse removeEnrolledUser( + String classroomHandle, String courseHandle, ClassroomsRemoveEnrolledUserRequest request) { + return removeEnrolledUser(classroomHandle, courseHandle, request, null); + } + + public ClassroomResponse removeEnrolledUser( + String classroomHandle, + String courseHandle, + ClassroomsRemoveEnrolledUserRequest request, + RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(classroomHandle) + .addPathSegments("courses") + .addPathSegment(courseHandle) + .addPathSegments("remove-enrolled"); + if (request.getRetMemberLimit().isPresent()) { + _httpUrl.addQueryParameter( + "retMemberLimit", request.getRetMemberLimit().get().toString()); + } + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("userId", request.getUserId()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), ClassroomResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List getMembersStats( + String classroomHandle, ClassroomsGetMembersStatsRequest request) { + return getMembersStats(classroomHandle, request, null); + } + + public List getMembersStats( + String classroomHandle, ClassroomsGetMembersStatsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(classroomHandle) + .addPathSegments("stats"); + if (request.getProject().isPresent()) { + _httpUrl.addQueryParameter("project", request.getProject().get()); + } + if (request.getMemberLimit().isPresent()) { + _httpUrl.addQueryParameter( + "memberLimit", request.getMemberLimit().get().toString()); + } + if (request.getMemberSkip().isPresent()) { + _httpUrl.addQueryParameter( + "memberSkip", request.getMemberSkip().get().toString()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue( + _response.body().string(), new TypeReference>() {}); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List getMembersStats(String classroomHandle) { + return getMembersStats( + classroomHandle, ClassroomsGetMembersStatsRequest.builder().build()); + } + + public List getLevelsPlayed(String classroomHandle, String memberHandle) { + return getLevelsPlayed(classroomHandle, memberHandle, null); + } + + public List getLevelsPlayed( + String classroomHandle, String memberHandle, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("classrooms") + .addPathSegment(classroomHandle) + .addPathSegments("members") + .addPathSegment(memberHandle) + .addPathSegments("sessions") + .build(); + Request _request = new Request.Builder() + .url(_httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue( + _response.body().string(), new TypeReference>() {}); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsCreateRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsCreateRequest.java new file mode 100644 index 0000000..cef71c3 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsCreateRequest.java @@ -0,0 +1,135 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.types.ClassroomsCreateRequestAceConfig; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsCreateRequest.Builder.class) +public final class ClassroomsCreateRequest { + private final String name; + + private final String ownerId; + + private final ClassroomsCreateRequestAceConfig aceConfig; + + private ClassroomsCreateRequest(String name, String ownerId, ClassroomsCreateRequestAceConfig aceConfig) { + this.name = name; + this.ownerId = ownerId; + this.aceConfig = aceConfig; + } + + /** + * @return Name of the classroom + */ + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("ownerID") + public String getOwnerId() { + return ownerId; + } + + @JsonProperty("aceConfig") + public ClassroomsCreateRequestAceConfig getAceConfig() { + return aceConfig; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsCreateRequest && equalTo((ClassroomsCreateRequest) other); + } + + private boolean equalTo(ClassroomsCreateRequest other) { + return name.equals(other.name) && ownerId.equals(other.ownerId) && aceConfig.equals(other.aceConfig); + } + + @Override + public int hashCode() { + return Objects.hash(this.name, this.ownerId, this.aceConfig); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + OwnerIdStage name(String name); + + Builder from(ClassroomsCreateRequest other); + } + + public interface OwnerIdStage { + AceConfigStage ownerId(String ownerId); + } + + public interface AceConfigStage { + _FinalStage aceConfig(ClassroomsCreateRequestAceConfig aceConfig); + } + + public interface _FinalStage { + ClassroomsCreateRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, OwnerIdStage, AceConfigStage, _FinalStage { + private String name; + + private String ownerId; + + private ClassroomsCreateRequestAceConfig aceConfig; + + private Builder() {} + + @Override + public Builder from(ClassroomsCreateRequest other) { + name(other.getName()); + ownerId(other.getOwnerId()); + aceConfig(other.getAceConfig()); + return this; + } + + /** + *

Name of the classroom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("name") + public OwnerIdStage name(String name) { + this.name = name; + return this; + } + + @Override + @JsonSetter("ownerID") + public AceConfigStage ownerId(String ownerId) { + this.ownerId = ownerId; + return this; + } + + @Override + @JsonSetter("aceConfig") + public _FinalStage aceConfig(ClassroomsCreateRequestAceConfig aceConfig) { + this.aceConfig = aceConfig; + return this; + } + + @Override + public ClassroomsCreateRequest build() { + return new ClassroomsCreateRequest(name, ownerId, aceConfig); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsEnrollUserInCourseRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsEnrollUserInCourseRequest.java new file mode 100644 index 0000000..3ddd662 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsEnrollUserInCourseRequest.java @@ -0,0 +1,121 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsEnrollUserInCourseRequest.Builder.class) +public final class ClassroomsEnrollUserInCourseRequest { + private final Optional retMemberLimit; + + private final String userId; + + private ClassroomsEnrollUserInCourseRequest(Optional retMemberLimit, String userId) { + this.retMemberLimit = retMemberLimit; + this.userId = userId; + } + + /** + * @return limit the return number of members for the classroom, the default value is 1000 + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsEnrollUserInCourseRequest + && equalTo((ClassroomsEnrollUserInCourseRequest) other); + } + + private boolean equalTo(ClassroomsEnrollUserInCourseRequest other) { + return retMemberLimit.equals(other.retMemberLimit) && userId.equals(other.userId); + } + + @Override + public int hashCode() { + return Objects.hash(this.retMemberLimit, this.userId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(String userId); + + Builder from(ClassroomsEnrollUserInCourseRequest other); + } + + public interface _FinalStage { + ClassroomsEnrollUserInCourseRequest build(); + + _FinalStage retMemberLimit(Optional retMemberLimit); + + _FinalStage retMemberLimit(Double retMemberLimit); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(ClassroomsEnrollUserInCourseRequest other) { + retMemberLimit(other.getRetMemberLimit()); + userId(other.getUserId()); + return this; + } + + @Override + @JsonSetter("userId") + public _FinalStage userId(String userId) { + this.userId = userId; + return this; + } + + /** + *

limit the return number of members for the classroom, the default value is 1000

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + @Override + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public _FinalStage retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + @Override + public ClassroomsEnrollUserInCourseRequest build() { + return new ClassroomsEnrollUserInCourseRequest(retMemberLimit, userId); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetMembersStatsRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetMembersStatsRequest.java new file mode 100644 index 0000000..d2e2fdc --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetMembersStatsRequest.java @@ -0,0 +1,133 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsGetMembersStatsRequest.Builder.class) +public final class ClassroomsGetMembersStatsRequest { + private final Optional project; + + private final Optional memberLimit; + + private final Optional memberSkip; + + private ClassroomsGetMembersStatsRequest( + Optional project, Optional memberLimit, Optional memberSkip) { + this.project = project; + this.memberLimit = memberLimit; + this.memberSkip = memberSkip; + } + + /** + * @return If specified, include only the specified projection of returned stats; else, return all stats. Format as a comma-separated list, like creator,playtime,state.complete. + */ + @JsonProperty("project") + public Optional getProject() { + return project; + } + + /** + * @return Limit the return member number. the default value is 10, and the max value is 100 + */ + @JsonProperty("memberLimit") + public Optional getMemberLimit() { + return memberLimit; + } + + /** + * @return Skip the members that doesn't need to return, for pagination + */ + @JsonProperty("memberSkip") + public Optional getMemberSkip() { + return memberSkip; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsGetMembersStatsRequest && equalTo((ClassroomsGetMembersStatsRequest) other); + } + + private boolean equalTo(ClassroomsGetMembersStatsRequest other) { + return project.equals(other.project) + && memberLimit.equals(other.memberLimit) + && memberSkip.equals(other.memberSkip); + } + + @Override + public int hashCode() { + return Objects.hash(this.project, this.memberLimit, this.memberSkip); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional project = Optional.empty(); + + private Optional memberLimit = Optional.empty(); + + private Optional memberSkip = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomsGetMembersStatsRequest other) { + project(other.getProject()); + memberLimit(other.getMemberLimit()); + memberSkip(other.getMemberSkip()); + return this; + } + + @JsonSetter(value = "project", nulls = Nulls.SKIP) + public Builder project(Optional project) { + this.project = project; + return this; + } + + public Builder project(String project) { + this.project = Optional.of(project); + return this; + } + + @JsonSetter(value = "memberLimit", nulls = Nulls.SKIP) + public Builder memberLimit(Optional memberLimit) { + this.memberLimit = memberLimit; + return this; + } + + public Builder memberLimit(Double memberLimit) { + this.memberLimit = Optional.of(memberLimit); + return this; + } + + @JsonSetter(value = "memberSkip", nulls = Nulls.SKIP) + public Builder memberSkip(Optional memberSkip) { + this.memberSkip = memberSkip; + return this; + } + + public Builder memberSkip(Double memberSkip) { + this.memberSkip = Optional.of(memberSkip); + return this; + } + + public ClassroomsGetMembersStatsRequest build() { + return new ClassroomsGetMembersStatsRequest(project, memberLimit, memberSkip); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetRequest.java new file mode 100644 index 0000000..7f38cad --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsGetRequest.java @@ -0,0 +1,127 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsGetRequest.Builder.class) +public final class ClassroomsGetRequest { + private final String code; + + private final Optional retMemberLimit; + + private ClassroomsGetRequest(String code, Optional retMemberLimit) { + this.code = code; + this.retMemberLimit = retMemberLimit; + } + + /** + * @return The classroom's code. + */ + @JsonProperty("code") + public String getCode() { + return code; + } + + /** + * @return limit the return number of members for the classroom + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsGetRequest && equalTo((ClassroomsGetRequest) other); + } + + private boolean equalTo(ClassroomsGetRequest other) { + return code.equals(other.code) && retMemberLimit.equals(other.retMemberLimit); + } + + @Override + public int hashCode() { + return Objects.hash(this.code, this.retMemberLimit); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CodeStage builder() { + return new Builder(); + } + + public interface CodeStage { + _FinalStage code(String code); + + Builder from(ClassroomsGetRequest other); + } + + public interface _FinalStage { + ClassroomsGetRequest build(); + + _FinalStage retMemberLimit(Optional retMemberLimit); + + _FinalStage retMemberLimit(Double retMemberLimit); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CodeStage, _FinalStage { + private String code; + + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(ClassroomsGetRequest other) { + code(other.getCode()); + retMemberLimit(other.getRetMemberLimit()); + return this; + } + + /** + *

The classroom's code.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("code") + public _FinalStage code(String code) { + this.code = code; + return this; + } + + /** + *

limit the return number of members for the classroom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + @Override + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public _FinalStage retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + @Override + public ClassroomsGetRequest build() { + return new ClassroomsGetRequest(code, retMemberLimit); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveEnrolledUserRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveEnrolledUserRequest.java new file mode 100644 index 0000000..cb83118 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveEnrolledUserRequest.java @@ -0,0 +1,121 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsRemoveEnrolledUserRequest.Builder.class) +public final class ClassroomsRemoveEnrolledUserRequest { + private final Optional retMemberLimit; + + private final String userId; + + private ClassroomsRemoveEnrolledUserRequest(Optional retMemberLimit, String userId) { + this.retMemberLimit = retMemberLimit; + this.userId = userId; + } + + /** + * @return limit the return number of members for the classroom, the default value is 1000 + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsRemoveEnrolledUserRequest + && equalTo((ClassroomsRemoveEnrolledUserRequest) other); + } + + private boolean equalTo(ClassroomsRemoveEnrolledUserRequest other) { + return retMemberLimit.equals(other.retMemberLimit) && userId.equals(other.userId); + } + + @Override + public int hashCode() { + return Objects.hash(this.retMemberLimit, this.userId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(String userId); + + Builder from(ClassroomsRemoveEnrolledUserRequest other); + } + + public interface _FinalStage { + ClassroomsRemoveEnrolledUserRequest build(); + + _FinalStage retMemberLimit(Optional retMemberLimit); + + _FinalStage retMemberLimit(Double retMemberLimit); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(ClassroomsRemoveEnrolledUserRequest other) { + retMemberLimit(other.getRetMemberLimit()); + userId(other.getUserId()); + return this; + } + + @Override + @JsonSetter("userId") + public _FinalStage userId(String userId) { + this.userId = userId; + return this; + } + + /** + *

limit the return number of members for the classroom, the default value is 1000

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + @Override + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public _FinalStage retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + @Override + public ClassroomsRemoveEnrolledUserRequest build() { + return new ClassroomsRemoveEnrolledUserRequest(retMemberLimit, userId); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveMemberRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveMemberRequest.java new file mode 100644 index 0000000..d808920 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsRemoveMemberRequest.java @@ -0,0 +1,127 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsRemoveMemberRequest.Builder.class) +public final class ClassroomsRemoveMemberRequest { + private final String userId; + + private final Optional retMemberLimit; + + private ClassroomsRemoveMemberRequest(String userId, Optional retMemberLimit) { + this.userId = userId; + this.retMemberLimit = retMemberLimit; + } + + /** + * @return The _id or slug of the user to remove from the class. + */ + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + /** + * @return limit the return number of members for the classroom, the default value is 1000 + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsRemoveMemberRequest && equalTo((ClassroomsRemoveMemberRequest) other); + } + + private boolean equalTo(ClassroomsRemoveMemberRequest other) { + return userId.equals(other.userId) && retMemberLimit.equals(other.retMemberLimit); + } + + @Override + public int hashCode() { + return Objects.hash(this.userId, this.retMemberLimit); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UserIdStage builder() { + return new Builder(); + } + + public interface UserIdStage { + _FinalStage userId(String userId); + + Builder from(ClassroomsRemoveMemberRequest other); + } + + public interface _FinalStage { + ClassroomsRemoveMemberRequest build(); + + _FinalStage retMemberLimit(Optional retMemberLimit); + + _FinalStage retMemberLimit(Double retMemberLimit); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UserIdStage, _FinalStage { + private String userId; + + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(ClassroomsRemoveMemberRequest other) { + userId(other.getUserId()); + retMemberLimit(other.getRetMemberLimit()); + return this; + } + + /** + *

The _id or slug of the user to remove from the class.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("userId") + public _FinalStage userId(String userId) { + this.userId = userId; + return this; + } + + /** + *

limit the return number of members for the classroom, the default value is 1000

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + @Override + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public _FinalStage retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + @Override + public ClassroomsRemoveMemberRequest build() { + return new ClassroomsRemoveMemberRequest(userId, retMemberLimit); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsUpsertMemberRequest.java b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsUpsertMemberRequest.java new file mode 100644 index 0000000..741765b --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/classrooms/requests/ClassroomsUpsertMemberRequest.java @@ -0,0 +1,156 @@ +package com.codecombat.api.resources.classrooms.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsUpsertMemberRequest.Builder.class) +public final class ClassroomsUpsertMemberRequest { + private final String code; + + private final String userId; + + private final Optional retMemberLimit; + + private ClassroomsUpsertMemberRequest(String code, String userId, Optional retMemberLimit) { + this.code = code; + this.userId = userId; + this.retMemberLimit = retMemberLimit; + } + + /** + * @return The code for joining this classroom + */ + @JsonProperty("code") + public String getCode() { + return code; + } + + /** + * @return The _id or slug of the user to add to the class. + */ + @JsonProperty("userId") + public String getUserId() { + return userId; + } + + /** + * @return limit the return number of members for the classroom, the default value is 1000 + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsUpsertMemberRequest && equalTo((ClassroomsUpsertMemberRequest) other); + } + + private boolean equalTo(ClassroomsUpsertMemberRequest other) { + return code.equals(other.code) && userId.equals(other.userId) && retMemberLimit.equals(other.retMemberLimit); + } + + @Override + public int hashCode() { + return Objects.hash(this.code, this.userId, this.retMemberLimit); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static CodeStage builder() { + return new Builder(); + } + + public interface CodeStage { + UserIdStage code(String code); + + Builder from(ClassroomsUpsertMemberRequest other); + } + + public interface UserIdStage { + _FinalStage userId(String userId); + } + + public interface _FinalStage { + ClassroomsUpsertMemberRequest build(); + + _FinalStage retMemberLimit(Optional retMemberLimit); + + _FinalStage retMemberLimit(Double retMemberLimit); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements CodeStage, UserIdStage, _FinalStage { + private String code; + + private String userId; + + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(ClassroomsUpsertMemberRequest other) { + code(other.getCode()); + userId(other.getUserId()); + retMemberLimit(other.getRetMemberLimit()); + return this; + } + + /** + *

The code for joining this classroom

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("code") + public UserIdStage code(String code) { + this.code = code; + return this; + } + + /** + *

The _id or slug of the user to add to the class.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("userId") + public _FinalStage userId(String userId) { + this.userId = userId; + return this; + } + + /** + *

limit the return number of members for the classroom, the default value is 1000

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + @Override + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public _FinalStage retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + @Override + public ClassroomsUpsertMemberRequest build() { + return new ClassroomsUpsertMemberRequest(code, userId, retMemberLimit); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/stats/StatsClient.java b/src/main/java/com/codecombat/api/resources/stats/StatsClient.java new file mode 100644 index 0000000..5d71e9b --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/stats/StatsClient.java @@ -0,0 +1,93 @@ +package com.codecombat.api.resources.stats; + +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.resources.stats.requests.StatsGetPlaytimeStatsRequest; +import com.codecombat.api.types.LicenseStatsResponse; +import com.codecombat.api.types.PlaytimeStatsResponse; +import java.io.IOException; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class StatsClient { + protected final ClientOptions clientOptions; + + public StatsClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public PlaytimeStatsResponse getPlaytimeStats(StatsGetPlaytimeStatsRequest request) { + return getPlaytimeStats(request, null); + } + + public PlaytimeStatsResponse getPlaytimeStats(StatsGetPlaytimeStatsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("playtime-stats"); + if (request.getStartDate().isPresent()) { + _httpUrl.addQueryParameter("startDate", request.getStartDate().get()); + } + if (request.getEndDate().isPresent()) { + _httpUrl.addQueryParameter("endDate", request.getEndDate().get()); + } + if (request.getCountry().isPresent()) { + _httpUrl.addQueryParameter("country", request.getCountry().get()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), PlaytimeStatsResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public PlaytimeStatsResponse getPlaytimeStats() { + return getPlaytimeStats(StatsGetPlaytimeStatsRequest.builder().build()); + } + + public LicenseStatsResponse getLicenseStats() { + return getLicenseStats(null); + } + + public LicenseStatsResponse getLicenseStats(RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("license-stats") + .build(); + Request _request = new Request.Builder() + .url(_httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json") + .build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), LicenseStatsResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/stats/requests/StatsGetPlaytimeStatsRequest.java b/src/main/java/com/codecombat/api/resources/stats/requests/StatsGetPlaytimeStatsRequest.java new file mode 100644 index 0000000..7ff5754 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/stats/requests/StatsGetPlaytimeStatsRequest.java @@ -0,0 +1,131 @@ +package com.codecombat.api.resources.stats.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = StatsGetPlaytimeStatsRequest.Builder.class) +public final class StatsGetPlaytimeStatsRequest { + private final Optional startDate; + + private final Optional endDate; + + private final Optional country; + + private StatsGetPlaytimeStatsRequest( + Optional startDate, Optional endDate, Optional country) { + this.startDate = startDate; + this.endDate = endDate; + this.country = country; + } + + /** + * @return Earliest an included user was created + */ + @JsonProperty("startDate") + public Optional getStartDate() { + return startDate; + } + + /** + * @return Latest an included user was created + */ + @JsonProperty("endDate") + public Optional getEndDate() { + return endDate; + } + + /** + * @return Filter by country string + */ + @JsonProperty("country") + public Optional getCountry() { + return country; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof StatsGetPlaytimeStatsRequest && equalTo((StatsGetPlaytimeStatsRequest) other); + } + + private boolean equalTo(StatsGetPlaytimeStatsRequest other) { + return startDate.equals(other.startDate) && endDate.equals(other.endDate) && country.equals(other.country); + } + + @Override + public int hashCode() { + return Objects.hash(this.startDate, this.endDate, this.country); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional startDate = Optional.empty(); + + private Optional endDate = Optional.empty(); + + private Optional country = Optional.empty(); + + private Builder() {} + + public Builder from(StatsGetPlaytimeStatsRequest other) { + startDate(other.getStartDate()); + endDate(other.getEndDate()); + country(other.getCountry()); + return this; + } + + @JsonSetter(value = "startDate", nulls = Nulls.SKIP) + public Builder startDate(Optional startDate) { + this.startDate = startDate; + return this; + } + + public Builder startDate(String startDate) { + this.startDate = Optional.of(startDate); + return this; + } + + @JsonSetter(value = "endDate", nulls = Nulls.SKIP) + public Builder endDate(Optional endDate) { + this.endDate = endDate; + return this; + } + + public Builder endDate(String endDate) { + this.endDate = Optional.of(endDate); + return this; + } + + @JsonSetter(value = "country", nulls = Nulls.SKIP) + public Builder country(Optional country) { + this.country = country; + return this; + } + + public Builder country(String country) { + this.country = Optional.of(country); + return this; + } + + public StatsGetPlaytimeStatsRequest build() { + return new StatsGetPlaytimeStatsRequest(startDate, endDate, country); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/UsersClient.java b/src/main/java/com/codecombat/api/resources/users/UsersClient.java new file mode 100644 index 0000000..560f89a --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/UsersClient.java @@ -0,0 +1,499 @@ +package com.codecombat.api.resources.users; + +import com.codecombat.api.core.ApiError; +import com.codecombat.api.core.ClientOptions; +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.core.RequestOptions; +import com.codecombat.api.resources.users.requests.UsersCreateRequest; +import com.codecombat.api.resources.users.requests.UsersGetClassroomsRequest; +import com.codecombat.api.resources.users.requests.UsersGetRequest; +import com.codecombat.api.resources.users.requests.UsersGrantLicenseRequest; +import com.codecombat.api.resources.users.requests.UsersGrantPremiumSubscriptionRequest; +import com.codecombat.api.resources.users.requests.UsersSetAceConfigRequest; +import com.codecombat.api.resources.users.requests.UsersSetHeroRequest; +import com.codecombat.api.resources.users.requests.UsersShortenLicenseRequest; +import com.codecombat.api.resources.users.requests.UsersShortenSubscriptionRequest; +import com.codecombat.api.resources.users.requests.UsersUpdateRequest; +import com.codecombat.api.types.ClassroomResponseWithCode; +import com.codecombat.api.types.UserResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +public class UsersClient { + protected final ClientOptions clientOptions; + + public UsersClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public UserResponse create(UsersCreateRequest request) { + return create(request, null); + } + + public UserResponse create(UsersCreateRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("name", request.getName()); + _requestBodyProperties.put("email", request.getEmail()); + if (request.getRole().isPresent()) { + _requestBodyProperties.put("role", request.getRole()); + } + if (request.getPreferredLanguage().isPresent()) { + _requestBodyProperties.put("preferredLanguage", request.getPreferredLanguage()); + } + if (request.getHeroConfig().isPresent()) { + _requestBodyProperties.put("heroConfig", request.getHeroConfig()); + } + if (request.getBirthday().isPresent()) { + _requestBodyProperties.put("birthday", request.getBirthday()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("POST", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse get(String handle, UsersGetRequest request) { + return get(handle, request, null); + } + + public UserResponse get(String handle, UsersGetRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle); + if (request.getIncludePlayTime().isPresent()) { + _httpUrl.addQueryParameter( + "includePlayTime", request.getIncludePlayTime().get()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse get(String handle) { + return get(handle, UsersGetRequest.builder().build()); + } + + public UserResponse update(String handle, UsersUpdateRequest request) { + return update(handle, request, null); + } + + public UserResponse update(String handle, UsersUpdateRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("name", request.getName()); + if (request.getBirthday().isPresent()) { + _requestBodyProperties.put("birthday", request.getBirthday()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List getClassrooms(String handle, UsersGetClassroomsRequest request) { + return getClassrooms(handle, request, null); + } + + public List getClassrooms( + String handle, UsersGetClassroomsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder _httpUrl = HttpUrl.parse( + this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("classrooms"); + if (request.getRetMemberLimit().isPresent()) { + _httpUrl.addQueryParameter( + "retMemberLimit", request.getRetMemberLimit().get().toString()); + } + RequestBody _requestBody = null; + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl.build()) + .method("GET", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue( + _response.body().string(), new TypeReference>() {}); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List getClassrooms(String handle) { + return getClassrooms(handle, UsersGetClassroomsRequest.builder().build()); + } + + public UserResponse setHero(String handle, UsersSetHeroRequest request) { + return setHero(handle, request, null); + } + + public UserResponse setHero(String handle, UsersSetHeroRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("hero-config") + .build(); + Map _requestBodyProperties = new HashMap<>(); + if (request.getThangType().isPresent()) { + _requestBodyProperties.put("thangType", request.getThangType()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse setHero(String handle) { + return setHero(handle, UsersSetHeroRequest.builder().build()); + } + + public UserResponse setAceConfig(String handle, UsersSetAceConfigRequest request) { + return setAceConfig(handle, request, null); + } + + public UserResponse setAceConfig(String handle, UsersSetAceConfigRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("ace-config") + .build(); + Map _requestBodyProperties = new HashMap<>(); + if (request.getLiveCompletion().isPresent()) { + _requestBodyProperties.put("liveCompletion", request.getLiveCompletion()); + } + if (request.getBehaviors().isPresent()) { + _requestBodyProperties.put("behaviors", request.getBehaviors()); + } + if (request.getLanguage().isPresent()) { + _requestBodyProperties.put("language", request.getLanguage()); + } + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse setAceConfig(String handle) { + return setAceConfig(handle, UsersSetAceConfigRequest.builder().build()); + } + + public UserResponse grantPremiumSubscription(String handle, UsersGrantPremiumSubscriptionRequest request) { + return grantPremiumSubscription(handle, request, null); + } + + public UserResponse grantPremiumSubscription( + String handle, UsersGrantPremiumSubscriptionRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("subscription") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("ends", request.getEnds()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse shortenSubscription(String handle, UsersShortenSubscriptionRequest request) { + return shortenSubscription(handle, request, null); + } + + public UserResponse shortenSubscription( + String handle, UsersShortenSubscriptionRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("shorten-subscription") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("ends", request.getEnds()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse grantLicense(String handle, UsersGrantLicenseRequest request) { + return grantLicense(handle, request, null); + } + + public UserResponse grantLicense(String handle, UsersGrantLicenseRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("license") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("ends", request.getEnds()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public UserResponse shortenLicense(String handle, UsersShortenLicenseRequest request) { + return shortenLicense(handle, request, null); + } + + public UserResponse shortenLicense( + String handle, UsersShortenLicenseRequest request, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("users") + .addPathSegment(handle) + .addPathSegments("shorten-license") + .build(); + Map _requestBodyProperties = new HashMap<>(); + _requestBodyProperties.put("ends", request.getEnds()); + RequestBody _requestBody; + try { + _requestBody = RequestBody.create( + ObjectMappers.JSON_MAPPER.writeValueAsBytes(_requestBodyProperties), + MediaType.parse("application/json")); + } catch (Exception e) { + throw new RuntimeException(e); + } + Request.Builder _requestBuilder = new Request.Builder() + .url(_httpUrl) + .method("PUT", _requestBody) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Content-Type", "application/json"); + Request _request = _requestBuilder.build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), UserResponse.class); + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public void lookup(String property, String value) { + lookup(property, value, null); + } + + public void lookup(String property, String value, RequestOptions requestOptions) { + HttpUrl _httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("user-lookup") + .addPathSegment(property) + .addPathSegment(value) + .build(); + Request _request = new Request.Builder() + .url(_httpUrl) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .build(); + try { + Response _response = clientOptions.httpClient().newCall(_request).execute(); + if (_response.isSuccessful()) { + return; + } + throw new ApiError( + _response.code(), + ObjectMappers.JSON_MAPPER.readValue(_response.body().string(), Object.class)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersCreateRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersCreateRequest.java new file mode 100644 index 0000000..67a1b3a --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersCreateRequest.java @@ -0,0 +1,239 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.codecombat.api.types.UsersCreateRequestHeroConfig; +import com.codecombat.api.types.UsersCreateRequestRole; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersCreateRequest.Builder.class) +public final class UsersCreateRequest { + private final String name; + + private final String email; + + private final Optional role; + + private final Optional preferredLanguage; + + private final Optional heroConfig; + + private final Optional birthday; + + private UsersCreateRequest( + String name, + String email, + Optional role, + Optional preferredLanguage, + Optional heroConfig, + Optional birthday) { + this.name = name; + this.email = email; + this.role = role; + this.preferredLanguage = preferredLanguage; + this.heroConfig = heroConfig; + this.birthday = birthday; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * @return "student" or "teacher". If unset, a home user will be created, unable to join classrooms. + */ + @JsonProperty("role") + public Optional getRole() { + return role; + } + + @JsonProperty("preferredLanguage") + public Optional getPreferredLanguage() { + return preferredLanguage; + } + + @JsonProperty("heroConfig") + public Optional getHeroConfig() { + return heroConfig; + } + + @JsonProperty("birthday") + public Optional getBirthday() { + return birthday; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersCreateRequest && equalTo((UsersCreateRequest) other); + } + + private boolean equalTo(UsersCreateRequest other) { + return name.equals(other.name) + && email.equals(other.email) + && role.equals(other.role) + && preferredLanguage.equals(other.preferredLanguage) + && heroConfig.equals(other.heroConfig) + && birthday.equals(other.birthday); + } + + @Override + public int hashCode() { + return Objects.hash(this.name, this.email, this.role, this.preferredLanguage, this.heroConfig, this.birthday); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + EmailStage name(String name); + + Builder from(UsersCreateRequest other); + } + + public interface EmailStage { + _FinalStage email(String email); + } + + public interface _FinalStage { + UsersCreateRequest build(); + + _FinalStage role(Optional role); + + _FinalStage role(UsersCreateRequestRole role); + + _FinalStage preferredLanguage(Optional preferredLanguage); + + _FinalStage preferredLanguage(String preferredLanguage); + + _FinalStage heroConfig(Optional heroConfig); + + _FinalStage heroConfig(UsersCreateRequestHeroConfig heroConfig); + + _FinalStage birthday(Optional birthday); + + _FinalStage birthday(String birthday); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, EmailStage, _FinalStage { + private String name; + + private String email; + + private Optional birthday = Optional.empty(); + + private Optional heroConfig = Optional.empty(); + + private Optional preferredLanguage = Optional.empty(); + + private Optional role = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(UsersCreateRequest other) { + name(other.getName()); + email(other.getEmail()); + role(other.getRole()); + preferredLanguage(other.getPreferredLanguage()); + heroConfig(other.getHeroConfig()); + birthday(other.getBirthday()); + return this; + } + + @Override + @JsonSetter("name") + public EmailStage name(String name) { + this.name = name; + return this; + } + + @Override + @JsonSetter("email") + public _FinalStage email(String email) { + this.email = email; + return this; + } + + @Override + public _FinalStage birthday(String birthday) { + this.birthday = Optional.of(birthday); + return this; + } + + @Override + @JsonSetter(value = "birthday", nulls = Nulls.SKIP) + public _FinalStage birthday(Optional birthday) { + this.birthday = birthday; + return this; + } + + @Override + public _FinalStage heroConfig(UsersCreateRequestHeroConfig heroConfig) { + this.heroConfig = Optional.of(heroConfig); + return this; + } + + @Override + @JsonSetter(value = "heroConfig", nulls = Nulls.SKIP) + public _FinalStage heroConfig(Optional heroConfig) { + this.heroConfig = heroConfig; + return this; + } + + @Override + public _FinalStage preferredLanguage(String preferredLanguage) { + this.preferredLanguage = Optional.of(preferredLanguage); + return this; + } + + @Override + @JsonSetter(value = "preferredLanguage", nulls = Nulls.SKIP) + public _FinalStage preferredLanguage(Optional preferredLanguage) { + this.preferredLanguage = preferredLanguage; + return this; + } + + /** + *

"student" or "teacher". If unset, a home user will be created, unable to join classrooms.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage role(UsersCreateRequestRole role) { + this.role = Optional.of(role); + return this; + } + + @Override + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public _FinalStage role(Optional role) { + this.role = role; + return this; + } + + @Override + public UsersCreateRequest build() { + return new UsersCreateRequest(name, email, role, preferredLanguage, heroConfig, birthday); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersGetClassroomsRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersGetClassroomsRequest.java new file mode 100644 index 0000000..3f29693 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersGetClassroomsRequest.java @@ -0,0 +1,80 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersGetClassroomsRequest.Builder.class) +public final class UsersGetClassroomsRequest { + private final Optional retMemberLimit; + + private UsersGetClassroomsRequest(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + } + + /** + * @return limit the return number of members for each classroom + */ + @JsonProperty("retMemberLimit") + public Optional getRetMemberLimit() { + return retMemberLimit; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersGetClassroomsRequest && equalTo((UsersGetClassroomsRequest) other); + } + + private boolean equalTo(UsersGetClassroomsRequest other) { + return retMemberLimit.equals(other.retMemberLimit); + } + + @Override + public int hashCode() { + return Objects.hash(this.retMemberLimit); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional retMemberLimit = Optional.empty(); + + private Builder() {} + + public Builder from(UsersGetClassroomsRequest other) { + retMemberLimit(other.getRetMemberLimit()); + return this; + } + + @JsonSetter(value = "retMemberLimit", nulls = Nulls.SKIP) + public Builder retMemberLimit(Optional retMemberLimit) { + this.retMemberLimit = retMemberLimit; + return this; + } + + public Builder retMemberLimit(Double retMemberLimit) { + this.retMemberLimit = Optional.of(retMemberLimit); + return this; + } + + public UsersGetClassroomsRequest build() { + return new UsersGetClassroomsRequest(retMemberLimit); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersGetRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersGetRequest.java new file mode 100644 index 0000000..720b4b8 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersGetRequest.java @@ -0,0 +1,80 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersGetRequest.Builder.class) +public final class UsersGetRequest { + private final Optional includePlayTime; + + private UsersGetRequest(Optional includePlayTime) { + this.includePlayTime = includePlayTime; + } + + /** + * @return Set to non-empty string to include stats.playTime in response + */ + @JsonProperty("includePlayTime") + public Optional getIncludePlayTime() { + return includePlayTime; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersGetRequest && equalTo((UsersGetRequest) other); + } + + private boolean equalTo(UsersGetRequest other) { + return includePlayTime.equals(other.includePlayTime); + } + + @Override + public int hashCode() { + return Objects.hash(this.includePlayTime); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional includePlayTime = Optional.empty(); + + private Builder() {} + + public Builder from(UsersGetRequest other) { + includePlayTime(other.getIncludePlayTime()); + return this; + } + + @JsonSetter(value = "includePlayTime", nulls = Nulls.SKIP) + public Builder includePlayTime(Optional includePlayTime) { + this.includePlayTime = includePlayTime; + return this; + } + + public Builder includePlayTime(String includePlayTime) { + this.includePlayTime = Optional.of(includePlayTime); + return this; + } + + public UsersGetRequest build() { + return new UsersGetRequest(includePlayTime); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantLicenseRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantLicenseRequest.java new file mode 100644 index 0000000..e8a2593 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantLicenseRequest.java @@ -0,0 +1,83 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersGrantLicenseRequest.Builder.class) +public final class UsersGrantLicenseRequest { + private final String ends; + + private UsersGrantLicenseRequest(String ends) { + this.ends = ends; + } + + @JsonProperty("ends") + public String getEnds() { + return ends; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersGrantLicenseRequest && equalTo((UsersGrantLicenseRequest) other); + } + + private boolean equalTo(UsersGrantLicenseRequest other) { + return ends.equals(other.ends); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EndsStage builder() { + return new Builder(); + } + + public interface EndsStage { + _FinalStage ends(String ends); + + Builder from(UsersGrantLicenseRequest other); + } + + public interface _FinalStage { + UsersGrantLicenseRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EndsStage, _FinalStage { + private String ends; + + private Builder() {} + + @Override + public Builder from(UsersGrantLicenseRequest other) { + ends(other.getEnds()); + return this; + } + + @Override + @JsonSetter("ends") + public _FinalStage ends(String ends) { + this.ends = ends; + return this; + } + + @Override + public UsersGrantLicenseRequest build() { + return new UsersGrantLicenseRequest(ends); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantPremiumSubscriptionRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantPremiumSubscriptionRequest.java new file mode 100644 index 0000000..017b9d0 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersGrantPremiumSubscriptionRequest.java @@ -0,0 +1,84 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersGrantPremiumSubscriptionRequest.Builder.class) +public final class UsersGrantPremiumSubscriptionRequest { + private final String ends; + + private UsersGrantPremiumSubscriptionRequest(String ends) { + this.ends = ends; + } + + @JsonProperty("ends") + public String getEnds() { + return ends; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersGrantPremiumSubscriptionRequest + && equalTo((UsersGrantPremiumSubscriptionRequest) other); + } + + private boolean equalTo(UsersGrantPremiumSubscriptionRequest other) { + return ends.equals(other.ends); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EndsStage builder() { + return new Builder(); + } + + public interface EndsStage { + _FinalStage ends(String ends); + + Builder from(UsersGrantPremiumSubscriptionRequest other); + } + + public interface _FinalStage { + UsersGrantPremiumSubscriptionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EndsStage, _FinalStage { + private String ends; + + private Builder() {} + + @Override + public Builder from(UsersGrantPremiumSubscriptionRequest other) { + ends(other.getEnds()); + return this; + } + + @Override + @JsonSetter("ends") + public _FinalStage ends(String ends) { + this.ends = ends; + return this; + } + + @Override + public UsersGrantPremiumSubscriptionRequest build() { + return new UsersGrantPremiumSubscriptionRequest(ends); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersSetAceConfigRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersSetAceConfigRequest.java new file mode 100644 index 0000000..76c2e68 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersSetAceConfigRequest.java @@ -0,0 +1,133 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersSetAceConfigRequest.Builder.class) +public final class UsersSetAceConfigRequest { + private final Optional liveCompletion; + + private final Optional behaviors; + + private final Optional language; + + private UsersSetAceConfigRequest( + Optional liveCompletion, Optional behaviors, Optional language) { + this.liveCompletion = liveCompletion; + this.behaviors = behaviors; + this.language = language; + } + + /** + * @return controls whether autocompletion snippets show up, the default value is true + */ + @JsonProperty("liveCompletion") + public Optional getLiveCompletion() { + return liveCompletion; + } + + /** + * @return controls whether things like automatic parenthesis and quote completion happens, the default value is false + */ + @JsonProperty("behaviors") + public Optional getBehaviors() { + return behaviors; + } + + /** + * @return only for home users, should be one of ["python", "javascript", "cpp", "lua", "coffeescript"] right now + */ + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersSetAceConfigRequest && equalTo((UsersSetAceConfigRequest) other); + } + + private boolean equalTo(UsersSetAceConfigRequest other) { + return liveCompletion.equals(other.liveCompletion) + && behaviors.equals(other.behaviors) + && language.equals(other.language); + } + + @Override + public int hashCode() { + return Objects.hash(this.liveCompletion, this.behaviors, this.language); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional liveCompletion = Optional.empty(); + + private Optional behaviors = Optional.empty(); + + private Optional language = Optional.empty(); + + private Builder() {} + + public Builder from(UsersSetAceConfigRequest other) { + liveCompletion(other.getLiveCompletion()); + behaviors(other.getBehaviors()); + language(other.getLanguage()); + return this; + } + + @JsonSetter(value = "liveCompletion", nulls = Nulls.SKIP) + public Builder liveCompletion(Optional liveCompletion) { + this.liveCompletion = liveCompletion; + return this; + } + + public Builder liveCompletion(Boolean liveCompletion) { + this.liveCompletion = Optional.of(liveCompletion); + return this; + } + + @JsonSetter(value = "behaviors", nulls = Nulls.SKIP) + public Builder behaviors(Optional behaviors) { + this.behaviors = behaviors; + return this; + } + + public Builder behaviors(Boolean behaviors) { + this.behaviors = Optional.of(behaviors); + return this; + } + + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public Builder language(Optional language) { + this.language = language; + return this; + } + + public Builder language(String language) { + this.language = Optional.of(language); + return this; + } + + public UsersSetAceConfigRequest build() { + return new UsersSetAceConfigRequest(liveCompletion, behaviors, language); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersSetHeroRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersSetHeroRequest.java new file mode 100644 index 0000000..b5228fa --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersSetHeroRequest.java @@ -0,0 +1,77 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersSetHeroRequest.Builder.class) +public final class UsersSetHeroRequest { + private final Optional thangType; + + private UsersSetHeroRequest(Optional thangType) { + this.thangType = thangType; + } + + @JsonProperty("thangType") + public Optional getThangType() { + return thangType; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersSetHeroRequest && equalTo((UsersSetHeroRequest) other); + } + + private boolean equalTo(UsersSetHeroRequest other) { + return thangType.equals(other.thangType); + } + + @Override + public int hashCode() { + return Objects.hash(this.thangType); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional thangType = Optional.empty(); + + private Builder() {} + + public Builder from(UsersSetHeroRequest other) { + thangType(other.getThangType()); + return this; + } + + @JsonSetter(value = "thangType", nulls = Nulls.SKIP) + public Builder thangType(Optional thangType) { + this.thangType = thangType; + return this; + } + + public Builder thangType(String thangType) { + this.thangType = Optional.of(thangType); + return this; + } + + public UsersSetHeroRequest build() { + return new UsersSetHeroRequest(thangType); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenLicenseRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenLicenseRequest.java new file mode 100644 index 0000000..76d4452 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenLicenseRequest.java @@ -0,0 +1,83 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersShortenLicenseRequest.Builder.class) +public final class UsersShortenLicenseRequest { + private final String ends; + + private UsersShortenLicenseRequest(String ends) { + this.ends = ends; + } + + @JsonProperty("ends") + public String getEnds() { + return ends; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersShortenLicenseRequest && equalTo((UsersShortenLicenseRequest) other); + } + + private boolean equalTo(UsersShortenLicenseRequest other) { + return ends.equals(other.ends); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EndsStage builder() { + return new Builder(); + } + + public interface EndsStage { + _FinalStage ends(String ends); + + Builder from(UsersShortenLicenseRequest other); + } + + public interface _FinalStage { + UsersShortenLicenseRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EndsStage, _FinalStage { + private String ends; + + private Builder() {} + + @Override + public Builder from(UsersShortenLicenseRequest other) { + ends(other.getEnds()); + return this; + } + + @Override + @JsonSetter("ends") + public _FinalStage ends(String ends) { + this.ends = ends; + return this; + } + + @Override + public UsersShortenLicenseRequest build() { + return new UsersShortenLicenseRequest(ends); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenSubscriptionRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenSubscriptionRequest.java new file mode 100644 index 0000000..a592db2 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersShortenSubscriptionRequest.java @@ -0,0 +1,83 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersShortenSubscriptionRequest.Builder.class) +public final class UsersShortenSubscriptionRequest { + private final String ends; + + private UsersShortenSubscriptionRequest(String ends) { + this.ends = ends; + } + + @JsonProperty("ends") + public String getEnds() { + return ends; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersShortenSubscriptionRequest && equalTo((UsersShortenSubscriptionRequest) other); + } + + private boolean equalTo(UsersShortenSubscriptionRequest other) { + return ends.equals(other.ends); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static EndsStage builder() { + return new Builder(); + } + + public interface EndsStage { + _FinalStage ends(String ends); + + Builder from(UsersShortenSubscriptionRequest other); + } + + public interface _FinalStage { + UsersShortenSubscriptionRequest build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements EndsStage, _FinalStage { + private String ends; + + private Builder() {} + + @Override + public Builder from(UsersShortenSubscriptionRequest other) { + ends(other.getEnds()); + return this; + } + + @Override + @JsonSetter("ends") + public _FinalStage ends(String ends) { + this.ends = ends; + return this; + } + + @Override + public UsersShortenSubscriptionRequest build() { + return new UsersShortenSubscriptionRequest(ends); + } + } +} diff --git a/src/main/java/com/codecombat/api/resources/users/requests/UsersUpdateRequest.java b/src/main/java/com/codecombat/api/resources/users/requests/UsersUpdateRequest.java new file mode 100644 index 0000000..3429320 --- /dev/null +++ b/src/main/java/com/codecombat/api/resources/users/requests/UsersUpdateRequest.java @@ -0,0 +1,127 @@ +package com.codecombat.api.resources.users.requests; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersUpdateRequest.Builder.class) +public final class UsersUpdateRequest { + private final String name; + + private final Optional birthday; + + private UsersUpdateRequest(String name, Optional birthday) { + this.name = name; + this.birthday = birthday; + } + + /** + * @return Set to new name string + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * @return Set the birthday + */ + @JsonProperty("birthday") + public Optional getBirthday() { + return birthday; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersUpdateRequest && equalTo((UsersUpdateRequest) other); + } + + private boolean equalTo(UsersUpdateRequest other) { + return name.equals(other.name) && birthday.equals(other.birthday); + } + + @Override + public int hashCode() { + return Objects.hash(this.name, this.birthday); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NameStage builder() { + return new Builder(); + } + + public interface NameStage { + _FinalStage name(String name); + + Builder from(UsersUpdateRequest other); + } + + public interface _FinalStage { + UsersUpdateRequest build(); + + _FinalStage birthday(Optional birthday); + + _FinalStage birthday(String birthday); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NameStage, _FinalStage { + private String name; + + private Optional birthday = Optional.empty(); + + private Builder() {} + + @Override + public Builder from(UsersUpdateRequest other) { + name(other.getName()); + birthday(other.getBirthday()); + return this; + } + + /** + *

Set to new name string

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + @JsonSetter("name") + public _FinalStage name(String name) { + this.name = name; + return this; + } + + /** + *

Set the birthday

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @Override + public _FinalStage birthday(String birthday) { + this.birthday = Optional.of(birthday); + return this; + } + + @Override + @JsonSetter(value = "birthday", nulls = Nulls.SKIP) + public _FinalStage birthday(Optional birthday) { + this.birthday = birthday; + return this; + } + + @Override + public UsersUpdateRequest build() { + return new UsersUpdateRequest(name, birthday); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClanResponse.java b/src/main/java/com/codecombat/api/types/ClanResponse.java new file mode 100644 index 0000000..3d6aa16 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClanResponse.java @@ -0,0 +1,281 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClanResponse.Builder.class) +public final class ClanResponse { + private final Optional id; + + private final Optional name; + + private final Optional displayName; + + private final Optional> members; + + private final Optional ownerId; + + private final Optional description; + + private final Optional type; + + private final Optional kind; + + private final Optional> metadata; + + private ClanResponse( + Optional id, + Optional name, + Optional displayName, + Optional> members, + Optional ownerId, + Optional description, + Optional type, + Optional kind, + Optional> metadata) { + this.id = id; + this.name = name; + this.displayName = displayName; + this.members = members; + this.ownerId = ownerId; + this.description = description; + this.type = type; + this.kind = kind; + this.metadata = metadata; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("displayName") + public Optional getDisplayName() { + return displayName; + } + + @JsonProperty("members") + public Optional> getMembers() { + return members; + } + + @JsonProperty("ownerID") + public Optional getOwnerId() { + return ownerId; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("type") + public Optional getType() { + return type; + } + + @JsonProperty("kind") + public Optional getKind() { + return kind; + } + + @JsonProperty("metadata") + public Optional> getMetadata() { + return metadata; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClanResponse && equalTo((ClanResponse) other); + } + + private boolean equalTo(ClanResponse other) { + return id.equals(other.id) + && name.equals(other.name) + && displayName.equals(other.displayName) + && members.equals(other.members) + && ownerId.equals(other.ownerId) + && description.equals(other.description) + && type.equals(other.type) + && kind.equals(other.kind) + && metadata.equals(other.metadata); + } + + @Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.displayName, + this.members, + this.ownerId, + this.description, + this.type, + this.kind, + this.metadata); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional displayName = Optional.empty(); + + private Optional> members = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional type = Optional.empty(); + + private Optional kind = Optional.empty(); + + private Optional> metadata = Optional.empty(); + + private Builder() {} + + public Builder from(ClanResponse other) { + id(other.getId()); + name(other.getName()); + displayName(other.getDisplayName()); + members(other.getMembers()); + ownerId(other.getOwnerId()); + description(other.getDescription()); + type(other.getType()); + kind(other.getKind()); + metadata(other.getMetadata()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "displayName", nulls = Nulls.SKIP) + public Builder displayName(Optional displayName) { + this.displayName = displayName; + return this; + } + + public Builder displayName(String displayName) { + this.displayName = Optional.of(displayName); + return this; + } + + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public Builder members(Optional> members) { + this.members = members; + return this; + } + + public Builder members(List members) { + this.members = Optional.of(members); + return this; + } + + @JsonSetter(value = "ownerID", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(String ownerId) { + this.ownerId = Optional.of(ownerId); + return this; + } + + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.of(description); + return this; + } + + @JsonSetter(value = "type", nulls = Nulls.SKIP) + public Builder type(Optional type) { + this.type = type; + return this; + } + + public Builder type(String type) { + this.type = Optional.of(type); + return this; + } + + @JsonSetter(value = "kind", nulls = Nulls.SKIP) + public Builder kind(Optional kind) { + this.kind = kind; + return this; + } + + public Builder kind(String kind) { + this.kind = Optional.of(kind); + return this; + } + + @JsonSetter(value = "metadata", nulls = Nulls.SKIP) + public Builder metadata(Optional> metadata) { + this.metadata = metadata; + return this; + } + + public Builder metadata(Map metadata) { + this.metadata = Optional.of(metadata); + return this; + } + + public ClanResponse build() { + return new ClanResponse(id, name, displayName, members, ownerId, description, type, kind, metadata); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomResponse.java b/src/main/java/com/codecombat/api/types/ClassroomResponse.java new file mode 100644 index 0000000..a0ddf1b --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomResponse.java @@ -0,0 +1,199 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomResponse.Builder.class) +public final class ClassroomResponse { + private final Optional id; + + private final Optional name; + + private final Optional> members; + + private final Optional ownerId; + + private final Optional description; + + private final Optional> courses; + + private ClassroomResponse( + Optional id, + Optional name, + Optional> members, + Optional ownerId, + Optional description, + Optional> courses) { + this.id = id; + this.name = name; + this.members = members; + this.ownerId = ownerId; + this.description = description; + this.courses = courses; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("members") + public Optional> getMembers() { + return members; + } + + @JsonProperty("ownerID") + public Optional getOwnerId() { + return ownerId; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("courses") + public Optional> getCourses() { + return courses; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomResponse && equalTo((ClassroomResponse) other); + } + + private boolean equalTo(ClassroomResponse other) { + return id.equals(other.id) + && name.equals(other.name) + && members.equals(other.members) + && ownerId.equals(other.ownerId) + && description.equals(other.description) + && courses.equals(other.courses); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.name, this.members, this.ownerId, this.description, this.courses); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional> members = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional> courses = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomResponse other) { + id(other.getId()); + name(other.getName()); + members(other.getMembers()); + ownerId(other.getOwnerId()); + description(other.getDescription()); + courses(other.getCourses()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public Builder members(Optional> members) { + this.members = members; + return this; + } + + public Builder members(List members) { + this.members = Optional.of(members); + return this; + } + + @JsonSetter(value = "ownerID", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(String ownerId) { + this.ownerId = Optional.of(ownerId); + return this; + } + + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.of(description); + return this; + } + + @JsonSetter(value = "courses", nulls = Nulls.SKIP) + public Builder courses(Optional> courses) { + this.courses = courses; + return this; + } + + public Builder courses(List courses) { + this.courses = Optional.of(courses); + return this; + } + + public ClassroomResponse build() { + return new ClassroomResponse(id, name, members, ownerId, description, courses); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomResponseCoursesItem.java b/src/main/java/com/codecombat/api/types/ClassroomResponseCoursesItem.java new file mode 100644 index 0000000..57688a5 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomResponseCoursesItem.java @@ -0,0 +1,152 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomResponseCoursesItem.Builder.class) +public final class ClassroomResponseCoursesItem { + private final Optional id; + + private final Optional>> levels; + + private final Optional> enrolled; + + private final Optional instanceId; + + private ClassroomResponseCoursesItem( + Optional id, + Optional>> levels, + Optional> enrolled, + Optional instanceId) { + this.id = id; + this.levels = levels; + this.enrolled = enrolled; + this.instanceId = instanceId; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("levels") + public Optional>> getLevels() { + return levels; + } + + @JsonProperty("enrolled") + public Optional> getEnrolled() { + return enrolled; + } + + @JsonProperty("instance_id") + public Optional getInstanceId() { + return instanceId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomResponseCoursesItem && equalTo((ClassroomResponseCoursesItem) other); + } + + private boolean equalTo(ClassroomResponseCoursesItem other) { + return id.equals(other.id) + && levels.equals(other.levels) + && enrolled.equals(other.enrolled) + && instanceId.equals(other.instanceId); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.levels, this.enrolled, this.instanceId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional>> levels = Optional.empty(); + + private Optional> enrolled = Optional.empty(); + + private Optional instanceId = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomResponseCoursesItem other) { + id(other.getId()); + levels(other.getLevels()); + enrolled(other.getEnrolled()); + instanceId(other.getInstanceId()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "levels", nulls = Nulls.SKIP) + public Builder levels(Optional>> levels) { + this.levels = levels; + return this; + } + + public Builder levels(List> levels) { + this.levels = Optional.of(levels); + return this; + } + + @JsonSetter(value = "enrolled", nulls = Nulls.SKIP) + public Builder enrolled(Optional> enrolled) { + this.enrolled = enrolled; + return this; + } + + public Builder enrolled(List enrolled) { + this.enrolled = Optional.of(enrolled); + return this; + } + + @JsonSetter(value = "instance_id", nulls = Nulls.SKIP) + public Builder instanceId(Optional instanceId) { + this.instanceId = instanceId; + return this; + } + + public Builder instanceId(String instanceId) { + this.instanceId = Optional.of(instanceId); + return this; + } + + public ClassroomResponseCoursesItem build() { + return new ClassroomResponseCoursesItem(id, levels, enrolled, instanceId); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomResponseWithCode.java b/src/main/java/com/codecombat/api/types/ClassroomResponseWithCode.java new file mode 100644 index 0000000..70c2ce5 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomResponseWithCode.java @@ -0,0 +1,281 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomResponseWithCode.Builder.class) +public final class ClassroomResponseWithCode { + private final Optional id; + + private final Optional name; + + private final Optional> members; + + private final Optional ownerId; + + private final Optional description; + + private final Optional code; + + private final Optional codeCamel; + + private final Optional> courses; + + private final Optional clanId; + + private ClassroomResponseWithCode( + Optional id, + Optional name, + Optional> members, + Optional ownerId, + Optional description, + Optional code, + Optional codeCamel, + Optional> courses, + Optional clanId) { + this.id = id; + this.name = name; + this.members = members; + this.ownerId = ownerId; + this.description = description; + this.code = code; + this.codeCamel = codeCamel; + this.courses = courses; + this.clanId = clanId; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("members") + public Optional> getMembers() { + return members; + } + + @JsonProperty("ownerID") + public Optional getOwnerId() { + return ownerId; + } + + @JsonProperty("description") + public Optional getDescription() { + return description; + } + + @JsonProperty("code") + public Optional getCode() { + return code; + } + + @JsonProperty("codeCamel") + public Optional getCodeCamel() { + return codeCamel; + } + + @JsonProperty("courses") + public Optional> getCourses() { + return courses; + } + + @JsonProperty("clanId") + public Optional getClanId() { + return clanId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomResponseWithCode && equalTo((ClassroomResponseWithCode) other); + } + + private boolean equalTo(ClassroomResponseWithCode other) { + return id.equals(other.id) + && name.equals(other.name) + && members.equals(other.members) + && ownerId.equals(other.ownerId) + && description.equals(other.description) + && code.equals(other.code) + && codeCamel.equals(other.codeCamel) + && courses.equals(other.courses) + && clanId.equals(other.clanId); + } + + @Override + public int hashCode() { + return Objects.hash( + this.id, + this.name, + this.members, + this.ownerId, + this.description, + this.code, + this.codeCamel, + this.courses, + this.clanId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional> members = Optional.empty(); + + private Optional ownerId = Optional.empty(); + + private Optional description = Optional.empty(); + + private Optional code = Optional.empty(); + + private Optional codeCamel = Optional.empty(); + + private Optional> courses = Optional.empty(); + + private Optional clanId = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomResponseWithCode other) { + id(other.getId()); + name(other.getName()); + members(other.getMembers()); + ownerId(other.getOwnerId()); + description(other.getDescription()); + code(other.getCode()); + codeCamel(other.getCodeCamel()); + courses(other.getCourses()); + clanId(other.getClanId()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "members", nulls = Nulls.SKIP) + public Builder members(Optional> members) { + this.members = members; + return this; + } + + public Builder members(List members) { + this.members = Optional.of(members); + return this; + } + + @JsonSetter(value = "ownerID", nulls = Nulls.SKIP) + public Builder ownerId(Optional ownerId) { + this.ownerId = ownerId; + return this; + } + + public Builder ownerId(String ownerId) { + this.ownerId = Optional.of(ownerId); + return this; + } + + @JsonSetter(value = "description", nulls = Nulls.SKIP) + public Builder description(Optional description) { + this.description = description; + return this; + } + + public Builder description(String description) { + this.description = Optional.of(description); + return this; + } + + @JsonSetter(value = "code", nulls = Nulls.SKIP) + public Builder code(Optional code) { + this.code = code; + return this; + } + + public Builder code(String code) { + this.code = Optional.of(code); + return this; + } + + @JsonSetter(value = "codeCamel", nulls = Nulls.SKIP) + public Builder codeCamel(Optional codeCamel) { + this.codeCamel = codeCamel; + return this; + } + + public Builder codeCamel(String codeCamel) { + this.codeCamel = Optional.of(codeCamel); + return this; + } + + @JsonSetter(value = "courses", nulls = Nulls.SKIP) + public Builder courses(Optional> courses) { + this.courses = courses; + return this; + } + + public Builder courses(List courses) { + this.courses = Optional.of(courses); + return this; + } + + @JsonSetter(value = "clanId", nulls = Nulls.SKIP) + public Builder clanId(Optional clanId) { + this.clanId = clanId; + return this; + } + + public Builder clanId(String clanId) { + this.clanId = Optional.of(clanId); + return this; + } + + public ClassroomResponseWithCode build() { + return new ClassroomResponseWithCode( + id, name, members, ownerId, description, code, codeCamel, courses, clanId); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomResponseWithCodeCoursesItem.java b/src/main/java/com/codecombat/api/types/ClassroomResponseWithCodeCoursesItem.java new file mode 100644 index 0000000..cc58342 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomResponseWithCodeCoursesItem.java @@ -0,0 +1,153 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomResponseWithCodeCoursesItem.Builder.class) +public final class ClassroomResponseWithCodeCoursesItem { + private final Optional id; + + private final Optional>> levels; + + private final Optional> enrolled; + + private final Optional instanceId; + + private ClassroomResponseWithCodeCoursesItem( + Optional id, + Optional>> levels, + Optional> enrolled, + Optional instanceId) { + this.id = id; + this.levels = levels; + this.enrolled = enrolled; + this.instanceId = instanceId; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("levels") + public Optional>> getLevels() { + return levels; + } + + @JsonProperty("enrolled") + public Optional> getEnrolled() { + return enrolled; + } + + @JsonProperty("instance_id") + public Optional getInstanceId() { + return instanceId; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomResponseWithCodeCoursesItem + && equalTo((ClassroomResponseWithCodeCoursesItem) other); + } + + private boolean equalTo(ClassroomResponseWithCodeCoursesItem other) { + return id.equals(other.id) + && levels.equals(other.levels) + && enrolled.equals(other.enrolled) + && instanceId.equals(other.instanceId); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.levels, this.enrolled, this.instanceId); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional>> levels = Optional.empty(); + + private Optional> enrolled = Optional.empty(); + + private Optional instanceId = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomResponseWithCodeCoursesItem other) { + id(other.getId()); + levels(other.getLevels()); + enrolled(other.getEnrolled()); + instanceId(other.getInstanceId()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "levels", nulls = Nulls.SKIP) + public Builder levels(Optional>> levels) { + this.levels = levels; + return this; + } + + public Builder levels(List> levels) { + this.levels = Optional.of(levels); + return this; + } + + @JsonSetter(value = "enrolled", nulls = Nulls.SKIP) + public Builder enrolled(Optional> enrolled) { + this.enrolled = enrolled; + return this; + } + + public Builder enrolled(List enrolled) { + this.enrolled = Optional.of(enrolled); + return this; + } + + @JsonSetter(value = "instance_id", nulls = Nulls.SKIP) + public Builder instanceId(Optional instanceId) { + this.instanceId = instanceId; + return this; + } + + public Builder instanceId(String instanceId) { + this.instanceId = Optional.of(instanceId); + return this; + } + + public ClassroomResponseWithCodeCoursesItem build() { + return new ClassroomResponseWithCodeCoursesItem(id, levels, enrolled, instanceId); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomsCreateRequestAceConfig.java b/src/main/java/com/codecombat/api/types/ClassroomsCreateRequestAceConfig.java new file mode 100644 index 0000000..4e6b42c --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomsCreateRequestAceConfig.java @@ -0,0 +1,80 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsCreateRequestAceConfig.Builder.class) +public final class ClassroomsCreateRequestAceConfig { + private final Optional language; + + private ClassroomsCreateRequestAceConfig(Optional language) { + this.language = language; + } + + /** + * @return Programming language for the classroom + */ + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsCreateRequestAceConfig && equalTo((ClassroomsCreateRequestAceConfig) other); + } + + private boolean equalTo(ClassroomsCreateRequestAceConfig other) { + return language.equals(other.language); + } + + @Override + public int hashCode() { + return Objects.hash(this.language); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional language = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomsCreateRequestAceConfig other) { + language(other.getLanguage()); + return this; + } + + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public Builder language(Optional language) { + this.language = language; + return this; + } + + public Builder language(String language) { + this.language = Optional.of(language); + return this; + } + + public ClassroomsCreateRequestAceConfig build() { + return new ClassroomsCreateRequestAceConfig(language); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItem.java b/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItem.java new file mode 100644 index 0000000..8679b44 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItem.java @@ -0,0 +1,101 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsGetMembersStatsResponseItem.Builder.class) +public final class ClassroomsGetMembersStatsResponseItem { + private final Optional id; + + private final Optional stats; + + private ClassroomsGetMembersStatsResponseItem( + Optional id, Optional stats) { + this.id = id; + this.stats = stats; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("stats") + public Optional getStats() { + return stats; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsGetMembersStatsResponseItem + && equalTo((ClassroomsGetMembersStatsResponseItem) other); + } + + private boolean equalTo(ClassroomsGetMembersStatsResponseItem other) { + return id.equals(other.id) && stats.equals(other.stats); + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.stats); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional stats = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomsGetMembersStatsResponseItem other) { + id(other.getId()); + stats(other.getStats()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "stats", nulls = Nulls.SKIP) + public Builder stats(Optional stats) { + this.stats = stats; + return this; + } + + public Builder stats(ClassroomsGetMembersStatsResponseItemStats stats) { + this.stats = Optional.of(stats); + return this; + } + + public ClassroomsGetMembersStatsResponseItem build() { + return new ClassroomsGetMembersStatsResponseItem(id, stats); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItemStats.java b/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItemStats.java new file mode 100644 index 0000000..82c3dc8 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/ClassroomsGetMembersStatsResponseItemStats.java @@ -0,0 +1,103 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = ClassroomsGetMembersStatsResponseItemStats.Builder.class) +public final class ClassroomsGetMembersStatsResponseItemStats { + private final Optional gamesCompleted; + + private final Optional playtime; + + private ClassroomsGetMembersStatsResponseItemStats(Optional gamesCompleted, Optional playtime) { + this.gamesCompleted = gamesCompleted; + this.playtime = playtime; + } + + @JsonProperty("gamesCompleted") + public Optional getGamesCompleted() { + return gamesCompleted; + } + + /** + * @return Total play time in seconds + */ + @JsonProperty("playtime") + public Optional getPlaytime() { + return playtime; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ClassroomsGetMembersStatsResponseItemStats + && equalTo((ClassroomsGetMembersStatsResponseItemStats) other); + } + + private boolean equalTo(ClassroomsGetMembersStatsResponseItemStats other) { + return gamesCompleted.equals(other.gamesCompleted) && playtime.equals(other.playtime); + } + + @Override + public int hashCode() { + return Objects.hash(this.gamesCompleted, this.playtime); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional gamesCompleted = Optional.empty(); + + private Optional playtime = Optional.empty(); + + private Builder() {} + + public Builder from(ClassroomsGetMembersStatsResponseItemStats other) { + gamesCompleted(other.getGamesCompleted()); + playtime(other.getPlaytime()); + return this; + } + + @JsonSetter(value = "gamesCompleted", nulls = Nulls.SKIP) + public Builder gamesCompleted(Optional gamesCompleted) { + this.gamesCompleted = gamesCompleted; + return this; + } + + public Builder gamesCompleted(Double gamesCompleted) { + this.gamesCompleted = Optional.of(gamesCompleted); + return this; + } + + @JsonSetter(value = "playtime", nulls = Nulls.SKIP) + public Builder playtime(Optional playtime) { + this.playtime = playtime; + return this; + } + + public Builder playtime(Double playtime) { + this.playtime = Optional.of(playtime); + return this; + } + + public ClassroomsGetMembersStatsResponseItemStats build() { + return new ClassroomsGetMembersStatsResponseItemStats(gamesCompleted, playtime); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/LevelSessionResponse.java b/src/main/java/com/codecombat/api/types/LevelSessionResponse.java new file mode 100644 index 0000000..9420a67 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/LevelSessionResponse.java @@ -0,0 +1,326 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LevelSessionResponse.Builder.class) +public final class LevelSessionResponse { + private final Optional state; + + private final Optional level; + + private final Optional levelId; + + private final Optional creator; + + private final Optional playtime; + + private final Optional changed; + + private final Optional created; + + private final Optional dateFirstCompleted; + + private final Optional submitted; + + private final Optional published; + + private LevelSessionResponse( + Optional state, + Optional level, + Optional levelId, + Optional creator, + Optional playtime, + Optional changed, + Optional created, + Optional dateFirstCompleted, + Optional submitted, + Optional published) { + this.state = state; + this.level = level; + this.levelId = levelId; + this.creator = creator; + this.playtime = playtime; + this.changed = changed; + this.created = created; + this.dateFirstCompleted = dateFirstCompleted; + this.submitted = submitted; + this.published = published; + } + + @JsonProperty("state") + public Optional getState() { + return state; + } + + @JsonProperty("level") + public Optional getLevel() { + return level; + } + + /** + * @return Level slug like wakka-maul + */ + @JsonProperty("levelID") + public Optional getLevelId() { + return levelId; + } + + @JsonProperty("creator") + public Optional getCreator() { + return creator; + } + + /** + * @return Time played in seconds. + */ + @JsonProperty("playtime") + public Optional getPlaytime() { + return playtime; + } + + @JsonProperty("changed") + public Optional getChanged() { + return changed; + } + + @JsonProperty("created") + public Optional getCreated() { + return created; + } + + @JsonProperty("dateFirstCompleted") + public Optional getDateFirstCompleted() { + return dateFirstCompleted; + } + + /** + * @return For arenas. Whether or not the level has been added to the ladder. + */ + @JsonProperty("submitted") + public Optional getSubmitted() { + return submitted; + } + + /** + * @return For shareable projects. Whether or not the project has been shared with classmates. + */ + @JsonProperty("published") + public Optional getPublished() { + return published; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LevelSessionResponse && equalTo((LevelSessionResponse) other); + } + + private boolean equalTo(LevelSessionResponse other) { + return state.equals(other.state) + && level.equals(other.level) + && levelId.equals(other.levelId) + && creator.equals(other.creator) + && playtime.equals(other.playtime) + && changed.equals(other.changed) + && created.equals(other.created) + && dateFirstCompleted.equals(other.dateFirstCompleted) + && submitted.equals(other.submitted) + && published.equals(other.published); + } + + @Override + public int hashCode() { + return Objects.hash( + this.state, + this.level, + this.levelId, + this.creator, + this.playtime, + this.changed, + this.created, + this.dateFirstCompleted, + this.submitted, + this.published); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional state = Optional.empty(); + + private Optional level = Optional.empty(); + + private Optional levelId = Optional.empty(); + + private Optional creator = Optional.empty(); + + private Optional playtime = Optional.empty(); + + private Optional changed = Optional.empty(); + + private Optional created = Optional.empty(); + + private Optional dateFirstCompleted = Optional.empty(); + + private Optional submitted = Optional.empty(); + + private Optional published = Optional.empty(); + + private Builder() {} + + public Builder from(LevelSessionResponse other) { + state(other.getState()); + level(other.getLevel()); + levelId(other.getLevelId()); + creator(other.getCreator()); + playtime(other.getPlaytime()); + changed(other.getChanged()); + created(other.getCreated()); + dateFirstCompleted(other.getDateFirstCompleted()); + submitted(other.getSubmitted()); + published(other.getPublished()); + return this; + } + + @JsonSetter(value = "state", nulls = Nulls.SKIP) + public Builder state(Optional state) { + this.state = state; + return this; + } + + public Builder state(LevelSessionResponseState state) { + this.state = Optional.of(state); + return this; + } + + @JsonSetter(value = "level", nulls = Nulls.SKIP) + public Builder level(Optional level) { + this.level = level; + return this; + } + + public Builder level(LevelSessionResponseLevel level) { + this.level = Optional.of(level); + return this; + } + + @JsonSetter(value = "levelID", nulls = Nulls.SKIP) + public Builder levelId(Optional levelId) { + this.levelId = levelId; + return this; + } + + public Builder levelId(String levelId) { + this.levelId = Optional.of(levelId); + return this; + } + + @JsonSetter(value = "creator", nulls = Nulls.SKIP) + public Builder creator(Optional creator) { + this.creator = creator; + return this; + } + + public Builder creator(String creator) { + this.creator = Optional.of(creator); + return this; + } + + @JsonSetter(value = "playtime", nulls = Nulls.SKIP) + public Builder playtime(Optional playtime) { + this.playtime = playtime; + return this; + } + + public Builder playtime(Integer playtime) { + this.playtime = Optional.of(playtime); + return this; + } + + @JsonSetter(value = "changed", nulls = Nulls.SKIP) + public Builder changed(Optional changed) { + this.changed = changed; + return this; + } + + public Builder changed(String changed) { + this.changed = Optional.of(changed); + return this; + } + + @JsonSetter(value = "created", nulls = Nulls.SKIP) + public Builder created(Optional created) { + this.created = created; + return this; + } + + public Builder created(String created) { + this.created = Optional.of(created); + return this; + } + + @JsonSetter(value = "dateFirstCompleted", nulls = Nulls.SKIP) + public Builder dateFirstCompleted(Optional dateFirstCompleted) { + this.dateFirstCompleted = dateFirstCompleted; + return this; + } + + public Builder dateFirstCompleted(String dateFirstCompleted) { + this.dateFirstCompleted = Optional.of(dateFirstCompleted); + return this; + } + + @JsonSetter(value = "submitted", nulls = Nulls.SKIP) + public Builder submitted(Optional submitted) { + this.submitted = submitted; + return this; + } + + public Builder submitted(Boolean submitted) { + this.submitted = Optional.of(submitted); + return this; + } + + @JsonSetter(value = "published", nulls = Nulls.SKIP) + public Builder published(Optional published) { + this.published = published; + return this; + } + + public Builder published(Boolean published) { + this.published = Optional.of(published); + return this; + } + + public LevelSessionResponse build() { + return new LevelSessionResponse( + state, + level, + levelId, + creator, + playtime, + changed, + created, + dateFirstCompleted, + submitted, + published); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/LevelSessionResponseLevel.java b/src/main/java/com/codecombat/api/types/LevelSessionResponseLevel.java new file mode 100644 index 0000000..8d0fd65 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/LevelSessionResponseLevel.java @@ -0,0 +1,80 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LevelSessionResponseLevel.Builder.class) +public final class LevelSessionResponseLevel { + private final Optional original; + + private LevelSessionResponseLevel(Optional original) { + this.original = original; + } + + /** + * @return The id for the level. + */ + @JsonProperty("original") + public Optional getOriginal() { + return original; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LevelSessionResponseLevel && equalTo((LevelSessionResponseLevel) other); + } + + private boolean equalTo(LevelSessionResponseLevel other) { + return original.equals(other.original); + } + + @Override + public int hashCode() { + return Objects.hash(this.original); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional original = Optional.empty(); + + private Builder() {} + + public Builder from(LevelSessionResponseLevel other) { + original(other.getOriginal()); + return this; + } + + @JsonSetter(value = "original", nulls = Nulls.SKIP) + public Builder original(Optional original) { + this.original = original; + return this; + } + + public Builder original(String original) { + this.original = Optional.of(original); + return this; + } + + public LevelSessionResponseLevel build() { + return new LevelSessionResponseLevel(original); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/LevelSessionResponseState.java b/src/main/java/com/codecombat/api/types/LevelSessionResponseState.java new file mode 100644 index 0000000..f55d1d9 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/LevelSessionResponseState.java @@ -0,0 +1,77 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LevelSessionResponseState.Builder.class) +public final class LevelSessionResponseState { + private final Optional complete; + + private LevelSessionResponseState(Optional complete) { + this.complete = complete; + } + + @JsonProperty("complete") + public Optional getComplete() { + return complete; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LevelSessionResponseState && equalTo((LevelSessionResponseState) other); + } + + private boolean equalTo(LevelSessionResponseState other) { + return complete.equals(other.complete); + } + + @Override + public int hashCode() { + return Objects.hash(this.complete); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional complete = Optional.empty(); + + private Builder() {} + + public Builder from(LevelSessionResponseState other) { + complete(other.getComplete()); + return this; + } + + @JsonSetter(value = "complete", nulls = Nulls.SKIP) + public Builder complete(Optional complete) { + this.complete = complete; + return this; + } + + public Builder complete(Boolean complete) { + this.complete = Optional.of(complete); + return this; + } + + public LevelSessionResponseState build() { + return new LevelSessionResponseState(complete); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/LicenseStatsResponse.java b/src/main/java/com/codecombat/api/types/LicenseStatsResponse.java new file mode 100644 index 0000000..ecc6f51 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/LicenseStatsResponse.java @@ -0,0 +1,163 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = LicenseStatsResponse.Builder.class) +public final class LicenseStatsResponse { + private final Optional licenseDaysGranted; + + private final Optional licenseDaysUsed; + + private final Optional licenseDaysRemaining; + + private final Optional activeLicenses; + + private LicenseStatsResponse( + Optional licenseDaysGranted, + Optional licenseDaysUsed, + Optional licenseDaysRemaining, + Optional activeLicenses) { + this.licenseDaysGranted = licenseDaysGranted; + this.licenseDaysUsed = licenseDaysUsed; + this.licenseDaysRemaining = licenseDaysRemaining; + this.activeLicenses = activeLicenses; + } + + /** + * @return Total number of license days granted + */ + @JsonProperty("licenseDaysGranted") + public Optional getLicenseDaysGranted() { + return licenseDaysGranted; + } + + /** + * @return Number of license days used + */ + @JsonProperty("licenseDaysUsed") + public Optional getLicenseDaysUsed() { + return licenseDaysUsed; + } + + /** + * @return Number of license days remaining + */ + @JsonProperty("licenseDaysRemaining") + public Optional getLicenseDaysRemaining() { + return licenseDaysRemaining; + } + + /** + * @return Number of active/valid licenses + */ + @JsonProperty("activeLicenses") + public Optional getActiveLicenses() { + return activeLicenses; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof LicenseStatsResponse && equalTo((LicenseStatsResponse) other); + } + + private boolean equalTo(LicenseStatsResponse other) { + return licenseDaysGranted.equals(other.licenseDaysGranted) + && licenseDaysUsed.equals(other.licenseDaysUsed) + && licenseDaysRemaining.equals(other.licenseDaysRemaining) + && activeLicenses.equals(other.activeLicenses); + } + + @Override + public int hashCode() { + return Objects.hash( + this.licenseDaysGranted, this.licenseDaysUsed, this.licenseDaysRemaining, this.activeLicenses); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional licenseDaysGranted = Optional.empty(); + + private Optional licenseDaysUsed = Optional.empty(); + + private Optional licenseDaysRemaining = Optional.empty(); + + private Optional activeLicenses = Optional.empty(); + + private Builder() {} + + public Builder from(LicenseStatsResponse other) { + licenseDaysGranted(other.getLicenseDaysGranted()); + licenseDaysUsed(other.getLicenseDaysUsed()); + licenseDaysRemaining(other.getLicenseDaysRemaining()); + activeLicenses(other.getActiveLicenses()); + return this; + } + + @JsonSetter(value = "licenseDaysGranted", nulls = Nulls.SKIP) + public Builder licenseDaysGranted(Optional licenseDaysGranted) { + this.licenseDaysGranted = licenseDaysGranted; + return this; + } + + public Builder licenseDaysGranted(Double licenseDaysGranted) { + this.licenseDaysGranted = Optional.of(licenseDaysGranted); + return this; + } + + @JsonSetter(value = "licenseDaysUsed", nulls = Nulls.SKIP) + public Builder licenseDaysUsed(Optional licenseDaysUsed) { + this.licenseDaysUsed = licenseDaysUsed; + return this; + } + + public Builder licenseDaysUsed(Double licenseDaysUsed) { + this.licenseDaysUsed = Optional.of(licenseDaysUsed); + return this; + } + + @JsonSetter(value = "licenseDaysRemaining", nulls = Nulls.SKIP) + public Builder licenseDaysRemaining(Optional licenseDaysRemaining) { + this.licenseDaysRemaining = licenseDaysRemaining; + return this; + } + + public Builder licenseDaysRemaining(Double licenseDaysRemaining) { + this.licenseDaysRemaining = Optional.of(licenseDaysRemaining); + return this; + } + + @JsonSetter(value = "activeLicenses", nulls = Nulls.SKIP) + public Builder activeLicenses(Optional activeLicenses) { + this.activeLicenses = activeLicenses; + return this; + } + + public Builder activeLicenses(Double activeLicenses) { + this.activeLicenses = Optional.of(activeLicenses); + return this; + } + + public LicenseStatsResponse build() { + return new LicenseStatsResponse(licenseDaysGranted, licenseDaysUsed, licenseDaysRemaining, activeLicenses); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/PlaytimeStatsResponse.java b/src/main/java/com/codecombat/api/types/PlaytimeStatsResponse.java new file mode 100644 index 0000000..154d980 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/PlaytimeStatsResponse.java @@ -0,0 +1,105 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = PlaytimeStatsResponse.Builder.class) +public final class PlaytimeStatsResponse { + private final Optional playTime; + + private final Optional gamesPlayed; + + private PlaytimeStatsResponse(Optional playTime, Optional gamesPlayed) { + this.playTime = playTime; + this.gamesPlayed = gamesPlayed; + } + + /** + * @return Total play time in seconds + */ + @JsonProperty("playTime") + public Optional getPlayTime() { + return playTime; + } + + /** + * @return Number of levels played + */ + @JsonProperty("gamesPlayed") + public Optional getGamesPlayed() { + return gamesPlayed; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof PlaytimeStatsResponse && equalTo((PlaytimeStatsResponse) other); + } + + private boolean equalTo(PlaytimeStatsResponse other) { + return playTime.equals(other.playTime) && gamesPlayed.equals(other.gamesPlayed); + } + + @Override + public int hashCode() { + return Objects.hash(this.playTime, this.gamesPlayed); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional playTime = Optional.empty(); + + private Optional gamesPlayed = Optional.empty(); + + private Builder() {} + + public Builder from(PlaytimeStatsResponse other) { + playTime(other.getPlayTime()); + gamesPlayed(other.getGamesPlayed()); + return this; + } + + @JsonSetter(value = "playTime", nulls = Nulls.SKIP) + public Builder playTime(Optional playTime) { + this.playTime = playTime; + return this; + } + + public Builder playTime(Double playTime) { + this.playTime = Optional.of(playTime); + return this; + } + + @JsonSetter(value = "gamesPlayed", nulls = Nulls.SKIP) + public Builder gamesPlayed(Optional gamesPlayed) { + this.gamesPlayed = gamesPlayed; + return this; + } + + public Builder gamesPlayed(Double gamesPlayed) { + this.gamesPlayed = Optional.of(gamesPlayed); + return this; + } + + public PlaytimeStatsResponse build() { + return new PlaytimeStatsResponse(playTime, gamesPlayed); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UserResponse.java b/src/main/java/com/codecombat/api/types/UserResponse.java new file mode 100644 index 0000000..5794977 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UserResponse.java @@ -0,0 +1,280 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UserResponse.Builder.class) +public final class UserResponse { + private final Optional id; + + private final Optional email; + + private final Optional name; + + private final Optional slug; + + private final Optional role; + + private final Optional stats; + + private final Optional> oAuthIdentities; + + private final Optional subscription; + + private final Optional license; + + private UserResponse( + Optional id, + Optional email, + Optional name, + Optional slug, + Optional role, + Optional stats, + Optional> oAuthIdentities, + Optional subscription, + Optional license) { + this.id = id; + this.email = email; + this.name = name; + this.slug = slug; + this.role = role; + this.stats = stats; + this.oAuthIdentities = oAuthIdentities; + this.subscription = subscription; + this.license = license; + } + + @JsonProperty("_id") + public Optional getId() { + return id; + } + + @JsonProperty("email") + public Optional getEmail() { + return email; + } + + @JsonProperty("name") + public Optional getName() { + return name; + } + + @JsonProperty("slug") + public Optional getSlug() { + return slug; + } + + @JsonProperty("role") + public Optional getRole() { + return role; + } + + @JsonProperty("stats") + public Optional getStats() { + return stats; + } + + @JsonProperty("oAuthIdentities") + public Optional> getOAuthIdentities() { + return oAuthIdentities; + } + + @JsonProperty("subscription") + public Optional getSubscription() { + return subscription; + } + + @JsonProperty("license") + public Optional getLicense() { + return license; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserResponse && equalTo((UserResponse) other); + } + + private boolean equalTo(UserResponse other) { + return id.equals(other.id) + && email.equals(other.email) + && name.equals(other.name) + && slug.equals(other.slug) + && role.equals(other.role) + && stats.equals(other.stats) + && oAuthIdentities.equals(other.oAuthIdentities) + && subscription.equals(other.subscription) + && license.equals(other.license); + } + + @Override + public int hashCode() { + return Objects.hash( + this.id, + this.email, + this.name, + this.slug, + this.role, + this.stats, + this.oAuthIdentities, + this.subscription, + this.license); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional id = Optional.empty(); + + private Optional email = Optional.empty(); + + private Optional name = Optional.empty(); + + private Optional slug = Optional.empty(); + + private Optional role = Optional.empty(); + + private Optional stats = Optional.empty(); + + private Optional> oAuthIdentities = Optional.empty(); + + private Optional subscription = Optional.empty(); + + private Optional license = Optional.empty(); + + private Builder() {} + + public Builder from(UserResponse other) { + id(other.getId()); + email(other.getEmail()); + name(other.getName()); + slug(other.getSlug()); + role(other.getRole()); + stats(other.getStats()); + oAuthIdentities(other.getOAuthIdentities()); + subscription(other.getSubscription()); + license(other.getLicense()); + return this; + } + + @JsonSetter(value = "_id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + @JsonSetter(value = "email", nulls = Nulls.SKIP) + public Builder email(Optional email) { + this.email = email; + return this; + } + + public Builder email(String email) { + this.email = Optional.of(email); + return this; + } + + @JsonSetter(value = "name", nulls = Nulls.SKIP) + public Builder name(Optional name) { + this.name = name; + return this; + } + + public Builder name(String name) { + this.name = Optional.of(name); + return this; + } + + @JsonSetter(value = "slug", nulls = Nulls.SKIP) + public Builder slug(Optional slug) { + this.slug = slug; + return this; + } + + public Builder slug(String slug) { + this.slug = Optional.of(slug); + return this; + } + + @JsonSetter(value = "role", nulls = Nulls.SKIP) + public Builder role(Optional role) { + this.role = role; + return this; + } + + public Builder role(String role) { + this.role = Optional.of(role); + return this; + } + + @JsonSetter(value = "stats", nulls = Nulls.SKIP) + public Builder stats(Optional stats) { + this.stats = stats; + return this; + } + + public Builder stats(UserResponseStats stats) { + this.stats = Optional.of(stats); + return this; + } + + @JsonSetter(value = "oAuthIdentities", nulls = Nulls.SKIP) + public Builder oAuthIdentities(Optional> oAuthIdentities) { + this.oAuthIdentities = oAuthIdentities; + return this; + } + + public Builder oAuthIdentities(List oAuthIdentities) { + this.oAuthIdentities = Optional.of(oAuthIdentities); + return this; + } + + @JsonSetter(value = "subscription", nulls = Nulls.SKIP) + public Builder subscription(Optional subscription) { + this.subscription = subscription; + return this; + } + + public Builder subscription(UserResponseSubscription subscription) { + this.subscription = Optional.of(subscription); + return this; + } + + @JsonSetter(value = "license", nulls = Nulls.SKIP) + public Builder license(Optional license) { + this.license = license; + return this; + } + + public Builder license(UserResponseLicense license) { + this.license = Optional.of(license); + return this; + } + + public UserResponse build() { + return new UserResponse(id, email, name, slug, role, stats, oAuthIdentities, subscription, license); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UserResponseLicense.java b/src/main/java/com/codecombat/api/types/UserResponseLicense.java new file mode 100644 index 0000000..ecbd4b5 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UserResponseLicense.java @@ -0,0 +1,99 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UserResponseLicense.Builder.class) +public final class UserResponseLicense { + private final Optional ends; + + private final Optional active; + + private UserResponseLicense(Optional ends, Optional active) { + this.ends = ends; + this.active = active; + } + + @JsonProperty("ends") + public Optional getEnds() { + return ends; + } + + @JsonProperty("active") + public Optional getActive() { + return active; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserResponseLicense && equalTo((UserResponseLicense) other); + } + + private boolean equalTo(UserResponseLicense other) { + return ends.equals(other.ends) && active.equals(other.active); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends, this.active); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional ends = Optional.empty(); + + private Optional active = Optional.empty(); + + private Builder() {} + + public Builder from(UserResponseLicense other) { + ends(other.getEnds()); + active(other.getActive()); + return this; + } + + @JsonSetter(value = "ends", nulls = Nulls.SKIP) + public Builder ends(Optional ends) { + this.ends = ends; + return this; + } + + public Builder ends(String ends) { + this.ends = Optional.of(ends); + return this; + } + + @JsonSetter(value = "active", nulls = Nulls.SKIP) + public Builder active(Optional active) { + this.active = active; + return this; + } + + public Builder active(Boolean active) { + this.active = Optional.of(active); + return this; + } + + public UserResponseLicense build() { + return new UserResponseLicense(ends, active); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UserResponseOAuthIdentitiesItem.java b/src/main/java/com/codecombat/api/types/UserResponseOAuthIdentitiesItem.java new file mode 100644 index 0000000..d9bd97c --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UserResponseOAuthIdentitiesItem.java @@ -0,0 +1,99 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UserResponseOAuthIdentitiesItem.Builder.class) +public final class UserResponseOAuthIdentitiesItem { + private final Optional provider; + + private final Optional id; + + private UserResponseOAuthIdentitiesItem(Optional provider, Optional id) { + this.provider = provider; + this.id = id; + } + + @JsonProperty("provider") + public Optional getProvider() { + return provider; + } + + @JsonProperty("id") + public Optional getId() { + return id; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserResponseOAuthIdentitiesItem && equalTo((UserResponseOAuthIdentitiesItem) other); + } + + private boolean equalTo(UserResponseOAuthIdentitiesItem other) { + return provider.equals(other.provider) && id.equals(other.id); + } + + @Override + public int hashCode() { + return Objects.hash(this.provider, this.id); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional provider = Optional.empty(); + + private Optional id = Optional.empty(); + + private Builder() {} + + public Builder from(UserResponseOAuthIdentitiesItem other) { + provider(other.getProvider()); + id(other.getId()); + return this; + } + + @JsonSetter(value = "provider", nulls = Nulls.SKIP) + public Builder provider(Optional provider) { + this.provider = provider; + return this; + } + + public Builder provider(String provider) { + this.provider = Optional.of(provider); + return this; + } + + @JsonSetter(value = "id", nulls = Nulls.SKIP) + public Builder id(Optional id) { + this.id = id; + return this; + } + + public Builder id(String id) { + this.id = Optional.of(id); + return this; + } + + public UserResponseOAuthIdentitiesItem build() { + return new UserResponseOAuthIdentitiesItem(provider, id); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UserResponseStats.java b/src/main/java/com/codecombat/api/types/UserResponseStats.java new file mode 100644 index 0000000..76aca69 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UserResponseStats.java @@ -0,0 +1,128 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UserResponseStats.Builder.class) +public final class UserResponseStats { + private final Optional gamesCompleted; + + private final Optional> concepts; + + private final Optional playTime; + + private UserResponseStats( + Optional gamesCompleted, Optional> concepts, Optional playTime) { + this.gamesCompleted = gamesCompleted; + this.concepts = concepts; + this.playTime = playTime; + } + + @JsonProperty("gamesCompleted") + public Optional getGamesCompleted() { + return gamesCompleted; + } + + @JsonProperty("concepts") + public Optional> getConcepts() { + return concepts; + } + + /** + * @return Included only when specifically requested on the endpoint + */ + @JsonProperty("playTime") + public Optional getPlayTime() { + return playTime; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserResponseStats && equalTo((UserResponseStats) other); + } + + private boolean equalTo(UserResponseStats other) { + return gamesCompleted.equals(other.gamesCompleted) + && concepts.equals(other.concepts) + && playTime.equals(other.playTime); + } + + @Override + public int hashCode() { + return Objects.hash(this.gamesCompleted, this.concepts, this.playTime); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional gamesCompleted = Optional.empty(); + + private Optional> concepts = Optional.empty(); + + private Optional playTime = Optional.empty(); + + private Builder() {} + + public Builder from(UserResponseStats other) { + gamesCompleted(other.getGamesCompleted()); + concepts(other.getConcepts()); + playTime(other.getPlayTime()); + return this; + } + + @JsonSetter(value = "gamesCompleted", nulls = Nulls.SKIP) + public Builder gamesCompleted(Optional gamesCompleted) { + this.gamesCompleted = gamesCompleted; + return this; + } + + public Builder gamesCompleted(Double gamesCompleted) { + this.gamesCompleted = Optional.of(gamesCompleted); + return this; + } + + @JsonSetter(value = "concepts", nulls = Nulls.SKIP) + public Builder concepts(Optional> concepts) { + this.concepts = concepts; + return this; + } + + public Builder concepts(Map concepts) { + this.concepts = Optional.of(concepts); + return this; + } + + @JsonSetter(value = "playTime", nulls = Nulls.SKIP) + public Builder playTime(Optional playTime) { + this.playTime = playTime; + return this; + } + + public Builder playTime(Double playTime) { + this.playTime = Optional.of(playTime); + return this; + } + + public UserResponseStats build() { + return new UserResponseStats(gamesCompleted, concepts, playTime); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UserResponseSubscription.java b/src/main/java/com/codecombat/api/types/UserResponseSubscription.java new file mode 100644 index 0000000..f597928 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UserResponseSubscription.java @@ -0,0 +1,99 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UserResponseSubscription.Builder.class) +public final class UserResponseSubscription { + private final Optional ends; + + private final Optional active; + + private UserResponseSubscription(Optional ends, Optional active) { + this.ends = ends; + this.active = active; + } + + @JsonProperty("ends") + public Optional getEnds() { + return ends; + } + + @JsonProperty("active") + public Optional getActive() { + return active; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UserResponseSubscription && equalTo((UserResponseSubscription) other); + } + + private boolean equalTo(UserResponseSubscription other) { + return ends.equals(other.ends) && active.equals(other.active); + } + + @Override + public int hashCode() { + return Objects.hash(this.ends, this.active); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional ends = Optional.empty(); + + private Optional active = Optional.empty(); + + private Builder() {} + + public Builder from(UserResponseSubscription other) { + ends(other.getEnds()); + active(other.getActive()); + return this; + } + + @JsonSetter(value = "ends", nulls = Nulls.SKIP) + public Builder ends(Optional ends) { + this.ends = ends; + return this; + } + + public Builder ends(String ends) { + this.ends = Optional.of(ends); + return this; + } + + @JsonSetter(value = "active", nulls = Nulls.SKIP) + public Builder active(Optional active) { + this.active = active; + return this; + } + + public Builder active(Boolean active) { + this.active = Optional.of(active); + return this; + } + + public UserResponseSubscription build() { + return new UserResponseSubscription(ends, active); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UsersCreateRequestHeroConfig.java b/src/main/java/com/codecombat/api/types/UsersCreateRequestHeroConfig.java new file mode 100644 index 0000000..9175851 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UsersCreateRequestHeroConfig.java @@ -0,0 +1,77 @@ +package com.codecombat.api.types; + +import com.codecombat.api.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Objects; +import java.util.Optional; + +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@JsonDeserialize(builder = UsersCreateRequestHeroConfig.Builder.class) +public final class UsersCreateRequestHeroConfig { + private final Optional thangType; + + private UsersCreateRequestHeroConfig(Optional thangType) { + this.thangType = thangType; + } + + @JsonProperty("thangType") + public Optional getThangType() { + return thangType; + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof UsersCreateRequestHeroConfig && equalTo((UsersCreateRequestHeroConfig) other); + } + + private boolean equalTo(UsersCreateRequestHeroConfig other) { + return thangType.equals(other.thangType); + } + + @Override + public int hashCode() { + return Objects.hash(this.thangType); + } + + @Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Optional thangType = Optional.empty(); + + private Builder() {} + + public Builder from(UsersCreateRequestHeroConfig other) { + thangType(other.getThangType()); + return this; + } + + @JsonSetter(value = "thangType", nulls = Nulls.SKIP) + public Builder thangType(Optional thangType) { + this.thangType = thangType; + return this; + } + + public Builder thangType(String thangType) { + this.thangType = Optional.of(thangType); + return this; + } + + public UsersCreateRequestHeroConfig build() { + return new UsersCreateRequestHeroConfig(thangType); + } + } +} diff --git a/src/main/java/com/codecombat/api/types/UsersCreateRequestRole.java b/src/main/java/com/codecombat/api/types/UsersCreateRequestRole.java new file mode 100644 index 0000000..c453de8 --- /dev/null +++ b/src/main/java/com/codecombat/api/types/UsersCreateRequestRole.java @@ -0,0 +1,21 @@ +package com.codecombat.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UsersCreateRequestRole { + STUDENT("student"), + + TEACHER("teacher"); + + private final String value; + + UsersCreateRequestRole(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/src/test/java/com/codecombat/api/TestClient.java b/src/test/java/com/codecombat/api/TestClient.java new file mode 100644 index 0000000..562fe91 --- /dev/null +++ b/src/test/java/com/codecombat/api/TestClient.java @@ -0,0 +1,8 @@ +package com.codecombat.api; + +public final class TestClient { + public void test() { + // Add tests here and mark this file in .fernignore + assert true; + } +}