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

Adding shared octanegg module. #88

Merged
merged 14 commits into from
Apr 12, 2022
2 changes: 1 addition & 1 deletion .github/workflows/lint_checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Lint Checks

on: push
on: pull_request

jobs:
lint-checks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Build
name: Unit Tests

on: push
on: pull_request

jobs:
build:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -19,4 +19,4 @@ jobs:
run: echo $LOCAL_PROPERTIES > ./local.properties

- name: Build Project
run: ./gradlew assemble
run: ./gradlew build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ local.properties
/feature-eventsummarylist/build/
/team-api/build/
/team-implementation/build/
/octanegg/build/
/buildSrc/build/
PocketLeagueiOS/PocketLeagueiOS.xcodeproj/project.xcworkspace/xcuserdata/amcneilly.xcuserdatad/UserInterfaceState.xcuserstate
16 changes: 0 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,6 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

testOptions {
unitTests.all {
it.extensions.configure(kotlinx.kover.api.KoverTaskExtension::class) {
isEnabled = true
excludes = listOf(
"dagger.hilt.internal.aggregatedroot.codegen.*",
"hilt_aggregated_deps.*",
".*ComposableSingletons.*",
".*Hilt.*",
".*BuildConfig.*",
".*_Factory.*",
)
}
}
}
}

