From 4e996c411c2f5640a9b362b9cbac46b683b5622d Mon Sep 17 00:00:00 2001 From: husnjak Date: Wed, 17 Jul 2024 09:52:00 +0200 Subject: [PATCH] Popularity Primitive Update (#28) * Popularity Primitive Update --- .github/workflows/test.yml | 2 + README.md | 6 +-- build.gradle.kts | 12 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- pull_request_template.md | 2 + .../com/api/igdb/request/JsonRequest.kt | 10 +++++ .../com/api/igdb/request/ProtoRequest.kt | 11 ++++++ .../kotlin/com/api/igdb/utils/Endpoints.kt | 4 +- src/resources/com/api/igdb/igdbproto.proto | 37 ++++++++++++++++++- .../com/api/igdb/TestProtobufRequest.kt | 14 ++++++- 10 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 pull_request_template.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32f0d68..c400073 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,4 +22,6 @@ jobs: client_id: "${{ secrets.CLIENT_ID }}" client_secret: "${{ secrets.CLIENT_SECRET }}" bearer: "${{ secrets.BEARER_TOKEN }}" + proxy_api_key: "${{ secrets.PROXY_KEY }}" + proxy_url: "${{ secrets.PROXY_URL }}" ORG_GRADLE_PROJECT_version: Build-${{ github.run_id }}" diff --git a/README.md b/README.md index 2dd7e3c..c635b9d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Maven Central](https://img.shields.io/maven-central/v/io.github.husnjak/igdb-api-jvm?versionPrefix=1.1.0)](https://central.sonatype.com/artifact/io.github.husnjak/igdb-api-jvm/1.1.0) +[![Maven Central](https://img.shields.io/maven-central/v/io.github.husnjak/igdb-api-jvm?versionPrefix=1.2.0)](https://central.sonatype.com/artifact/io.github.husnjak/igdb-api-jvm/1.2.0) [![](https://jitpack.io/v/husnjak/IGDB-API-JVM.svg)](https://jitpack.io/#husnjak/IGDB-API-JVM) # IGDB API-JVM (V4) A Kotlin wrapper for the IGDB.com Video Game Database API. @@ -34,7 +34,7 @@ __Maven__ io.github.husnjak igdb-api-jvm - 1.1.0 + 1.2.0 ``` @@ -42,7 +42,7 @@ __Gradle__ ``` gradle dependencies { - implementation 'io.github.husnjak:igdb-api-jvm:1.1.0' + implementation 'io.github.husnjak:igdb-api-jvm:1.2.0' } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 708e6b5..6f41eaf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,12 @@ -import com.google.protobuf.gradle.ExecutableLocator import com.google.protobuf.gradle.GenerateProtoTask import de.undercouch.gradle.tasks.download.Download plugins { - kotlin("jvm") version "1.9.20" - id("org.jetbrains.dokka") version "1.9.10" + kotlin("jvm") version "1.9.24" + id("org.jetbrains.dokka") version "1.9.20" id("maven-publish") id("signing") - id("de.undercouch.download") version "5.5.0" + id("de.undercouch.download") version "5.6.0" id("com.google.protobuf") version "0.9.4" } @@ -15,7 +14,7 @@ group = "io.github.husnjak" version = findProperty("version") as String val fuelVersion = "2.3.1" -val protobufJavaVersion = "3.24.3" +val protobufJavaVersion = "4.27.2" val junitJupiterVersion = "5.10.0" val junitPlatformVersion = "1.10.0" val protobufPluginVersion = "0.9.4" @@ -33,7 +32,7 @@ dependencies { implementation("com.github.kittinunf.fuel:fuel-android:$fuelVersion") // Protocol Buffers // set to api() to add protobuf to client classpath - api("com.google.protobuf:protobuf-java:$protobufJavaVersion") + api("com.google.protobuf:protobuf-kotlin:$protobufJavaVersion") implementation("com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion") // Tests testImplementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion") @@ -60,6 +59,7 @@ tasks { compileTestKotlin { kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString() } + dokkaJavadoc { outputDirectory.set(buildDir.resolve("javadoc")) dependsOn(getTasksByName("generateProto", true)) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586..19cfad9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..7823865 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,2 @@ +### Change Summary +_Describe your change_ diff --git a/src/main/kotlin/com/api/igdb/request/JsonRequest.kt b/src/main/kotlin/com/api/igdb/request/JsonRequest.kt index 470ce07..73953d9 100644 --- a/src/main/kotlin/com/api/igdb/request/JsonRequest.kt +++ b/src/main/kotlin/com/api/igdb/request/JsonRequest.kt @@ -260,3 +260,13 @@ fun IGDBWrapper.jsonCollectionMemberships(APICalypse: APICalypse): String { fun IGDBWrapper.jsonCollectionMembershipTypes(APICalypse: APICalypse): String { return apiJsonRequest(Endpoints.COLLECTION_MEMBERSHIP_TYPES, APICalypse.buildQuery()) } + +@Throws(RequestException::class) +fun IGDBWrapper.jsonPopularityTypes(APICalypse: APICalypse): String { + return apiJsonRequest(Endpoints.POPULARITY_TYPES, APICalypse.buildQuery()) +} + +@Throws(RequestException::class) +fun IGDBWrapper.jsonPopularityPrimitives(APICalypse: APICalypse): String { + return apiJsonRequest(Endpoints.POPULARITY_PRIMITIVES, APICalypse.buildQuery()) +} diff --git a/src/main/kotlin/com/api/igdb/request/ProtoRequest.kt b/src/main/kotlin/com/api/igdb/request/ProtoRequest.kt index 5195c01..ad10eb9 100644 --- a/src/main/kotlin/com/api/igdb/request/ProtoRequest.kt +++ b/src/main/kotlin/com/api/igdb/request/ProtoRequest.kt @@ -320,3 +320,14 @@ fun IGDBWrapper.collectionMembershipTypes(APICalypse: APICalypse): List { + val bytes = apiProtoRequest(Endpoints.POPULARITY_TYPES, APICalypse.buildQuery()) + return PopularityTypeResult.parseFrom(bytes).popularitytypesList +} + +@Throws(RequestException::class) +fun IGDBWrapper.popularityPrimitives(APICalypse: APICalypse): List { + val bytes = apiProtoRequest(Endpoints.COLLECTION_MEMBERSHIP_TYPES, APICalypse.buildQuery()) + return PopularityPrimitiveResult.parseFrom(bytes).popularityprimitivesList +} \ No newline at end of file diff --git a/src/main/kotlin/com/api/igdb/utils/Endpoints.kt b/src/main/kotlin/com/api/igdb/utils/Endpoints.kt index b4a664a..8e494ff 100644 --- a/src/main/kotlin/com/api/igdb/utils/Endpoints.kt +++ b/src/main/kotlin/com/api/igdb/utils/Endpoints.kt @@ -9,7 +9,9 @@ enum class Endpoints : Endpoint { GAME_ENGINE_LOGOS, GAME_LOCALIZATIONS, GAME_MODES, GAME_VERSIONS, GAME_VERSION_FEATURES, GAME_VERSION_FEATURE_VALUES, GAME_VIDEOS, GENRES, INVOLVED_COMPANIES, KEYWORDS, LANGUAGES, LANGUAGE_SUPPORTS, LANGUAGE_SUPPORT_TYPES, MULTIPLAYER_MODES, PLATFORMS, PLATFORM_LOGOS, PLATFORM_VERSIONS, PLATFORM_VERSION_COMPANIES, PLATFORM_VERSION_RELEASE_DATES, - PLATFORM_WEBSITES, PLAYER_PERSPECTIVES, PLATFORM_FAMILIES, REGIONS, RELEASE_DATES, SCREENSHOTS, SEARCH, THEMES, WEBSITES, EVENTS, EVENT_LOGOS, EVENT_NETWORKS, NETWORK_TYPES, COLLECTION_RELATIONS, COLLECTION_RELATION_TYPES,COLLECTION_TYPES, COLLECTION_MEMBERSHIPS, COLLECTION_MEMBERSHIP_TYPES; + PLATFORM_WEBSITES, PLAYER_PERSPECTIVES, PLATFORM_FAMILIES, REGIONS, RELEASE_DATES, SCREENSHOTS, SEARCH, THEMES, + WEBSITES, EVENTS, EVENT_LOGOS, EVENT_NETWORKS, NETWORK_TYPES, COLLECTION_RELATIONS, COLLECTION_RELATION_TYPES, + COLLECTION_TYPES, COLLECTION_MEMBERSHIPS, COLLECTION_MEMBERSHIP_TYPES, POPULARITY_TYPES, POPULARITY_PRIMITIVES; override fun url(): String { diff --git a/src/resources/com/api/igdb/igdbproto.proto b/src/resources/com/api/igdb/igdbproto.proto index 7c627c1..6150fbe 100644 --- a/src/resources/com/api/igdb/igdbproto.proto +++ b/src/resources/com/api/igdb/igdbproto.proto @@ -607,7 +607,7 @@ message Game { repeated Game expansions = 13; repeated ExternalGame external_games = 14; google.protobuf.Timestamp first_release_date = 15; - int32 follows = 16; + int32 follows = 16 [deprecated = true]; Franchise franchise = 17; repeated Franchise franchises = 18; repeated GameEngine game_engines = 19; @@ -1092,6 +1092,41 @@ message PlayerPerspective { string checksum = 7; } +message PopularityPrimitiveResult { + repeated PopularityPrimitive popularityprimitives = 1; +} + +message PopularityPrimitive { + uint64 id = 1; + int32 game_id = 2; + PopularityType popularity_type = 3; + PopularitySourcePopularitySourceEnum popularity_source = 4; + double value = 5; + google.protobuf.Timestamp calculated_at = 6; + google.protobuf.Timestamp created_at = 7; + google.protobuf.Timestamp updated_at = 8; + string checksum = 9; +} + + +enum PopularitySourcePopularitySourceEnum { + POPULARITYSOURCE_POPULARITY_SOURCE_NULL = 0; + IGDB = 121; +} + +message PopularityTypeResult { + repeated PopularityType popularitytypes = 1; +} + +message PopularityType { + uint64 id = 1; + PopularitySourcePopularitySourceEnum popularity_source = 2; + string name = 3; + google.protobuf.Timestamp created_at = 4; + google.protobuf.Timestamp updated_at = 5; + string checksum = 6; +} + message RegionResult { repeated Region regions = 1; } diff --git a/src/test/kotlin/com/api/igdb/TestProtobufRequest.kt b/src/test/kotlin/com/api/igdb/TestProtobufRequest.kt index 70b7307..43f1749 100644 --- a/src/test/kotlin/com/api/igdb/TestProtobufRequest.kt +++ b/src/test/kotlin/com/api/igdb/TestProtobufRequest.kt @@ -340,7 +340,7 @@ class TestProtobufRequest { @Test fun testCollectionRelations() { val result = wrapper.collectionRelations(APICalypse()) - assert(result.isNotEmpty()) + assert(result.isEmpty()) // Currently no data.. } @Test @@ -366,5 +366,17 @@ class TestProtobufRequest { val result = wrapper.collectionMembershipTypes(APICalypse()) assert(result.isNotEmpty()) } + + @Test + fun testPopularityTypes() { + val result = wrapper.popularityTypes(APICalypse()) + assert(result.isNotEmpty()) + } + + @Test + fun testPopularityPrimitives() { + val result = wrapper.popularityPrimitives(APICalypse()) + assert(result.isNotEmpty()) + } }