Skip to content

Commit

Permalink
Merge pull request #99 from VictorKabata/kotlin-1.9.20
Browse files Browse the repository at this point in the history
Update to Kotlin 1.9.20
  • Loading branch information
VictorKabata authored Nov 10, 2023
2 parents d3106ee + 485d294 commit a53eede
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[*.{kt,kts}]
disabled_rules = import-ordering, experimental:argument-list-wrapping,experimental:package-name
disabled_rules = import-ordering, experimental:argument-list-wrapping, package-name
insert_final_newline = true
2 changes: 1 addition & 1 deletion app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.6"
kotlinCompilerExtensionVersion = "1.5.4"
}
packagingOptions {
resources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private val LightColorScheme = lightColorScheme(
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
*/
)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ val Typography = Typography(
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
*/
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private val LightColorScheme = lightColors(
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
*/
)

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ val Typography = Typography(
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
*/
)
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ plugins {
alias(libs.plugins.jvm) apply false
alias(libs.plugins.nativeCocoapod) apply false

// alias(libs.plugins.ktLint)
alias(libs.plugins.ktLint)
alias(libs.plugins.detekt)
alias(libs.plugins.spotless)
}

subprojects {
/*apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
ktlint {
debug.set(true)
verbose.set(true)
Expand All @@ -22,8 +22,9 @@ subprojects {
filter {
enableExperimentalRules.set(true)
exclude { projectDir.toURI().relativize(it.file.toURI()).path.contains("/generated/") }
include("**/kotlin/**")
}
}*/
}

apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
Expand Down
17 changes: 11 additions & 6 deletions daraja/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/sn

fun Project.get(key: String, defaultValue: String = "Invalid value $key") =
gradleLocalProperties(rootDir).getProperty(key)?.toString() ?: System.getenv(key)?.toString()
?: defaultValue
?: defaultValue

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
Expand All @@ -35,7 +35,7 @@ plugins {
kotlin {
targetHierarchy.default()

android {
androidTarget {
publishLibraryVariants("release", "debug")
}

Expand Down Expand Up @@ -83,7 +83,7 @@ kotlin {
sourceSets["androidMain"].dependencies {
implementation(libs.ktor.android)
}
sourceSets["androidTest"].dependencies {}
sourceSets["androidUnitTest"].dependencies {}

sourceSets["iosMain"].dependencies {
implementation(libs.ktor.darwin)
Expand Down Expand Up @@ -162,8 +162,11 @@ publishing {
repositories {
maven {
name = "Sonatype"
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl
else releasesRepoUrl
url = if (version.toString().endsWith("SNAPSHOT")) {
snapshotsRepoUrl
} else {
releasesRepoUrl
}

credentials {
username = project.get("OSSRH_USERNAME")
Expand Down Expand Up @@ -219,7 +222,9 @@ publishing {
val signingKey = project.get("SIGNING_PASSWORD")

useInMemoryPgpKeys(
signingKeyId, signingKeyPassword, signingKey
signingKeyId,
signingKeyPassword,
signingKey
)
sign(publishing.publications)
}
Expand Down
11 changes: 8 additions & 3 deletions daraja/src/commonMain/kotlin/com/vickbt/darajakmp/Daraja.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ class Daraja constructor(
val timestamp = Clock.System.now().getDarajaTimestamp()

val darajaPassword = getDarajaPassword(
shortCode = businessShortCode, passkey = passKey ?: "", timestamp = timestamp
shortCode = businessShortCode,
passkey = passKey ?: "",
timestamp = timestamp
)

val mpesaExpressRequest = MpesaExpressRequest(
Expand Down Expand Up @@ -190,11 +192,14 @@ class Daraja constructor(
* */
@ObjCName(swiftName = "transactionStatus")
fun transactionStatus(
businessShortCode: String, checkoutRequestID: String
businessShortCode: String,
checkoutRequestID: String
): DarajaResult<DarajaTransactionResponse> = runBlocking {
val timestamp = Clock.System.now().getDarajaTimestamp()
val darajaPassword = getDarajaPassword(
shortCode = businessShortCode, passkey = passKey ?: "", timestamp = timestamp
shortCode = businessShortCode,
passkey = passKey ?: "",
timestamp = timestamp
)

val darajaTransactionRequest = DarajaTransactionRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,4 @@ internal class DarajaApiService constructor(
setBody(c2bRequest)
}.body()
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier
import io.ktor.client.HttpClient
import io.ktor.client.plugins.addDefaultResponseValidation
import io.ktor.client.plugins.cache.HttpCache
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.plugins.logging.LogLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ internal data class C2BRegistrationRequest(

/**A unique number is tagged to an M-PESA pay bill/till number of the organization.*/
@SerialName("ShortCode")
val shortCode: Int,
val shortCode: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ sealed class DarajaResult<out T> {
* @receiver [DarajaResult]
* */
internal fun <T : Any> DarajaResult<T>.getOrNull(): T? {
return if (this is DarajaResult.Success) this.data
else null
return if (this is DarajaResult.Success) {
this.data
} else {
null
}
}

/**Returns exception of type [DarajaException] on failure
Expand All @@ -48,17 +51,23 @@ internal fun <T : Any> DarajaResult<T>.getOrNull(): T? {
* @receiver [DarajaResult]
* */
internal fun <T : Any> DarajaResult<T>.throwOnFailure(): DarajaException {
return if (this is DarajaResult.Failure) this.exception
else throw DarajaException()
return if (this is DarajaResult.Failure) {
this.exception
} else {
throw DarajaException()
}
}

/**Returns result of type [T] on success or exception of type [DarajaException] on failure
*
* @receiver [DarajaResult]
* */
internal fun <T : Any> DarajaResult<T>.getOrThrow(): T {
return if (this is DarajaResult.Success) this.data
else throw this.throwOnFailure()
return if (this is DarajaResult.Success) {
this.data
} else {
throw this.throwOnFailure()
}
}

/* ToDo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class DarajaApiServiceTest {
private lateinit var darajaApiService: DarajaApiService

private val darajaToken = DarajaToken(
accessToken = "wWAHdtiE4GCSGv2ocfzQ0WHefwAJ", expiresIn = "3599"
accessToken = "wWAHdtiE4GCSGv2ocfzQ0WHefwAJ",
expiresIn = "3599"
)

private val mpesaExpressRequest = MpesaExpressRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ internal class MockDarajaHttpClient {
when (request.url.fullPath) {
"/${DarajaEndpoints.REQUEST_ACCESS_TOKEN}" -> {
respond(
responseContent ?: AccessToken200JSON, httpStatusCode, responseHeaders
responseContent ?: AccessToken200JSON,
httpStatusCode,
responseHeaders
)
}
"/${DarajaEndpoints.INITIATE_MPESA_EXPRESS}" -> {
respond(
responseContent ?: MpesaExpress200JSON, httpStatusCode, responseHeaders
responseContent ?: MpesaExpress200JSON,
httpStatusCode,
responseHeaders
)
}
"/${DarajaEndpoints.QUERY_MPESA_TRANSACTION}" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.vickbt.darajakmp.utils
import com.vickbt.darajakmp.network.models.DarajaException
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
import kotlin.test.assertNull

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ android.nonTransitiveRClass=true

#MPP
kotlin.mpp.enableCInteropCommonization=true
kotlin.native.binary.memoryModel=experimental
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.stability.nowarn=true
kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "1.8.20"
kotlin = "1.9.20"
gradle = "7.4.1"
ktLint = "10.3.0"
ktLint = "11.6.0"
detekt = "1.19.0"
spotless = "6.2.2"
nativeCocoapod = "1.9.0"
Expand All @@ -17,7 +17,7 @@ kotlinxDateTime = "0.4.1"
napier = "2.6.1"
ktor = "2.3.4"
kotlinxTestResources = "0.2.2"
composeMultiplatform = "1.5.0-beta01"
composeMultiplatform = "1.5.10"
cache4k = "0.11.0"
mockative = "2.0.1"

Expand Down

0 comments on commit a53eede

Please sign in to comment.