Skip to content

Commit

Permalink
Add new endpoints: collection types, memberships and relations
Browse files Browse the repository at this point in the history
* collection_memberships
* collection_membership_types
* collection_relations
* collection_relation_types
* collection_types
  • Loading branch information
illarionov committed Nov 2, 2023
1 parent 70c8d0b commit 9cb549c
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 0 deletions.
10 changes: 10 additions & 0 deletions igdbclient-core/api/android/igdbclient-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public final class ru/pixnews/igdbclient/IgdbClientKt {
public static final fun getArtworks (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCharacterMugShots (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCharacters (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionMembershipTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionMemberships (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionRelationTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionRelations (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollections (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCompanies (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCompanyLogos (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -79,6 +84,11 @@ public final class ru/pixnews/igdbclient/IgdbEndpoint$Companion {
public final fun getCHARACTER ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCHARACTER_MUG_SHOT ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_MEMBERSHIP ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_MEMBERSHIP_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_RELATION ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_RELATION_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY_LOGO ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY_WEBSITE ()Lru/pixnews/igdbclient/IgdbEndpoint;
Expand Down
10 changes: 10 additions & 0 deletions igdbclient-core/api/jvm/igdbclient-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public final class ru/pixnews/igdbclient/IgdbClientKt {
public static final fun getArtworks (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCharacterMugShots (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCharacters (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionMembershipTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionMemberships (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionRelationTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionRelations (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollectionTypes (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCollections (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCompanies (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun getCompanyLogos (Lru/pixnews/igdbclient/IgdbClient;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -79,6 +84,11 @@ public final class ru/pixnews/igdbclient/IgdbEndpoint$Companion {
public final fun getCHARACTER ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCHARACTER_MUG_SHOT ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_MEMBERSHIP ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_MEMBERSHIP_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_RELATION ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_RELATION_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOLLECTION_TYPE ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY_LOGO ()Lru/pixnews/igdbclient/IgdbEndpoint;
public final fun getCOMPANY_WEBSITE ()Lru/pixnews/igdbclient/IgdbEndpoint;
Expand Down
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
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

0 comments on commit 9cb549c

Please sign in to comment.