dependencies {
Expand Down
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ buildscript {
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0")
classpath("com.github.ben-manes:gradle-versions-plugin:0.29.0")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}")
classpath("org.jetbrains.kotlinx:kover:0.4.1")
classpath("com.hiya:jacoco-android:0.2")
classpath("gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0")
classpath("org.jetbrains.kotlin:kotlin-serialization:1.6.10")
Expand All @@ -38,9 +37,8 @@ allprojects {
}

subprojects {
apply(from = "../buildscripts/ktlint.gradle")
apply(from = "../buildscripts/versionsplugin.gradle")
apply(from = "../buildscripts/kover.gradle")
apply(from = "${rootProject.projectDir}/buildscripts/ktlint.gradle")
apply(from = "${rootProject.projectDir}/buildscripts/versionsplugin.gradle")
}

tasks.register("clean", Delete::class) {
Expand Down
1 change: 0 additions & 1 deletion buildscripts/kover.gradle

This file was deleted.

12 changes: 2 additions & 10 deletions event-implementation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import java.util.Properties

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.android.library")
id("com.apollographql.apollo3").version(Versions.apollo)
id("com.codingfeline.buildkonfig").version(Versions.buildKonfig)
Expand All @@ -27,6 +26,7 @@ kotlin {
dependencies {
implementation(project(":event-api"))
implementation(project(":core-datetime"))
implementation(project(":octanegg"))
implementation("com.apollographql.apollo3:apollo-runtime:${Versions.apollo}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("io.ktor:ktor-client-core:${Versions.ktor}")
Expand All @@ -40,11 +40,7 @@ kotlin {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
implementation("io.ktor:ktor-client-android:${Versions.ktor}")
}
}
val androidMain by getting
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
Expand All @@ -54,10 +50,6 @@ kotlin {
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)

dependencies {
implementation("io.ktor:ktor-client-ios:${Versions.ktor}")
}
}
val iosX64Test by getting
val iosArm64Test by getting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.adammcneilly.pocketleague.event.implementation.octanegg
import com.adammcneilly.pocketleague.core.data.DataResult
import com.adammcneilly.pocketleague.core.models.EventOverview
import com.adammcneilly.pocketleague.core.models.EventSummary
import com.adammcneilly.pocketleague.data.remote.octanegg.OctaneGGAPIClient
import com.adammcneilly.pocketleague.data.remote.octanegg.dtos.EventDTO
import com.adammcneilly.pocketleague.data.remote.octanegg.dtos.EventListResponseDTO
import com.adammcneilly.pocketleague.data.remote.octanegg.mappers.toEventSummary
import com.adammcneilly.pocketleague.event.api.EventRepository
import com.adammcneilly.pocketleague.event.implementation.octanegg.dtos.EventDTO
import com.adammcneilly.pocketleague.event.implementation.octanegg.dtos.EventListResponseDTO
import com.adammcneilly.pocketleague.event.implementation.octanegg.mappers.toEventSummary
import io.ktor.client.request.parameter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow

Expand All @@ -25,9 +25,7 @@ class OctaneGGEventService : EventRepository {

override fun fetchEventSummaries(): Flow<DataResult<List<EventSummary>>> {
return flow {
val apiResult = apiClient.getResponse<EventListResponseDTO>("events") {
this.parameter("group", "rlcs2122")
}
val apiResult = apiClient.getResponse<EventListResponseDTO>("events")

val mappedResult: DataResult<List<EventSummary>> = when (apiResult) {
is DataResult.Success -> {
Expand Down
76 changes: 76 additions & 0 deletions octanegg/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.android.library")
}

kotlin {
android()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "octanegg"
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":core-data"))
implementation(project(":core-models"))
implementation(project(":core-datetime"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("io.ktor:ktor-client-core:${Versions.ktor}")
implementation("io.ktor:ktor-client-json:${Versions.ktor}")
implementation("io.ktor:ktor-client-logging:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization:${Versions.ktor}")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
implementation("io.ktor:ktor-client-android:${Versions.ktor}")
}
}
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)

dependencies {
implementation("io.ktor:ktor-client-ios:${Versions.ktor}")
}
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}

android {
compileSdk = AndroidConfig.compileSDK
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = AndroidConfig.minSDK
targetSdk = AndroidConfig.targetSDK
}
}
2 changes: 2 additions & 0 deletions octanegg/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.adammcneilly.pocketleague.data.remote.octanegg" />
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg
package com.adammcneilly.pocketleague.data.remote.octanegg

import com.adammcneilly.pocketleague.core.data.DataResult
import io.ktor.client.HttpClient
Expand All @@ -12,7 +12,7 @@ import kotlinx.serialization.json.Json
/**
* Defines the API client information for communicating with the octane.gg API.
*/
internal class OctaneGGAPIClient {
class OctaneGGAPIClient {
val baseURL = "https://zsr.octane.gg/"

val httpClient = HttpClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a [PlayerDTO] account within the octane.gg API.
*/
@Serializable
data class AccountDTO(
@SerialName("id")
val id: String? = null,
@SerialName("platform")
val platform: String? = null,
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg.dtos
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
* A data class mapping to an Event from the octane.gg API.
*/
@Serializable
internal data class EventDTO(
data class EventDTO(
@SerialName("_id")
val id: String,
val endDate: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg.dtos
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.Serializable

/**
* A DTO that maps to an event list response from the octane.gg API.
*/
@Serializable
internal data class EventListResponseDTO(
data class EventListResponseDTO(
val events: List<EventDTO>,
val page: Int,
val perPage: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg.dtos
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.Serializable

/**
* A data class mapping to a location from the octane.gg API.
*/
@Serializable
internal data class LocationDTO(
data class LocationDTO(
val city: String? = null,
val country: String? = null,
val venue: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a person who is a player for a [TeamDTO] in the octane.gg API.
*/
@Serializable
data class PlayerDTO(
@SerialName("accounts")
val accounts: List<AccountDTO>? = null,
@SerialName("coach")
val coach: Boolean? = null,
@SerialName("country")
val country: String? = null,
@SerialName("_id")
val id: String? = null,
@SerialName("name")
val name: String? = null,
@SerialName("relevant")
val relevant: Boolean? = null,
@SerialName("slug")
val slug: String? = null,
@SerialName("substitute")
val substitute: Boolean? = null,
@SerialName("tag")
val tag: String? = null,
@SerialName("team")
val team: TeamOverviewDTO? = null,
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg.dtos
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.Serializable

/**
* A data class mapping to a prize entity from the octane.gg API.
*/
@Serializable
internal data class PrizeDTO(
data class PrizeDTO(
val amount: Double? = null,
val currency: String? = null,
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.adammcneilly.pocketleague.event.implementation.octanegg.dtos
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
* A data class mapping to a stage from the octane.gg API.
*/
@Serializable
internal data class StageDTO(
data class StageDTO(
@SerialName("_id")
val id: Int,
val endDate: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.adammcneilly.pocketleague.data.remote.octanegg.dtos

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Represents a team within the octane.gg API domain.
*/
@Serializable
data class TeamDTO(
@SerialName("players")
val players: List<PlayerDTO>? = null,
@SerialName("team")
val team: TeamOverviewDTO? = null,
)
Loading