Skip to content

Commit

Permalink
Added helpers for requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
innala committed Nov 9, 2023
1 parent 8de4a72 commit 1e02280
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/main/kotlin/com/api/igdb/request/JsonRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,45 @@ fun IGDBWrapper.jsonThemes(APICalypse: APICalypse): String {
fun IGDBWrapper.jsonWebsites(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.WEBSITES, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonEvents(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.EVENTS, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonEventLogos(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.EVENT_LOGOS, APICalypse.buildQuery())
}
@Throws(RequestException::class)
fun IGDBWrapper.jsonEventNetworks(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.EVENT_NETWORKS, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonNetworkTypes(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.NETWORK_TYPES, APICalypse.buildQuery())
}
@Throws(RequestException::class)
fun IGDBWrapper.jsonCollectionRelations(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.COLLECTION_RELATIONS, APICalypse.buildQuery())
}
@Throws(RequestException::class)
fun IGDBWrapper.jsonCollectionRelationTypes(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.COLLECTION_RELATION_TYPES, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonCollectionTypes(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.COLLECTION_TYPES, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonCollectionMemberships(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.COLLECTION_MEMBERSHIPS, APICalypse.buildQuery())
}

@Throws(RequestException::class)
fun IGDBWrapper.jsonCollectionMembershipTypes(APICalypse: APICalypse): String {
return apiJsonRequest(Endpoints.COLLECTION_MEMBERSHIP_TYPES, APICalypse.buildQuery())
}
56 changes: 56 additions & 0 deletions src/main/kotlin/com/api/igdb/request/ProtoRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,59 @@ fun IGDBWrapper.websites(APICalypse: APICalypse): List<Website> {
val bytes = apiProtoRequest(Endpoints.WEBSITES, APICalypse.buildQuery())
return WebsiteResult.parseFrom(bytes).websitesList
}

@Throws(RequestException::class)
fun IGDBWrapper.events(APICalypse: APICalypse): List<Event> {
val bytes = apiProtoRequest(Endpoints.EVENTS, APICalypse.buildQuery())
return EventResult.parseFrom(bytes).eventsList
}

@Throws(RequestException::class)
fun IGDBWrapper.eventLogos(APICalypse: APICalypse): List<EventLogo> {
val bytes = apiProtoRequest(Endpoints.EVENT_LOGOS, APICalypse.buildQuery())
return EventLogoResult.parseFrom(bytes).eventlogosList
}


@Throws(RequestException::class)
fun IGDBWrapper.eventNetworks(APICalypse: APICalypse): List<EventNetwork> {
val bytes = apiProtoRequest(Endpoints.EVENT_NETWORKS, APICalypse.buildQuery())
return EventNetworkResult.parseFrom(bytes).eventnetworksList
}

@Throws(RequestException::class)
fun IGDBWrapper.networkTypes(APICalypse: APICalypse): List<NetworkType> {
val bytes = apiProtoRequest(Endpoints.NETWORK_TYPES, APICalypse.buildQuery())
return NetworkTypeResult.parseFrom(bytes).networktypesList
}

@Throws(RequestException::class)
fun IGDBWrapper.collectionRelations(APICalypse: APICalypse): List<CollectionRelation> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_RELATIONS, APICalypse.buildQuery())
return CollectionRelationResult.parseFrom(bytes).collectionrelationsList
}

@Throws(RequestException::class)
fun IGDBWrapper.collectionRelationTypes(APICalypse: APICalypse): List<CollectionRelationType> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_RELATION_TYPES, APICalypse.buildQuery())
return CollectionRelationTypeResult.parseFrom(bytes).collectionrelationtypesList
}

@Throws(RequestException::class)
fun IGDBWrapper.collectionTypes(APICalypse: APICalypse): List<CollectionType> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_TYPES, APICalypse.buildQuery())
return CollectionTypeResult.parseFrom(bytes).collectiontypesList
}

@Throws(RequestException::class)
fun IGDBWrapper.collectionMemberships(APICalypse: APICalypse): List<CollectionMembership> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_MEMBERSHIPS, APICalypse.buildQuery())
return CollectionMembershipResult.parseFrom(bytes).collectionmembershipsList
}

@Throws(RequestException::class)
fun IGDBWrapper.collectionMembershipTypes(APICalypse: APICalypse): List<CollectionMembershipType> {
val bytes = apiProtoRequest(Endpoints.COLLECTION_MEMBERSHIP_TYPES, APICalypse.buildQuery())
return CollectionMembershipTypeResult.parseFrom(bytes).collectionmembershiptypesList
}

2 changes: 1 addition & 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,7 @@ 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;
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;


override fun url(): String {
Expand Down
54 changes: 54 additions & 0 deletions src/test/kotlin/com/api/igdb/TestProtobufRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,59 @@ class TestProtobufRequest {
val result = wrapper.websites(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testEvents() {
val result = wrapper.events(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testEventLogos() {
val result = wrapper.eventLogos(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testEventNetworks() {
val result = wrapper.eventNetworks(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testNetworkTypes() {
val result = wrapper.networkTypes(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testCollectionRelations() {
val result = wrapper.collectionRelations(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testCollectionRelationTypes() {
val result = wrapper.collectionRelationTypes(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testCollectionTypes() {
val result = wrapper.collectionTypes(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testCollectionMemberships() {
val result = wrapper.collectionMemberships(APICalypse())
assert(result.isNotEmpty())
}

@Test
fun testCollectionMembershipTypes() {
val result = wrapper.collectionMembershipTypes(APICalypse())
assert(result.isNotEmpty())
}

}

0 comments on commit 1e02280

Please sign in to comment.