Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new endpoints: collection types, memberships and relations #63

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
434 changes: 399 additions & 35 deletions igdbclient-core/api/android/igdbclient-core.api

Large diffs are not rendered by default.

434 changes: 399 additions & 35 deletions igdbclient-core/api/jvm/igdbclient-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ import ru.pixnews.igdbclient.model.AlternativeNameResult
import ru.pixnews.igdbclient.model.ArtworkResult
import ru.pixnews.igdbclient.model.CharacterMugShotResult
import ru.pixnews.igdbclient.model.CharacterResult
import ru.pixnews.igdbclient.model.CollectionMembershipResult
import ru.pixnews.igdbclient.model.CollectionMembershipTypeResult
import ru.pixnews.igdbclient.model.CollectionRelationResult
import ru.pixnews.igdbclient.model.CollectionRelationTypeResult
import ru.pixnews.igdbclient.model.CollectionResult
import ru.pixnews.igdbclient.model.CollectionTypeResult
import ru.pixnews.igdbclient.model.CompanyLogoResult
import ru.pixnews.igdbclient.model.CompanyResult
import ru.pixnews.igdbclient.model.CompanyWebsiteResult
Expand Down Expand Up @@ -166,6 +171,40 @@ public suspend fun IgdbClient.getCharacterMugShots(builder: ApicalypseQueryBuild
public suspend fun IgdbClient.getCollections(builder: ApicalypseQueryBuilder.() -> Unit): CollectionResult =
executeOrThrow(IgdbEndpoint.COLLECTION, apicalypseQuery(builder))

/**
* Collection memberships
*/
public suspend fun IgdbClient.getCollectionMemberships(
builder: ApicalypseQueryBuilder.() -> Unit,
): CollectionMembershipResult = executeOrThrow(IgdbEndpoint.COLLECTION_MEMBERSHIP, apicalypseQuery(builder))

/**
* Collection membership types
*/
public suspend fun IgdbClient.getCollectionMembershipTypes(
builder: ApicalypseQueryBuilder.() -> Unit,
): CollectionMembershipTypeResult = executeOrThrow(IgdbEndpoint.COLLECTION_MEMBERSHIP_TYPE, apicalypseQuery(builder))

/**
* Describes Relationship between Collections
*/
public suspend fun IgdbClient.getCollectionRelations(
builder: ApicalypseQueryBuilder.() -> Unit,
): CollectionRelationResult = executeOrThrow(IgdbEndpoint.COLLECTION_RELATION, apicalypseQuery(builder))

/**
* Collection Relation types
*/
public suspend fun IgdbClient.getCollectionRelationTypes(
builder: ApicalypseQueryBuilder.() -> Unit,
): CollectionRelationTypeResult = executeOrThrow(IgdbEndpoint.COLLECTION_RELATION_TYPE, apicalypseQuery(builder))

/**
* Collection types
*/
public suspend fun IgdbClient.getCollectionTypes(builder: ApicalypseQueryBuilder.() -> Unit): CollectionTypeResult =
executeOrThrow(IgdbEndpoint.COLLECTION_TYPE, apicalypseQuery(builder))

/**
* Video game companies. Both publishers & developers
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ import ru.pixnews.igdbclient.model.CharacterMugShot
import ru.pixnews.igdbclient.model.CharacterMugShotResult
import ru.pixnews.igdbclient.model.CharacterResult
import ru.pixnews.igdbclient.model.Collection
import ru.pixnews.igdbclient.model.CollectionMembership
import ru.pixnews.igdbclient.model.CollectionMembershipResult
import ru.pixnews.igdbclient.model.CollectionMembershipType
import ru.pixnews.igdbclient.model.CollectionMembershipTypeResult
import ru.pixnews.igdbclient.model.CollectionRelation
import ru.pixnews.igdbclient.model.CollectionRelationResult
import ru.pixnews.igdbclient.model.CollectionRelationType
import ru.pixnews.igdbclient.model.CollectionRelationTypeResult
import ru.pixnews.igdbclient.model.CollectionResult
import ru.pixnews.igdbclient.model.CollectionType
import ru.pixnews.igdbclient.model.CollectionTypeResult
import ru.pixnews.igdbclient.model.Company
import ru.pixnews.igdbclient.model.CompanyLogo
import ru.pixnews.igdbclient.model.CompanyLogoResult
Expand Down Expand Up @@ -194,6 +204,51 @@ public open class IgdbEndpoint<out R : Any>(
Collection.ADAPTER::decode,
)

/**
* Collection Memberships
*/
public val COLLECTION_MEMBERSHIP: IgdbEndpoint<CollectionMembershipResult> = IgdbEndpoint(
"collection_memberships",
CollectionMembershipResult.ADAPTER::decode,
CollectionMembership.ADAPTER::decode,
)

/**
* Collection Membership Types
*/
public val COLLECTION_MEMBERSHIP_TYPE: IgdbEndpoint<CollectionMembershipTypeResult> = IgdbEndpoint(
"collection_membership_types",
CollectionMembershipTypeResult.ADAPTER::decode,
CollectionMembershipType.ADAPTER::decode,
)

/**
* Describes Relationship between Collections
*/
public val COLLECTION_RELATION: IgdbEndpoint<CollectionRelationResult> = IgdbEndpoint(
"collection_relations",
CollectionRelationResult.ADAPTER::decode,
CollectionRelation.ADAPTER::decode,
)

/**
* Collection Relation Types
*/
public val COLLECTION_RELATION_TYPE: IgdbEndpoint<CollectionRelationTypeResult> = IgdbEndpoint(
"collection_relation_types",
CollectionRelationTypeResult.ADAPTER::decode,
CollectionRelationType.ADAPTER::decode,
)

/**
* Enums for collection types.
*/
public val COLLECTION_TYPE: IgdbEndpoint<CollectionTypeResult> = IgdbEndpoint(
"collection_types",
CollectionTypeResult.ADAPTER::decode,
CollectionType.ADAPTER::decode,
)

/**
* Video game companies. Both publishers & developers
*/
Expand Down
106 changes: 84 additions & 22 deletions igdbclient-core/src/commonMain/proto/igdbapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,79 @@ message Collection {
google.protobuf.Timestamp updated_at = 6;
string url = 7;
string checksum = 8;
CollectionType type = 9;
repeated CollectionRelation as_parent_relations = 10;
repeated CollectionRelation as_child_relations = 11;
}

message CollectionMembershipResult {
repeated CollectionMembership collectionmemberships = 1;
}

message CollectionMembership {
uint64 id = 1;
Game game = 2;
Collection collection = 3;
CollectionMembershipType type = 4;
google.protobuf.Timestamp updated_at = 5;
google.protobuf.Timestamp created_at = 6;
string checksum = 7;
}

message CollectionMembershipTypeResult {
repeated CollectionMembershipType collectionmembershiptypes = 1;
}

message CollectionMembershipType {
uint64 id = 1;
string name = 2;
string description = 3;
CollectionType allowed_collection_type = 4;
google.protobuf.Timestamp updated_at = 5;
google.protobuf.Timestamp created_at = 6;
string checksum = 7;
}

message CollectionRelationResult {
repeated CollectionRelation collectionrelations = 1;
}

message CollectionRelation {
uint64 id = 1;
Collection child_collection = 2;
Collection parent_collection = 3;
CollectionRelationType type = 4;
google.protobuf.Timestamp updated_at = 5;
google.protobuf.Timestamp created_at = 6;
string checksum = 7;
}

message CollectionRelationTypeResult {
repeated CollectionRelationType collectionrelationtypes = 1;
}

message CollectionRelationType {
uint64 id = 1;
string name = 2;
string description = 3;
CollectionType allowed_child_type = 4;
CollectionType allowed_parent_type = 5;
google.protobuf.Timestamp updated_at = 6;
google.protobuf.Timestamp created_at = 7;
string checksum = 8;
}

message CollectionTypeResult {
repeated CollectionType collectiontypes = 1;
}

message CollectionType {
uint64 id = 1;
string name = 2;
string description = 3;
google.protobuf.Timestamp updated_at = 4;
google.protobuf.Timestamp created_at = 5;
string checksum = 6;
}

message CompanyResult {
Expand Down Expand Up @@ -405,28 +478,16 @@ message Event {
string description = 3;
string slug = 4;
EventLogo event_logo = 5;
repeated EventEventCategoriesEnum event_categories = 6;
google.protobuf.Timestamp start_time = 7;
string time_zone = 8;
google.protobuf.Timestamp end_time = 9;
string live_stream_url = 10;
repeated Game games = 11;
repeated GameVideo videos = 12;
repeated EventNetwork event_networks = 13;
google.protobuf.Timestamp created_at = 14;
google.protobuf.Timestamp updated_at = 15;
string checksum = 16;
}


enum EventEventCategoriesEnum {
EVENT_EVENT_CATEGORIES_NULL = 0;
INDUSTRY_CONFERENCE = 1;
STREAM_EVENT = 2;
AWARD = 3;
GAME_EXPO = 4;
E_SPORT = 5;
OTHER_MISC = 6;
google.protobuf.Timestamp start_time = 6;
string time_zone = 7;
google.protobuf.Timestamp end_time = 8;
string live_stream_url = 9;
repeated Game games = 10;
repeated GameVideo videos = 11;
repeated EventNetwork event_networks = 12;
google.protobuf.Timestamp created_at = 13;
google.protobuf.Timestamp updated_at = 14;
string checksum = 15;
}

message EventLogoResult {
Expand Down Expand Up @@ -590,6 +651,7 @@ message Game {
repeated Game forks = 55;
repeated LanguageSupport language_supports = 56;
repeated GameLocalization game_localizations = 57;
repeated Collection collections = 58;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import ru.pixnews.igdbclient.auth.twitch.InMemoryTwitchTokenStorage
import ru.pixnews.igdbclient.auth.twitch.TwitchTokenPayload
import ru.pixnews.igdbclient.dsl.field.field
import ru.pixnews.igdbclient.executeOrThrow
import ru.pixnews.igdbclient.getCollectionMembershipTypes
import ru.pixnews.igdbclient.getCollectionMemberships
import ru.pixnews.igdbclient.getCollectionRelationTypes
import ru.pixnews.igdbclient.getCollectionRelations
import ru.pixnews.igdbclient.getCollectionTypes
import ru.pixnews.igdbclient.getEventLogos
import ru.pixnews.igdbclient.getEventNetworks
import ru.pixnews.igdbclient.getEvents
Expand All @@ -32,6 +37,10 @@ import ru.pixnews.igdbclient.getNetworkTypes
import ru.pixnews.igdbclient.ktor.integration.IgdbKtorLogger
import ru.pixnews.igdbclient.library.test.TestingLoggers
import ru.pixnews.igdbclient.library.test.jupiter.MainCoroutineExtension
import ru.pixnews.igdbclient.model.CollectionMembership
import ru.pixnews.igdbclient.model.CollectionMembershipType
import ru.pixnews.igdbclient.model.CollectionRelation
import ru.pixnews.igdbclient.model.CollectionType
import ru.pixnews.igdbclient.model.Event
import ru.pixnews.igdbclient.model.EventLogo
import ru.pixnews.igdbclient.model.EventNetwork
Expand Down Expand Up @@ -178,6 +187,41 @@ class RealKtorNetworkTestClient {
Unit
}

@Test
fun testCollectionTypes() = runBlocking {
val collectionMemberships = client.getCollectionMemberships {
fields(CollectionMembership.field.all)
limit(10)
}
logger.i { "collection memberships: $collectionMemberships" }

val collectionMembershipTypes = client.getCollectionMembershipTypes {
fields(CollectionMembershipType.field.all)
limit(10)
}
logger.i { "collection membership types: $collectionMembershipTypes" }

val collectionRelations = client.getCollectionRelations {
fields(CollectionRelation.field.all)
limit(10)
}
logger.i { "collection relations: $collectionRelations" }

val collectionRelationTypes = client.getCollectionRelationTypes {
fields(CollectionMembershipType.field.all)
limit(10)
}
logger.i { "collection relation types: $collectionRelationTypes" }

val collectionTypes = client.getCollectionTypes {
fields(CollectionType.field.all)
limit(10)
}
logger.i { "collection types: $collectionTypes" }

Unit
}

class TestTokenProperties(
val clientId: String?,
val clientSecret: String?,
Expand Down