Skip to content

Commit

Permalink
Popularity Primitive Update (#28)
Browse files Browse the repository at this point in the history
* Popularity Primitive Update
  • Loading branch information
husnjak authored Jul 17, 2024
1 parent 48a8860 commit 4e996c4
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -34,15 +34,15 @@ __Maven__
<dependency>
<groupId>io.github.husnjak</groupId>
<artifactId>igdb-api-jvm</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```

__Gradle__

``` gradle
dependencies {
implementation 'io.github.husnjak:igdb-api-jvm:1.1.0'
implementation 'io.github.husnjak:igdb-api-jvm:1.2.0'
}
```

Expand Down
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
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"
}

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"
Expand All @@ -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")
Expand All @@ -60,6 +59,7 @@ tasks {
compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
}

dokkaJavadoc {
outputDirectory.set(buildDir.resolve("javadoc"))
dependsOn(getTasksByName("generateProto", true))
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Change Summary
_Describe your change_
10 changes: 10 additions & 0 deletions src/main/kotlin/com/api/igdb/request/JsonRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
11 changes: 11 additions & 0 deletions src/main/kotlin/com/api/igdb/request/ProtoRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,14 @@ fun IGDBWrapper.collectionMembershipTypes(APICalypse: APICalypse): List<Collecti
return CollectionMembershipTypeResult.parseFrom(bytes).collectionmembershiptypesList
}

@Throws(RequestException::class)
fun IGDBWrapper.popularityTypes(APICalypse: APICalypse): List<PopularityType> {
val bytes = apiProtoRequest(Endpoints.POPULARITY_TYPES, APICalypse.buildQuery())
return PopularityTypeResult.parseFrom(bytes).popularitytypesList
}

@Throws(RequestException::class)
fun IGDBWrapper.popularityPrimitives(APICalypse: APICalypse): List<PopularityPrimitive> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_MEMBERSHIP_TYPES, APICalypse.buildQuery())
return PopularityPrimitiveResult.parseFrom(bytes).popularityprimitivesList
}
4 changes: 3 additions & 1 deletion src/main/kotlin/com/api/igdb/utils/Endpoints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
37 changes: 36 additions & 1 deletion src/resources/com/api/igdb/igdbproto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 13 additions & 1 deletion src/test/kotlin/com/api/igdb/TestProtobufRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class TestProtobufRequest {
@Test
fun testCollectionRelations() {
val result = wrapper.collectionRelations(APICalypse())
assert(result.isNotEmpty())
assert(result.isEmpty()) // Currently no data..
}

@Test
Expand All @@ -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())
}

}

0 comments on commit 4e996c4

Please sign in to comment.