diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 25833e5..d6ea3bf 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,5 @@ -# Pipeline to publish core sdk -name: Publish Core SDK +# Pipeline for pull request +name: Pull request pipeline on: pull_request: diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/FeedbackRequestBuilder.kt b/configs/code/spotless/copyright.swift similarity index 75% rename from sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/FeedbackRequestBuilder.kt rename to configs/code/spotless/copyright.swift index 33f6c84..4943148 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/FeedbackRequestBuilder.kt +++ b/configs/code/spotless/copyright.swift @@ -1,5 +1,5 @@ /* - * Copyright 2023 nyris GmbH + * Copyright $YEAR nyris GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,10 +13,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.nyris.sdk.builder - -import io.nyris.sdk.model.Feedback - -interface FeedbackRequestBuilder { - suspend fun send(feedback: Feedback): Result -} diff --git a/configs/signing/release-maven.txt b/configs/signing/release-maven.txt new file mode 100644 index 0000000..1fcc6f3 --- /dev/null +++ b/configs/signing/release-maven.txt @@ -0,0 +1,87 @@ +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 +wx4zevj3v3A6zNl2sO86a2osxVXd8GIhQYSs diff --git a/gradle/init.gradle.kts b/gradle/init.gradle.kts index cef97c9..7349396 100644 --- a/gradle/init.gradle.kts +++ b/gradle/init.gradle.kts @@ -44,6 +44,15 @@ rootProject { "(^(?![\\/ ]\\*).*$)" ) } + format("swift") { + target("**/*.swift") + targetExclude("**/build/**/*.swift") + // Look for the first line that doesn't have a block comment (assumed to be the license) + licenseHeaderFile( + rootProject.file("configs/code/spotless/copyright.swift"), + "(^(?![\\/ ]\\*).*$)" + ) + } format("xml") { target("**/*.xml") targetExclude("**/build/**/*.xml") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 405fc75..9081674 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -54,6 +54,7 @@ ktor_loggin = { group = "io.ktor", name = "ktor-client-logging", version.ref = " ktor_serialization = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor_okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor" } ktor_android = { group = "io.ktor", name = "ktor-client-android", version.ref = "ktor" } +ktor_ios = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor" } ktor_jvm = { group = "io.ktor", name = "ktor-client-java", version.ref = "ktor" } androidx_core = { group = "androidx.core", name = "core", version.ref = "androidxCore" } diff --git a/sdk.camera/android/feature-barcode/src/main/kotlin/io/nyris/sdk/camera/feature/barcode/BarcodeRectFactory.kt b/sdk.camera/android/feature-barcode/src/main/kotlin/io/nyris/sdk/camera/feature/barcode/BarcodeRectFactory.kt index 5787dea..b7f8856 100644 --- a/sdk.camera/android/feature-barcode/src/main/kotlin/io/nyris/sdk/camera/feature/barcode/BarcodeRectFactory.kt +++ b/sdk.camera/android/feature-barcode/src/main/kotlin/io/nyris/sdk/camera/feature/barcode/BarcodeRectFactory.kt @@ -46,7 +46,7 @@ internal class BarcodeRectFactory { } } -data class KRectF( +class KRectF( val left: Float, val top: Float, val right: Float, diff --git a/sdk.camera/android/view/src/main/kotlin/io/nyris/sdk/camera/Result.kt b/sdk.camera/android/view/src/main/kotlin/io/nyris/sdk/camera/Result.kt index 8cd9665..c4910ef 100644 --- a/sdk.camera/android/view/src/main/kotlin/io/nyris/sdk/camera/Result.kt +++ b/sdk.camera/android/view/src/main/kotlin/io/nyris/sdk/camera/Result.kt @@ -19,8 +19,8 @@ import io.nyris.sdk.camera.core.BarcodeFormat interface Result -data class BarcodeResult(val barcodes: List) : Result -data class Barcode( +class BarcodeResult(val barcodes: List) : Result +class Barcode( val code: String?, @BarcodeFormat val format: Int, diff --git a/sdk.core/build.gradle.kts b/sdk.core/build.gradle.kts index 4d2dcd6..0809eee 100644 --- a/sdk.core/build.gradle.kts +++ b/sdk.core/build.gradle.kts @@ -27,21 +27,20 @@ kotlin { android { publishLibraryVariants("release") } - jvm() + //jvm() + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64() + ).forEach { + it.binaries.framework { + baseName = "nyris" + } + } sourceSets { val commonMain by getting { dependencies { - implementation(libs.ktx.coroutines.core) - implementation(libs.ktor.core) - implementation(libs.ktor.json) - implementation(libs.ktor.loggin) - implementation(libs.ktor.contentnegotiation) - implementation(libs.ktor.serialization) - - implementation(libs.ktx.json) - - implementation(libs.ktx.date) } } val commonTest by getting { @@ -63,16 +62,31 @@ kotlin { implementation(libs.test.mockk.core) } } - val jvmMain by getting { - dependencies { - implementation(libs.ktor.jvm) - } - } - val jvmTest by getting { +// val jvmMain by getting { +// dependencies { +// implementation(libs.ktor.jvm) +// } +// } +// val jvmTest by getting { +// dependencies { +// implementation(kotlin("test-junit")) +// implementation(libs.test.mockk.core) +// } +// } + // iOS build + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + + val iosMain by creating { + dependsOn(commonMain) dependencies { - implementation(kotlin("test-junit")) - implementation(libs.test.mockk.core) + implementation(libs.ktor.ios) } + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + + iosSimulatorArm64Main.dependsOn(this) } } } \ No newline at end of file diff --git a/sdk.core/src/androidMain/kotlin/io/nyris/sdk/Nyris.kt b/sdk.core/src/androidMain/kotlin/io/nyris/sdk/Nyris.kt index d3c3951..a9205e2 100644 --- a/sdk.core/src/androidMain/kotlin/io/nyris/sdk/Nyris.kt +++ b/sdk.core/src/androidMain/kotlin/io/nyris/sdk/Nyris.kt @@ -19,7 +19,7 @@ import io.nyris.sdk.builder.FeedbackRequestBuilder import io.nyris.sdk.builder.ImageMatchingRequestBuilder import io.nyris.sdk.builder.ObjectDetectingRequestBuilder import io.nyris.sdk.builder.SkuMatchingRequestBuilder -import io.nyris.sdk.internal.NyrisImpl +import io.nyris.sdk.internal.createInstanceNyrisImpl actual interface Nyris { actual fun imageMatching(): ImageMatchingRequestBuilder @@ -29,17 +29,12 @@ actual interface Nyris { actual fun feedback(): FeedbackRequestBuilder actual fun skuMatching(): SkuMatchingRequestBuilder - - actual companion object { - @JvmStatic - actual fun createInstance( - apiKey: String, - config: NyrisConfig, - ): Nyris = NyrisImpl.createInstance( - apiKey = apiKey, - config = config.copy( - platform = NyrisPlatform.Android - ) - ) - } } + +actual fun createInstance( + apiKey: String, + config: NyrisConfig, +): Nyris = createInstanceNyrisImpl( + apiKey = apiKey, + config = config +) \ No newline at end of file diff --git a/sdk.core/src/androidMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilder.kt b/sdk.core/src/androidMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilder.kt new file mode 100644 index 0000000..4c92a61 --- /dev/null +++ b/sdk.core/src/androidMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilder.kt @@ -0,0 +1,20 @@ +package io.nyris.sdk.internal.repository.imagematching + +import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.model.MatchResponse + +internal actual class ImageMatchingRequestBuilderImpl actual constructor( + logger: Logger, + imageMatchingRepository: ImageMatchingRepository, +) : CommonImageMatchingRequestBuilderImpl(logger, imageMatchingRepository) { + override suspend fun match(image: DataType): Result { + logger.log("[ImageMatchingRequestBuilderImpl] match") + + return imageMatchingRepository.match( + image = image, + params = createParams() + ) + } +} + +internal actual typealias DataType = ByteArray \ No newline at end of file diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/Nyris.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/Nyris.kt index 452d691..eae2d07 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/Nyris.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/Nyris.kt @@ -15,8 +15,6 @@ */ package io.nyris.sdk -import io.ktor.client.engine.HttpClientEngineConfig -import io.ktor.client.engine.HttpClientEngineFactory import io.nyris.sdk.builder.FeedbackRequestBuilder import io.nyris.sdk.builder.ImageMatchingRequestBuilder import io.nyris.sdk.builder.ObjectDetectingRequestBuilder @@ -30,13 +28,39 @@ expect interface Nyris { fun feedback(): FeedbackRequestBuilder fun skuMatching(): SkuMatchingRequestBuilder - - companion object { - fun createInstance( - apiKey: String, - config: NyrisConfig = NyrisConfig(), - ): Nyris - } } -typealias HttpEngine = HttpClientEngineFactory +expect fun createInstance( + apiKey: String, + config: NyrisConfig = NyrisConfig(), +): Nyris + +class NyrisConfig( + val isDebug: Boolean = false, + val baseUrl: String = BASE_URL, + val timeout: Long = TIMEOUT, + internal val platform: NyrisPlatform = NyrisPlatform.Generic, +) + +const val BASE_URL = "https://api.nyris.io/" +const val TIMEOUT = 3000L + +sealed class NyrisException(message: String?) : Throwable(message) + +class ResponseException( + val title: String?, + val status: Int?, + val detail: String?, + val traceId: String?, + val itemKey: String?, +) : NyrisException(detail) + +class ClientException( + override val message: String?, +) : NyrisException(message) + +class ServerException( + override val message: String?, +) : NyrisException(message) + +enum class NyrisPlatform { Generic, Android, IOS, Jvm } \ No newline at end of file diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisConfig.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisConfig.kt deleted file mode 100644 index db18ba6..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisConfig.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk - -data class NyrisConfig( - val isDebug: Boolean = false, - val baseUrl: String = BASE_URL, - val httpEngine: HttpEngine? = null, - val timeout: Long = TIMEOUT, - internal val platform: NyrisPlatform = NyrisPlatform.Generic, -) { - companion object { - const val BASE_URL = "https://api.nyris.io/" - const val TIMEOUT = 3000L - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisException.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisException.kt deleted file mode 100644 index 2bdfa6c..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisException.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk - -sealed class NyrisException(message: String?) : Throwable(message) - -data class ResponseException( - val title: String?, - val status: Int?, - val detail: String?, - val traceId: String?, - val itemKey: String?, -) : NyrisException(detail) - -data class ClientException( - override val message: String?, -) : NyrisException(message) - -data class ServerException( - override val message: String?, -) : NyrisException(message) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisPlatform.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisPlatform.kt index 5cfa299..755655a 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisPlatform.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/NyrisPlatform.kt @@ -14,5 +14,3 @@ * limitations under the License. */ package io.nyris.sdk - -enum class NyrisPlatform { Generic, Android, IOS, Jvm } diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ImageMatchingRequestBuilder.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ImageMatchingRequestBuilder.kt deleted file mode 100644 index 7aa708f..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ImageMatchingRequestBuilder.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.builder - -import io.nyris.sdk.model.MatchResponse - -interface ImageMatchingRequestBuilder { - fun limit(limit: Int): ImageMatchingRequestBuilder - - fun language(language: String): ImageMatchingRequestBuilder - - fun threshold(threshold: Float): ImageMatchingRequestBuilder - - fun geolocation( - lat: Float, - lon: Float, - dist: Int, - ): ImageMatchingRequestBuilder - - fun filters(filters: Map>): ImageMatchingRequestBuilder - - fun session(session: String): ImageMatchingRequestBuilder - - // Put the params before this call - suspend fun match(image: ByteArray): Result -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ObjectDetectingRequestBuilder.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ObjectDetectingRequestBuilder.kt deleted file mode 100644 index 467b311..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/ObjectDetectingRequestBuilder.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.builder - -import io.nyris.sdk.model.DetectResponse - -interface ObjectDetectingRequestBuilder { - fun session(session: String): ObjectDetectingRequestBuilder - - suspend fun detect(image: ByteArray): Result -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/RequestBuilder.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/RequestBuilder.kt new file mode 100644 index 0000000..f1417c5 --- /dev/null +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/RequestBuilder.kt @@ -0,0 +1,48 @@ +package io.nyris.sdk.builder + +import io.nyris.sdk.internal.repository.imagematching.DataType +import io.nyris.sdk.model.DetectResponse +import io.nyris.sdk.model.Feedback +import io.nyris.sdk.model.MatchResponse +import io.nyris.sdk.model.SkuResponse + +interface FeedbackRequestBuilder { + suspend fun send(feedback: Feedback): NyrisResult +} + +sealed class NyrisResult { + object Successfull : NyrisResult() + object Fail : NyrisResult() +} + +interface ImageMatchingRequestBuilder { + fun limit(limit: Int): ImageMatchingRequestBuilder + + fun language(language: String): ImageMatchingRequestBuilder + + fun threshold(threshold: Float): ImageMatchingRequestBuilder + + fun geolocation( + lat: Float, + lon: Float, + dist: Int, + ): ImageMatchingRequestBuilder + + fun filters(filters: Map>): ImageMatchingRequestBuilder + + fun session(session: String): ImageMatchingRequestBuilder + + // Put the params before this call + suspend fun match(image: DataType): Result +} + +interface ObjectDetectingRequestBuilder { + fun session(session: String): ObjectDetectingRequestBuilder + + suspend fun detect(image: ByteArray): Result +} + +interface SkuMatchingRequestBuilder { + suspend fun match(sku: String): Result +} + diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/ConfigInternal.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/ConfigInternal.kt deleted file mode 100644 index f8fc91c..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/ConfigInternal.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal - -import io.nyris.sdk.HttpEngine - -internal class ConfigInternal( - val apiKey: String, - val isDebug: Boolean, - val httpEngine: HttpEngine?, - val timeout: Long, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/NyrisImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/NyrisImpl.kt index 2e6f062..ef70cba 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/NyrisImpl.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/NyrisImpl.kt @@ -23,7 +23,7 @@ import io.nyris.sdk.builder.ObjectDetectingRequestBuilder import io.nyris.sdk.builder.SkuMatchingRequestBuilder import io.nyris.sdk.internal.di.ServiceLocator -internal class NyrisImpl private constructor( +internal class NyrisImpl internal constructor( apiKey: String, config: NyrisConfig, ) : Nyris { @@ -39,13 +39,17 @@ internal class NyrisImpl private constructor( override fun feedback(): FeedbackRequestBuilder = requestBuilders.feedback() override fun skuMatching(): SkuMatchingRequestBuilder = requestBuilders.skuMatching() +} - companion object { - fun createInstance( - apiKey: String, - config: NyrisConfig, - ): NyrisImpl { - return NyrisImpl(apiKey, config) - } - } +internal fun createInstanceNyrisImpl( + apiKey: String, + config: NyrisConfig, +): Nyris { + return NyrisImpl(apiKey, config) } + +internal class ConfigInternal( + val apiKey: String, + val isDebug: Boolean, + val timeout: Long, +) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuilders.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuilders.kt index bb6e37e..8c0c585 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuilders.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuilders.kt @@ -29,3 +29,18 @@ internal interface RequestBuilders { fun skuMatching(): SkuMatchingRequestBuilder } + +internal class RequestBuildersImpl( + private val imageMatching: Lazy, + private val objectDetecting: Lazy, + private val feedback: Lazy, + private val skuMatching: Lazy, +) : RequestBuilders { + override fun imageMatching(): ImageMatchingRequestBuilder = imageMatching.value + + override fun objectDetecting(): ObjectDetectingRequestBuilder = objectDetecting.value + + override fun feedback(): FeedbackRequestBuilder = feedback.value + + override fun skuMatching(): SkuMatchingRequestBuilder = skuMatching.value +} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuildersImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuildersImpl.kt deleted file mode 100644 index e106358..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/RequestBuildersImpl.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal - -import io.nyris.sdk.builder.FeedbackRequestBuilder -import io.nyris.sdk.builder.ImageMatchingRequestBuilder -import io.nyris.sdk.builder.ObjectDetectingRequestBuilder -import io.nyris.sdk.builder.SkuMatchingRequestBuilder - -/** - * Since the Request builders class represents the components for each implemented api, we lazy load the builders to - * avoid heavy waist of time on sdk instance creation. - * Please make sure to respect that - */ -internal class RequestBuildersImpl( - private val imageMatching: Lazy, - private val objectDetecting: Lazy, - private val feedback: Lazy, - private val skuMatching: Lazy, -) : RequestBuilders { - override fun imageMatching(): ImageMatchingRequestBuilder = imageMatching.value - - override fun objectDetecting(): ObjectDetectingRequestBuilder = objectDetecting.value - - override fun feedback(): FeedbackRequestBuilder = feedback.value - - override fun skuMatching(): SkuMatchingRequestBuilder = skuMatching.value -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/NetworkModule.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/NetworkModule.kt deleted file mode 100644 index 2c0c526..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/NetworkModule.kt +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.di - -import io.ktor.client.HttpClient -import io.ktor.client.HttpClientConfig -import io.ktor.client.plugins.HttpTimeout -import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.client.plugins.logging.LogLevel -import io.ktor.client.plugins.logging.Logging -import io.ktor.client.plugins.logging.SIMPLE -import io.ktor.serialization.kotlinx.json.json -import io.nyris.sdk.NyrisPlatform -import io.nyris.sdk.internal.ConfigInternal -import io.nyris.sdk.internal.network.CommonHeaders -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.HttpClientWrapper -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.network.UserAgent -import io.nyris.sdk.internal.network.XOptionsBuilder -import io.nyris.sdk.internal.util.Logger -import kotlinx.serialization.json.Json -import io.ktor.client.plugins.logging.Logger as KLogger - -internal object NetworkModule { - fun init( - platform: NyrisPlatform, - baseUrl: String, - ) { - putUserAgent(platform) - putCommonHeaders() - putXOptionsBuilder() - putEndpoints(baseUrl) - puJson() - putHttpClient() - } - - private fun putUserAgent(platform: NyrisPlatform) { - ServiceLocator.put(UserAgent::class) { - UserAgent( - sdkVersion = "1.0.0", - platform = platform, - osVersion = "12.0" - ) - } - } - - private fun putCommonHeaders() { - ServiceLocator.put(CommonHeaders::class) { - CommonHeaders( - ServiceLocator.get().value.apiKey, - ServiceLocator.get().value - ) - } - } - - private fun putXOptionsBuilder() { - ServiceLocator.put(XOptionsBuilder::class) { - XOptionsBuilder() - } - } - - private fun putEndpoints(baseUrl: String) { - ServiceLocator.put(Endpoints::class) { - Endpoints(baseUrl) - } - } - - private fun puJson() { - ServiceLocator.put(Json::class) { - Json { - isLenient = true - ignoreUnknownKeys = true - } - } - } - - private fun putHttpClient() { - val config = ServiceLocator.get().value - val engine = config.httpEngine - - val httpConfig: HttpClientConfig<*>.() -> Unit = { - install(ContentNegotiation) { - json(ServiceLocator.get().value) - } - install(HttpTimeout) { - requestTimeoutMillis = config.timeout - } - if (config.isDebug) { - install(Logging) { - logger = KLogger.SIMPLE - level = LogLevel.ALL - } - } - } - - val httpClient = if (engine != null) { - HttpClient(engine, httpConfig) - } else { - HttpClient(httpConfig) - } - - ServiceLocator.put(NyrisHttpClient::class) { - NyrisHttpClient( - ServiceLocator.get().value, - ServiceLocator.get().value, - HttpClientWrapper(httpClient) - ) - } - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RepositoryModule.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RepositoryModule.kt deleted file mode 100644 index 8bc3363..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RepositoryModule.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.di - -import io.nyris.sdk.internal.network.feedback.FeedbackService -import io.nyris.sdk.internal.network.find.FindService -import io.nyris.sdk.internal.network.recommend.RecommendService -import io.nyris.sdk.internal.network.regions.RegionsService -import io.nyris.sdk.internal.repository.feedback.FeedbackRepository -import io.nyris.sdk.internal.repository.feedback.FeedbackRepositoryImpl -import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRepository -import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRepositoryImpl -import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRepository -import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRepositoryImpl -import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRepository -import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRepositoryImpl -import io.nyris.sdk.internal.util.Logger - -internal object RepositoryModule { - fun init() { - putImageMatchingRepository() - putObjectDetectingRepository() - putFeedbackRepository() - putSkuMatchingRepository() - } - - private fun putImageMatchingRepository() { - ServiceLocator.put(ImageMatchingRepository::class) { - ImageMatchingRepositoryImpl( - logger = ServiceLocator.get().value, - findService = ServiceLocator.get().value, - ) - } - } - - private fun putObjectDetectingRepository() { - ServiceLocator.put(ObjectDetectingRepository::class) { - ObjectDetectingRepositoryImpl( - logger = ServiceLocator.get().value, - regionsService = ServiceLocator.get().value, - ) - } - } - - private fun putFeedbackRepository() { - ServiceLocator.put(FeedbackRepository::class) { - FeedbackRepositoryImpl( - logger = ServiceLocator.get().value, - feedbackService = ServiceLocator.get().value, - ) - } - } - - private fun putSkuMatchingRepository() { - ServiceLocator.put(SkuMatchingRepository::class) { - SkuMatchingRepositoryImpl( - logger = ServiceLocator.get().value, - recommendService = ServiceLocator.get().value, - ) - } - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RequestBuilderModule.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RequestBuilderModule.kt deleted file mode 100644 index 979458a..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/RequestBuilderModule.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.di - -import io.nyris.sdk.builder.FeedbackRequestBuilder -import io.nyris.sdk.builder.ImageMatchingRequestBuilder -import io.nyris.sdk.builder.ObjectDetectingRequestBuilder -import io.nyris.sdk.builder.SkuMatchingRequestBuilder -import io.nyris.sdk.internal.RequestBuilders -import io.nyris.sdk.internal.RequestBuildersImpl -import io.nyris.sdk.internal.repository.feedback.FeedbackRepository -import io.nyris.sdk.internal.repository.feedback.FeedbackRequestBuilderImpl -import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRepository -import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRequestBuilderImpl -import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRepository -import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRequestBuilderImpl -import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRepository -import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRequestBuilderImpl -import io.nyris.sdk.internal.util.Logger - -internal object RequestBuilderModule { - fun init() { - putImageMatchingRequestBuilder() - putObjectDetectingRequestBuilder() - putFeedbackRequestBuilder() - putSkuMatchingBuilder() - - putRequestBuilders() - } - - private fun putImageMatchingRequestBuilder() { - ServiceLocator.put(ImageMatchingRequestBuilder::class) { - ImageMatchingRequestBuilderImpl( - logger = ServiceLocator.get().value, - imageMatchingRepository = ServiceLocator.get().value - ) - } - } - - private fun putObjectDetectingRequestBuilder() { - ServiceLocator.put(ObjectDetectingRequestBuilder::class) { - ObjectDetectingRequestBuilderImpl( - logger = ServiceLocator.get().value, - objectDetectingRepository = ServiceLocator.get().value - ) - } - } - - private fun putFeedbackRequestBuilder() { - ServiceLocator.put(FeedbackRequestBuilder::class) { - FeedbackRequestBuilderImpl( - logger = ServiceLocator.get().value, - feedbackRepository = ServiceLocator.get().value - ) - } - } - - private fun putSkuMatchingBuilder() { - ServiceLocator.put(SkuMatchingRequestBuilder::class) { - SkuMatchingRequestBuilderImpl( - logger = ServiceLocator.get().value, - skuMatchingRepository = ServiceLocator.get().value - ) - } - } - - private fun putRequestBuilders() { - ServiceLocator.put(RequestBuilders::class) { - RequestBuildersImpl( - imageMatching = ServiceLocator.get(), - objectDetecting = ServiceLocator.get(), - feedback = ServiceLocator.get(), - skuMatching = ServiceLocator.get(), - ) - } - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceLocator.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceLocator.kt index d2f6693..773ee0e 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceLocator.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceLocator.kt @@ -18,7 +18,34 @@ package io.nyris.sdk.internal.di import io.nyris.sdk.NyrisConfig +import io.nyris.sdk.NyrisPlatform +import io.nyris.sdk.builder.FeedbackRequestBuilder +import io.nyris.sdk.builder.ImageMatchingRequestBuilder +import io.nyris.sdk.builder.ObjectDetectingRequestBuilder +import io.nyris.sdk.builder.SkuMatchingRequestBuilder import io.nyris.sdk.internal.ConfigInternal +import io.nyris.sdk.internal.RequestBuilders +import io.nyris.sdk.internal.RequestBuildersImpl +import io.nyris.sdk.internal.network.CommonHeaders +import io.nyris.sdk.internal.network.Endpoints +import io.nyris.sdk.internal.network.UserAgent +import io.nyris.sdk.internal.network.XOptionsBuilder +import io.nyris.sdk.internal.network.feedback.FeedbackService +import io.nyris.sdk.internal.network.find.FindService +import io.nyris.sdk.internal.network.recommend.RecommendService +import io.nyris.sdk.internal.network.regions.RegionsService +import io.nyris.sdk.internal.repository.feedback.FeedbackRepository +import io.nyris.sdk.internal.repository.feedback.FeedbackRepositoryImpl +import io.nyris.sdk.internal.repository.feedback.FeedbackRequestBuilderImpl +import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRepository +import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRepositoryImpl +import io.nyris.sdk.internal.repository.imagematching.ImageMatchingRequestBuilderImpl +import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRepository +import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRepositoryImpl +import io.nyris.sdk.internal.repository.objectdetecting.ObjectDetectingRequestBuilderImpl +import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRepository +import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRepositoryImpl +import io.nyris.sdk.internal.repository.skumatching.SkuMatchingRequestBuilderImpl import io.nyris.sdk.internal.util.DEFAULT import io.nyris.sdk.internal.util.Logger import kotlin.reflect.KClass @@ -56,16 +83,16 @@ internal object ServiceLocator { ConfigInternal( apiKey = apiKey, isDebug = config.isDebug, - httpEngine = config.httpEngine, timeout = config.timeout ) ) // Init your modules here - NetworkModule.init(config.platform, config.baseUrl) - ServiceModule.init() - RepositoryModule.init() - RequestBuilderModule.init() + initNetworkModule(config.platform, config.baseUrl) + + initServiceModule() + initRepositories() + initRequestModule() } private fun putLogger(logger: Logger) { @@ -75,4 +102,179 @@ internal object ServiceLocator { private fun putConfig(config: ConfigInternal) { put(ConfigInternal::class) { config } } + + //region Network Module + private fun initNetworkModule( + platform: NyrisPlatform, + baseUrl: String, + ) { + putUserAgent(platform) + putCommonHeaders() + putXOptionsBuilder() + putEndpoints(baseUrl) + puJson() + putHttpClient() + } + + private fun putUserAgent(platform: NyrisPlatform) { + put(UserAgent::class) { + UserAgent( + sdkVersion = "1.0.0", + platform = platform, + osVersion = "12.0" + ) + } + } + + private fun putCommonHeaders() { + put(CommonHeaders::class) { + CommonHeaders( + get().value.apiKey, + get().value + ) + } + } + + private fun putXOptionsBuilder() { + put(XOptionsBuilder::class) { + XOptionsBuilder() + } + } + + private fun putEndpoints(baseUrl: String) { + put(Endpoints::class) { + Endpoints(baseUrl) + } + } + + private fun puJson() { + } + + private fun putHttpClient() { + } + //endregion + + //region Service Module + private fun initServiceModule() { + putFindService() + putRegionsService() + putFeedbackService() + putRecommendService() + } + + private fun putFindService() { + } + + private fun putRegionsService() { + } + + private fun putFeedbackService() { + } + + private fun putRecommendService() { + } + //endregion + + //region Repositories module + private fun initRepositories() { + putImageMatchingRepository() + putObjectDetectingRepository() + putFeedbackRepository() + putSkuMatchingRepository() + } + + private fun putImageMatchingRepository() { + put(ImageMatchingRepository::class) { + ImageMatchingRepositoryImpl( + logger = get().value, + findService = get().value, + ) + } + } + + private fun putObjectDetectingRepository() { + put(ObjectDetectingRepository::class) { + ObjectDetectingRepositoryImpl( + logger = get().value, + regionsService = get().value, + ) + } + } + + private fun putFeedbackRepository() { + put(FeedbackRepository::class) { + FeedbackRepositoryImpl( + logger = get().value, + feedbackService = get().value, + ) + } + } + + private fun putSkuMatchingRepository() { + put(SkuMatchingRepository::class) { + SkuMatchingRepositoryImpl( + logger = get().value, + recommendService = get().value, + ) + } + } + //endregion + + //region Request Builder Module + private fun initRequestModule() { + putImageMatchingRequestBuilder() + putObjectDetectingRequestBuilder() + putFeedbackRequestBuilder() + putSkuMatchingBuilder() + + putRequestBuilders() + } + + private fun putImageMatchingRequestBuilder() { + put(ImageMatchingRequestBuilder::class) { + ImageMatchingRequestBuilderImpl( + logger = get().value, + imageMatchingRepository = get().value + ) + } + } + + private fun putObjectDetectingRequestBuilder() { + put(ObjectDetectingRequestBuilder::class) { + ObjectDetectingRequestBuilderImpl( + logger = get().value, + objectDetectingRepository = get().value + ) + } + } + + private fun putFeedbackRequestBuilder() { + put(FeedbackRequestBuilder::class) { + FeedbackRequestBuilderImpl( + logger = get().value, + feedbackRepository = get().value + ) + } + } + + private fun putSkuMatchingBuilder() { + put(SkuMatchingRequestBuilder::class) { + SkuMatchingRequestBuilderImpl( + logger = get().value, + skuMatchingRepository = get().value + ) + } + } + + private fun putRequestBuilders() { + put(RequestBuilders::class) { + RequestBuildersImpl( + imageMatching = get(), + objectDetecting = get(), + feedback = get(), + skuMatching = get(), + ) + } + } + //endregion } diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceModule.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceModule.kt deleted file mode 100644 index edb5432..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/di/ServiceModule.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.di - -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.network.XOptionsBuilder -import io.nyris.sdk.internal.network.feedback.FeedbackService -import io.nyris.sdk.internal.network.feedback.FeedbackServiceImpl -import io.nyris.sdk.internal.network.find.FindService -import io.nyris.sdk.internal.network.find.FindServiceImpl -import io.nyris.sdk.internal.network.recommend.RecommendService -import io.nyris.sdk.internal.network.recommend.RecommendServiceImpl -import io.nyris.sdk.internal.network.regions.RegionsService -import io.nyris.sdk.internal.network.regions.RegionsServiceImpl -import io.nyris.sdk.internal.util.Logger -import kotlinx.coroutines.Dispatchers - -internal object ServiceModule { - fun init() { - putFindService() - putRegionsService() - putFeedbackService() - putRecommendService() - } - - private fun putFindService() { - ServiceLocator.put(FindService::class) { - FindServiceImpl( - logger = ServiceLocator.get().value, - xOptionsBuilder = ServiceLocator.get().value, - httpClient = ServiceLocator.get().value, - endpoints = ServiceLocator.get().value, - coroutineContext = Dispatchers.IO - ) - } - } - - private fun putRegionsService() { - ServiceLocator.put(RegionsService::class) { - RegionsServiceImpl( - logger = ServiceLocator.get().value, - httpClient = ServiceLocator.get().value, - endpoints = ServiceLocator.get().value, - coroutineContext = Dispatchers.IO - ) - } - } - - private fun putFeedbackService() { - ServiceLocator.put(FeedbackService::class) { - FeedbackServiceImpl( - logger = ServiceLocator.get().value, - httpClient = ServiceLocator.get().value, - endpoints = ServiceLocator.get().value, - coroutineContext = Dispatchers.IO - ) - } - } - - private fun putRecommendService() { - ServiceLocator.put(RecommendService::class) { - RecommendServiceImpl( - logger = ServiceLocator.get().value, - httpClient = ServiceLocator.get().value, - endpoints = ServiceLocator.get().value, - coroutineContext = Dispatchers.IO - ) - } - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ApiError.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ApiError.kt deleted file mode 100644 index f3a7615..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ApiError.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -class ApiError( - @SerialName("title") - val title: String? = null, - - @SerialName("status") - val status: Int? = null, - - @SerialName("detail") - val detail: String? = null, - - @SerialName("traceId") - val traceId: String? = null, - - @SerialName("itemKey") - val itemKey: String? = null, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/CommonHeaders.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/CommonHeaders.kt deleted file mode 100644 index 6148a14..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/CommonHeaders.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network - -internal class CommonHeaders( - apiKey: String, - userAgent: UserAgent, -) { - val default: Map = mapOf( - NyrisHttpHeaders.XApiKey to apiKey, - NyrisHttpHeaders.UserAgent to userAgent.toString(), - ) -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/Endpoints.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/Endpoints.kt index e18c003..e1dca64 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/Endpoints.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/Endpoints.kt @@ -15,8 +15,25 @@ */ package io.nyris.sdk.internal.network +import io.nyris.sdk.ResponseException import io.nyris.sdk.internal.repository.imagematching.GeolocationParam +class ApiError( + val title: String? = null, + val status: Int? = null, + val detail: String? = null, + val traceId: String? = null, + val itemKey: String? = null, +) + +internal class CommonHeaders( + apiKey: String, + userAgent: UserAgent, +) { + val default: Map = mapOf( + ) +} + internal class Endpoints(baseUrl: String) { private val find: String = "${baseUrl}find/v1.1" @@ -32,3 +49,11 @@ internal class Endpoints(baseUrl: String) { fun recommend(sku: String) = "$recommend/$sku" } + +internal fun ApiError.toNyrisException(): ResponseException = ResponseException( + title = title, + status = status, + detail = detail, + traceId = traceId, + itemKey = itemKey +) \ No newline at end of file diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ExceptionMapper.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ExceptionMapper.kt deleted file mode 100644 index 7321f3f..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/ExceptionMapper.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network - -import io.ktor.client.plugins.ClientRequestException -import io.ktor.client.plugins.ServerResponseException -import io.nyris.sdk.ClientException -import io.nyris.sdk.ResponseException -import io.nyris.sdk.ServerException - -internal fun ApiError.toNyrisException(): ResponseException = ResponseException( - title = title, - status = status, - detail = detail, - traceId = traceId, - itemKey = itemKey -) - -internal fun ClientRequestException.toNyrisException(): ClientException = ClientException(message) - -internal fun ServerResponseException.toNyrisException(): ServerException = ServerException(message) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/NyrisHttpClient.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/NyrisHttpClient.kt index 334ea66..0409951 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/NyrisHttpClient.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/NyrisHttpClient.kt @@ -15,99 +15,64 @@ */ package io.nyris.sdk.internal.network -import io.ktor.client.HttpClient -import io.ktor.client.call.body -import io.ktor.client.plugins.ClientRequestException -import io.ktor.client.plugins.ServerResponseException -import io.ktor.client.request.HttpRequestBuilder -import io.ktor.client.request.get -import io.ktor.client.request.header -import io.ktor.client.request.post -import io.ktor.client.statement.HttpResponse -import io.ktor.http.HttpHeaders -import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.NyrisPlatform -internal class NyrisHttpClient( - private val logger: Logger, - private val commonHeaders: CommonHeaders, - private val httpClient: HttpClientWrapper, -) { - suspend fun post( - endpoint: String, - block: HttpRequestBuilder.() -> Unit = {}, - ): HttpResponse = sendHttpRequestAndHandleError { - logger.log("[NyrisHttpClient] post $endpoint") - logger.log("[NyrisHttpClient] apiHeaders[${commonHeaders.default}]") - val response = httpClient.post(endpoint) { - this.apply(block) - commonHeaders.default.forEach { entry -> header(entry.key, entry.value) } - } - if (response.status.value in OK_STATUS) { - logger.log("[NyrisHttpClient] post status ok") - response - } else { - logger.log("[NyrisHttpClient] post status ${response.status}") - throw response.body().toNyrisException() - } +internal class NyrisHttpClient { + suspend fun post() { + TODO("Not yet implemented") } - suspend fun get( - endpoint: String, - block: HttpRequestBuilder.() -> Unit = {}, - ): HttpResponse = sendHttpRequestAndHandleError { - logger.log("[NyrisHttpClient] get $endpoint") - logger.log("[NyrisHttpClient] apiHeaders[${commonHeaders.default}]") - val response = httpClient.get(endpoint) { - this.apply(block) - commonHeaders.default.forEach { entry -> header(entry.key, entry.value) } - } - if (response.status.value in OK_STATUS) { - logger.log("[NyrisHttpClient] get status ok") - response - } else { - logger.log("[NyrisHttpClient] post status ${response.status}") - throw response.body().toNyrisException() - } + suspend fun get() { + TODO("Not yet implemented") } - private suspend fun sendHttpRequestAndHandleError(block: suspend Unit.() -> HttpResponse): HttpResponse = try { - block(Unit) - } catch (ignore: ClientRequestException) { - logger.log("[NyrisHttpClient] ClientRequestException is thrown") - throw ignore.toNyrisException() - } catch (ignore: ServerResponseException) { - logger.log("[NyrisHttpClient] ServerResponseException is thrown") - throw ignore.toNyrisException() - } catch (e: Throwable) { - logger.log("[NyrisHttpClient] General Exception is thrown") - throw e + private suspend fun sendHttpRequestAndHandleError() { + TODO("Not yet implemented") } } -internal class HttpClientWrapper(private val httpClient: HttpClient) { - suspend fun post( - urlString: String, - block: HttpRequestBuilder.() -> Unit = {}, - ): HttpResponse = httpClient.post(urlString, block) +internal object NyrisHttpHeaders - suspend fun get( - urlString: String, - block: HttpRequestBuilder.() -> Unit = {}, - ): HttpResponse = httpClient.get(urlString, block) +private const val OK_MIN = 200 +private const val OK_MAX = 200 +private val OK_STATUS = OK_MIN..OK_MAX + +internal class UserAgent( + private val sdkVersion: String, + private val platform: NyrisPlatform, + private val osVersion: String, +) { + override fun toString(): String = "sdk-client/$sdkVersion ($platform $osVersion)" } -object NyrisHttpHeaders { - val UserAgent: String = HttpHeaders.UserAgent - val AcceptLanguage: String = HttpHeaders.AcceptLanguage - val ContentLength: String = HttpHeaders.ContentLength - val ContentDisposition: String = HttpHeaders.ContentDisposition - val ContentType: String = HttpHeaders.ContentType +internal class XOptionsBuilder { + private var limit: Int? = null + private var threshold: Float? = null + + fun limit(limit: Int?) = apply { + this.limit = limit + } + + fun threshold(threshold: Float?) = apply { + this.threshold = threshold + } - const val XApiKey: String = "X-Api-Key" - const val XSession: String = "X-Session" - const val XOptions: String = "X-Options" + fun build(): String? = StringBuilder().apply { + if (limit != null) { + append("limit=$limit ") + } + if (threshold != null) { + append("threshold=$threshold ") + } + }.toString().takeIf { xOptions -> + xOptions.isNotEmpty() + }.also { + reset() + } + + private fun reset() { + limit = null + threshold = null + } } -private const val OK_MIN = 200 -private const val OK_MAX = 200 -private val OK_STATUS = OK_MIN..OK_MAX diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/UserAgent.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/UserAgent.kt deleted file mode 100644 index 36c028d..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/UserAgent.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network - -import io.nyris.sdk.NyrisPlatform - -internal class UserAgent( - private val sdkVersion: String, - private val platform: NyrisPlatform, - private val osVersion: String, -) { - override fun toString(): String = "sdk-client/$sdkVersion ($platform $osVersion)" -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/XOptionsBuilder.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/XOptionsBuilder.kt deleted file mode 100644 index caa927a..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/XOptionsBuilder.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network - -internal class XOptionsBuilder { - private var limit: Int? = null - private var threshold: Float? = null - - fun limit(limit: Int?) = apply { - this.limit = limit - } - - fun threshold(threshold: Float?) = apply { - this.threshold = threshold - } - - fun build(): String? = StringBuilder().apply { - if (limit != null) { - append("limit=$limit ") - } - if (threshold != null) { - append("threshold=$threshold ") - } - }.toString().takeIf { xOptions -> - xOptions.isNotEmpty() - }.also { - reset() - } - - private fun reset() { - limit = null - threshold = null - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackDtoSerializer.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackDtoSerializer.kt deleted file mode 100644 index bea0d02..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackDtoSerializer.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network.feedback - -import kotlinx.serialization.KSerializer -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.descriptors.buildClassSerialDescriptor -import kotlinx.serialization.descriptors.element -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder -import kotlinx.serialization.encoding.encodeStructure -import kotlinx.serialization.serializer - -internal object FeedbackDtoSerializer : KSerializer { - override val descriptor: SerialDescriptor = buildClassSerialDescriptor("FeedbackDto") { - element>("positions") - element>("product_ids") - element("success") - element("comment") - element("rect") - } - - // NO Deserialize, return EMPTY - override fun deserialize(decoder: Decoder): FeedbackDto = FeedbackDto.EMPTY - - override fun serialize( - encoder: Encoder, - value: FeedbackDto, - ) { - encoder.encodeStructure(descriptor) { - when (value) { - is ClickFeedbackDto -> { - encodeSerializableElement(descriptor, POSITIONS_INDEX, serializer(), value.positions) - encodeSerializableElement(descriptor, PUBLIC_IDS_INDEX, serializer(), value.productIds) - } - is ConversationFeedbackDto -> { - encodeSerializableElement(descriptor, POSITIONS_INDEX, serializer(), value.positions) - encodeSerializableElement(descriptor, PUBLIC_IDS_INDEX, serializer(), value.productIds) - } - is CommentFeedbackDto -> { - encodeBooleanElement(descriptor, SUCCESS_INDEX, value.success) - value.comment?.let { encodeStringElement(descriptor, COMMENT_INDEX, value.comment) } - } - is RegionFeedbackDto -> { - encodeSerializableElement(descriptor, RECT_INDEX, serializer(), value.rect) - } - is FeedbackDto.EMPTY -> { - /*Ignore*/ - } - } - } - } -} - -private const val POSITIONS_INDEX = 0 -private const val PUBLIC_IDS_INDEX = 1 -private const val SUCCESS_INDEX = 2 -private const val COMMENT_INDEX = 3 -private const val RECT_INDEX = 4 diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackRequest.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackRequest.kt deleted file mode 100644 index 0be9506..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackRequest.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network.feedback - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -internal data class FeedbackRequest( - @SerialName("request_id") - val requestId: String, - @SerialName("session_id") - val sessionId: String, - @SerialName("timestamp") - val timestamp: String, - @SerialName("event") - val eventType: String, - @SerialName("data") - val data: FeedbackDto, -) - -@Serializable(FeedbackDtoSerializer::class) -internal sealed class FeedbackDto { - internal object EMPTY : FeedbackDto() -} - -@Serializable -internal data class ClickFeedbackDto( - @SerialName("positions") - val positions: List, - @SerialName("product_ids") - val productIds: List, -) : FeedbackDto() - -@Serializable -internal data class ConversationFeedbackDto( - @SerialName("positions") - val positions: List, - @SerialName("product_ids") - val productIds: List, -) : FeedbackDto() - -@Serializable -internal data class CommentFeedbackDto( - @SerialName("success") - val success: Boolean, - @SerialName("comment") - val comment: String?, -) : FeedbackDto() - -@Serializable -internal data class RegionFeedbackDto( - @SerialName("rect") - val rect: RectDto, -) : FeedbackDto() - -@Serializable -internal data class RectDto( - @SerialName("x") - val x: Float, - @SerialName("y") - val y: Float, - @SerialName("w") - val w: Float, - @SerialName("h") - val h: Float, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackService.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackService.kt index 8a40bdd..4438a95 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackService.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/feedback/FeedbackService.kt @@ -15,40 +15,53 @@ */ package io.nyris.sdk.internal.network.feedback -import io.ktor.client.request.setBody -import io.ktor.http.ContentType -import io.ktor.http.contentType -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.util.Logger -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.withContext +import io.nyris.sdk.builder.NyrisResult internal interface FeedbackService { - suspend fun send(feedbackRequest: FeedbackRequest): Result + suspend fun send(feedbackRequest: FeedbackRequest): NyrisResult } -internal class FeedbackServiceImpl( - private val logger: Logger, - private val endpoints: Endpoints, - private val httpClient: NyrisHttpClient, - private val coroutineContext: CoroutineContext, -) : FeedbackService { - override suspend fun send( - feedbackRequest: FeedbackRequest, - ): Result = withContext(coroutineContext) { - logger.log("[FeedbackServiceImpl] send") - return@withContext try { - httpClient.post(endpoints.feedback) { - contentType(ContentType.Application.Json) - - setBody(feedbackRequest) - } - Result.success(Unit) - } catch (e: Throwable) { - Result.failure(e).also { - logger.log("[RegionsServiceImpl] result is failure") - } - } +internal class FeedbackServiceImpl : FeedbackService { + override suspend fun send(feedbackRequest: FeedbackRequest): NyrisResult { + TODO("Not yet implemented") } } + + +internal class FeedbackRequest( + val requestId: String, + val sessionId: String, + val timestamp: String, + val eventType: String, + val data: FeedbackDto, +) + +internal sealed class FeedbackDto { + internal object EMPTY : FeedbackDto() +} + +internal class ClickFeedbackDto( + val positions: List, + val productIds: List, +) : FeedbackDto() + +internal class ConversationFeedbackDto( + val positions: List, + val productIds: List, +) : FeedbackDto() + +internal class CommentFeedbackDto( + val success: Boolean, + val comment: String?, +) : FeedbackDto() + +internal class RegionFeedbackDto( + val rect: RectDto, +) : FeedbackDto() + +internal class RectDto( + val x: Float, + val y: Float, + val w: Float, + val h: Float, +) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindResponse.kt deleted file mode 100644 index b0fbae2..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindResponse.kt +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network.find - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -internal class FindResponse( - @SerialName("id") - val requestId: String? = null, - - @SerialName("session") - val sessionId: String? = null, - - @SerialName("results") - val offers: List = emptyList(), -) - -@Serializable -@Suppress("LongParameterList") -internal class OfferDto( - @SerialName("oid") - val id: String? = null, - - @SerialName("title") - val title: String? = null, - - @SerialName("descriptionShort") - val description: String? = null, - - @SerialName("descriptionLong") - val descriptionLong: String? = null, - - @SerialName("language") - val language: String? = null, - - @SerialName("brand") - val brand: String? = null, - - @SerialName("catalogNumbers") - val catalogNumbers: List = emptyList(), - - @SerialName("customIds") - val customIds: Map = emptyMap(), - - @SerialName("keywords") - val keywords: List = emptyList(), - - @SerialName("categories") - val categories: List = emptyList(), - - @SerialName("availability") - val availability: String? = null, - - @SerialName("feedId") - val feedId: String? = null, - - @SerialName("groupId") - val groupId: String? = null, - - @SerialName("price") - val priceStr: String? = null, - - @SerialName("salePrice") - val salePrice: String? = null, - - @SerialName("links") - val links: LinksDto? = null, - - @SerialName("images") - val images: List = emptyList(), - - @SerialName("metadata") - val metadata: String? = null, - - @SerialName("sku") - val sku: String? = null, - - @SerialName("score") - val score: Float? = null, -) - -@Serializable -internal class LinksDto( - @SerialName("main") - val main: String? = null, - - @SerialName("mobile") - val mobile: String? = null, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindService.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindService.kt index d053eab..ec7a27a 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindService.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/find/FindService.kt @@ -15,24 +15,7 @@ */ package io.nyris.sdk.internal.network.find -import io.ktor.client.call.body -import io.ktor.client.request.forms.FormBuilder -import io.ktor.client.request.forms.MultiPartFormDataContent -import io.ktor.client.request.forms.formData -import io.ktor.client.request.header -import io.ktor.client.request.setBody -import io.ktor.http.ContentType -import io.ktor.http.Headers -import io.ktor.utils.io.core.buildPacket -import io.ktor.utils.io.core.writeFully -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.network.NyrisHttpHeaders -import io.nyris.sdk.internal.network.XOptionsBuilder import io.nyris.sdk.internal.repository.imagematching.GeolocationParam -import io.nyris.sdk.internal.util.Logger -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.withContext internal interface FindService { suspend fun find( @@ -41,46 +24,17 @@ internal interface FindService { ): Result } -internal class FindServiceImpl( - private val logger: Logger, - private val xOptionsBuilder: XOptionsBuilder, - private val endpoints: Endpoints, - private val httpClient: NyrisHttpClient, - private val coroutineContext: CoroutineContext, -) : FindService { +internal class FindServiceImpl : FindService { override suspend fun find( image: ByteArray, params: FindServiceParams, - ): Result = withContext(coroutineContext) { - logger.log("[FindServiceImpl] find") - logger.log("[FindServiceImpl] params[$params]") - - return@withContext try { - with(params) { - logger.log("[FindServiceImpl] find post ${endpoints.find(geolocation)}") - Result.success( - httpClient.post( - endpoints.find(geolocation) - ) { - header(NyrisHttpHeaders.AcceptLanguage, language) - header(NyrisHttpHeaders.XSession, session) - header(NyrisHttpHeaders.XOptions, xOptionsBuilder.limit(limit).threshold(threshold).build()) - - setBody(buildMultiParamForm(image, params)) - }.body() - ).also { - logger.log("[FindServiceImpl] result is success") - } - } - } catch (e: Throwable) { - Result.failure(e).also { - logger.log("[FindServiceImpl] result is failure") - } - } + ): Result { + TODO("Not yet implemented") } + } -internal data class FindServiceParams( +internal class FindServiceParams( val language: String?, val limit: Int?, val threshold: Float?, @@ -89,35 +43,37 @@ internal data class FindServiceParams( val session: String?, ) -internal fun buildMultiParamForm( - image: ByteArray, - params: FindServiceParams, -): MultiPartFormDataContent = MultiPartFormDataContent( - formData { - appendImage(image) - appendFilters(params.filters) - } + +internal class FindResponse( + val requestId: String? = null, + val sessionId: String? = null, + val offers: List = emptyList(), ) -internal fun FormBuilder.appendImage(image: ByteArray) { - appendInput( - key = "image", - headers = Headers.build { - this.append(NyrisHttpHeaders.ContentDisposition, "filename=image.jpg") - this.append(NyrisHttpHeaders.ContentType, ContentType.Image.JPEG.toString()) - this.append(NyrisHttpHeaders.ContentLength, image.size.toString()) - }, - size = image.size.toLong() - ) { - buildPacket { writeFully(image) } - } -} +internal class OfferDto( + val id: String? = null, + val title: String? = null, + val description: String? = null, + val descriptionLong: String? = null, + val language: String? = null, + val brand: String? = null, + val catalogNumbers: List = emptyList(), + val customIds: Map = emptyMap(), + val keywords: List = emptyList(), + val categories: List = emptyList(), + val availability: String? = null, + val feedId: String? = null, + val groupId: String? = null, + val priceStr: String? = null, + val salePrice: String? = null, + val links: LinksDto? = null, + val images: List = emptyList(), + val metadata: String? = null, + val sku: String? = null, + val score: Float? = null, +) -internal fun FormBuilder.appendFilters(map: Map>) { - map.keys.forEachIndexed { i, filterType -> - append("filters[$i].filterType", filterType) - map[filterType]?.forEachIndexed { j, filterTypeValue -> - append("filters[$i].filterValues[$j]", filterTypeValue) - } - } -} +internal class LinksDto( + val main: String? = null, + val mobile: String? = null, +) \ No newline at end of file diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendResponse.kt deleted file mode 100644 index 79b77b6..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendResponse.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network.recommend - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -class RecommendResponse( - @SerialName("id") - val requestId: String? = null, - @SerialName("session") - val sessionId: String? = null, - @SerialName("results") - val result: List = emptyList(), -) - -@Serializable -class SkuOfferDto( - @SerialName("sku") - val sku: String? = null, - @SerialName("score") - val score: Float? = null, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendService.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendService.kt index 222acda..37606f2 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendService.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/recommend/RecommendService.kt @@ -15,35 +15,24 @@ */ package io.nyris.sdk.internal.network.recommend -import io.ktor.client.call.body -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.util.Logger -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.withContext - internal interface RecommendService { suspend fun match(sku: String): Result } -internal class RecommendServiceImpl( - private val logger: Logger, - private val endpoints: Endpoints, - private val httpClient: NyrisHttpClient, - private val coroutineContext: CoroutineContext, -) : RecommendService { - override suspend fun match(sku: String): Result = withContext(coroutineContext) { - logger.log("[RecommendServiceImpl] match") - try { - Result.success( - httpClient.get(endpoints.recommend(sku)).body() - ).also { - logger.log("[RecommendServiceImpl] result is success") - } - } catch (e: Throwable) { - Result.failure(e).also { - logger.log("[RecommendServiceImpl] result is failure") - } - } +internal class RecommendServiceImpl : RecommendService { + override suspend fun match(sku: String): Result { + TODO("Not yet implemented") } + } + +internal class RecommendResponse( + val requestId: String? = null, + val sessionId: String? = null, + val result: List = emptyList(), +) + +internal class SkuOfferDto( + val sku: String? = null, + val score: Float? = null, +) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsResponse.kt deleted file mode 100644 index b30ddad..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsResponse.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.network.regions - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -internal class RegionsResponse( - @SerialName("regions") - val regionsDto: List = emptyList(), -) - -@Serializable -internal class RegionDto( - @SerialName("confidence") - val confidence: Float = 0.0F, - - @SerialName("region") - val positionDto: PositionDto? = null, -) - -@Serializable -internal class PositionDto( - @SerialName("left") - val left: Float = 0F, - - @SerialName("top") - val top: Float = 0F, - - @SerialName("right") - val right: Float = 0F, - - @SerialName("bottom") - val bottom: Float = 0F, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsService.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsService.kt index 4668688..bb5a75b 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsService.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/network/regions/RegionsService.kt @@ -15,18 +15,6 @@ */ package io.nyris.sdk.internal.network.regions -import io.ktor.client.call.body -import io.ktor.client.request.header -import io.ktor.client.request.setBody -import io.ktor.http.ContentType -import io.ktor.http.contentType -import io.nyris.sdk.internal.network.Endpoints -import io.nyris.sdk.internal.network.NyrisHttpClient -import io.nyris.sdk.internal.network.NyrisHttpHeaders -import io.nyris.sdk.internal.util.Logger -import kotlin.coroutines.CoroutineContext -import kotlinx.coroutines.withContext - internal interface RegionsService { suspend fun detect( image: ByteArray, @@ -34,40 +22,33 @@ internal interface RegionsService { ): Result } -internal class RegionsServiceImpl( - private val logger: Logger, - private val endpoints: Endpoints, - private val httpClient: NyrisHttpClient, - private val coroutineContext: CoroutineContext, -) : RegionsService { - +internal class RegionsServiceImpl : RegionsService { override suspend fun detect( image: ByteArray, params: RegionsServiceParams, - ): Result = withContext(coroutineContext) { - logger.log("[RegionsServiceImpl] detect") - return@withContext try { - with(params) { - Result.success( - httpClient.post(endpoints.regions) { - contentType(ContentType.Image.JPEG) - header(NyrisHttpHeaders.XSession, session) - header(NyrisHttpHeaders.ContentLength, image.size) - - setBody(image) - }.body() - ).also { - logger.log("[RegionsServiceImpl] result is success") - } - } - } catch (e: Throwable) { - Result.failure(e).also { - logger.log("[RegionsServiceImpl] result is failure") - } - } + ): Result { + TODO("Not yet implemented") } } -internal data class RegionsServiceParams( +internal class RegionsServiceParams( val session: String?, ) + + +internal class RegionsResponse( + val regionsDto: List = emptyList(), +) + +internal class RegionDto( + val confidence: Float = 0.0F, + val positionDto: PositionDto? = null, +) + +internal class PositionDto( + val left: Float = 0F, + val top: Float = 0F, + val right: Float = 0F, + val bottom: Float = 0F, +) + diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRepository.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRepository.kt deleted file mode 100644 index 6787b0f..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRepository.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.feedback - -import io.nyris.sdk.internal.network.feedback.FeedbackService -import io.nyris.sdk.internal.util.Logger -import io.nyris.sdk.model.Feedback - -internal interface FeedbackRepository { - suspend fun send(feedback: Feedback): Result -} - -internal class FeedbackRepositoryImpl( - private val logger: Logger, - private val feedbackService: FeedbackService, -) : FeedbackRepository { - override suspend fun send(feedback: Feedback): Result { - logger.log("[FeedbackRepositoryImpl] send") - return feedbackService.send(feedback.toFeedbackRequest()) - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestBuilderImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestBuilderImpl.kt index 1007d7f..4b4e6bd 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestBuilderImpl.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestBuilderImpl.kt @@ -16,15 +16,86 @@ package io.nyris.sdk.internal.repository.feedback import io.nyris.sdk.builder.FeedbackRequestBuilder +import io.nyris.sdk.builder.NyrisResult +import io.nyris.sdk.internal.network.feedback.ClickFeedbackDto +import io.nyris.sdk.internal.network.feedback.CommentFeedbackDto +import io.nyris.sdk.internal.network.feedback.ConversationFeedbackDto +import io.nyris.sdk.internal.network.feedback.FeedbackDto +import io.nyris.sdk.internal.network.feedback.FeedbackRequest +import io.nyris.sdk.internal.network.feedback.FeedbackService +import io.nyris.sdk.internal.network.feedback.RectDto +import io.nyris.sdk.internal.network.feedback.RegionFeedbackDto import io.nyris.sdk.internal.util.Logger import io.nyris.sdk.model.Feedback +internal interface FeedbackRepository { + suspend fun send(feedback: Feedback): NyrisResult +} + +internal class FeedbackRepositoryImpl( + private val logger: Logger, + private val feedbackService: FeedbackService, +) : FeedbackRepository { + override suspend fun send(feedback: Feedback): NyrisResult { + logger.log("[FeedbackRepositoryImpl] send") + return feedbackService.send(feedback.toFeedbackRequest()) + } +} + internal class FeedbackRequestBuilderImpl( private val logger: Logger, private val feedbackRepository: FeedbackRepository, ) : FeedbackRequestBuilder { - override suspend fun send(feedback: Feedback): Result { + override suspend fun send(feedback: Feedback): NyrisResult { logger.log("[FeedbackRequestBuilderImpl] send") return feedbackRepository.send(feedback) } } + +internal fun Feedback.toFeedbackRequest(): FeedbackRequest = with(this) { + FeedbackRequest( + requestId = this.requestId, + sessionId = this.sessionId, + timestamp = "", + eventType = this.toEventType(), + data = this.toData() + ) +} + +internal fun Feedback.toEventType(): String = when (this) { + is Feedback.Click -> "click" + is Feedback.Conversion -> "conversion" + is Feedback.Comment -> "feedback" + is Feedback.Region -> "region" +} + +internal fun Feedback.toData(): FeedbackDto = when (this) { + is Feedback.Click -> { + ClickFeedbackDto( + productIds = this.productIds, + positions = this.positions + ) + } + is Feedback.Conversion -> { + ConversationFeedbackDto( + productIds = this.productIds, + positions = this.positions + ) + } + is Feedback.Comment -> { + CommentFeedbackDto( + success = this.success, + comment = this.comment + ) + } + is Feedback.Region -> { + RegionFeedbackDto( + RectDto( + x = this.left, + y = this.top, + w = this.width, + h = this.height + ) + ) + } +} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestMapper.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestMapper.kt deleted file mode 100644 index c074648..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/feedback/FeedbackRequestMapper.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.feedback - -import io.nyris.sdk.internal.network.feedback.ClickFeedbackDto -import io.nyris.sdk.internal.network.feedback.CommentFeedbackDto -import io.nyris.sdk.internal.network.feedback.ConversationFeedbackDto -import io.nyris.sdk.internal.network.feedback.FeedbackDto -import io.nyris.sdk.internal.network.feedback.FeedbackRequest -import io.nyris.sdk.internal.network.feedback.RectDto -import io.nyris.sdk.internal.network.feedback.RegionFeedbackDto -import io.nyris.sdk.model.Feedback -import kotlinx.datetime.Clock - -internal fun Feedback.toFeedbackRequest(): FeedbackRequest = with(this) { - FeedbackRequest( - requestId = this.requestId, - sessionId = this.sessionId, - timestamp = TimeProvider.currentTime(), - eventType = this.toEventType(), - data = this.toData() - ) -} - -internal fun Feedback.toEventType(): String = when (this) { - is Feedback.Click -> "click" - is Feedback.Conversion -> "conversion" - is Feedback.Comment -> "feedback" - is Feedback.Region -> "region" -} - -internal fun Feedback.toData(): FeedbackDto = when (this) { - is Feedback.Click -> { - ClickFeedbackDto( - productIds = this.productIds, - positions = this.positions - ) - } - is Feedback.Conversion -> { - ConversationFeedbackDto( - productIds = this.productIds, - positions = this.positions - ) - } - is Feedback.Comment -> { - CommentFeedbackDto( - success = this.success, - comment = this.comment - ) - } - is Feedback.Region -> { - RegionFeedbackDto( - RectDto( - x = this.left, - y = this.top, - w = this.width, - h = this.height - ) - ) - } -} - -internal object TimeProvider { - fun currentTime(): String = Clock.System.now().toString() -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRepository.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRepository.kt deleted file mode 100644 index 9605646..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRepository.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.imagematching - -import io.nyris.sdk.internal.network.find.FindService -import io.nyris.sdk.internal.network.find.FindServiceParams -import io.nyris.sdk.internal.util.Logger -import io.nyris.sdk.model.MatchResponse - -internal interface ImageMatchingRepository { - suspend fun match( - image: ByteArray, - params: ImageMatchingParams, - ): Result -} - -internal class ImageMatchingRepositoryImpl( - private val logger: Logger, - private val findService: FindService, -) : ImageMatchingRepository { - override suspend fun match( - image: ByteArray, - params: ImageMatchingParams, - ): Result { - logger.log("[ImageMatchingRepositoryImpl] match") - return findService.find( - image, - params.toParams() - ).map { findResponse -> - logger.log("[ImageMatchingRepositoryImpl] mapping findResponse to match response") - findResponse.toMatchResponse() - } - } -} - -internal data class ImageMatchingParams( - val limit: Int?, - val language: String?, - val threshold: Float?, - val geolocation: GeolocationParam?, - val filters: Map>, - val session: String?, -) - -internal data class GeolocationParam( - val lat: Float, - val lon: Float, - val dist: Int, -) - -internal fun ImageMatchingParams.toParams(): FindServiceParams = FindServiceParams( - language = language, - limit = limit, - threshold = threshold, - geolocation = geolocation, - filters = filters, - session = session -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt index 5985243..548c9e6 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt @@ -16,12 +16,19 @@ package io.nyris.sdk.internal.repository.imagematching import io.nyris.sdk.builder.ImageMatchingRequestBuilder +import io.nyris.sdk.internal.network.find.FindResponse +import io.nyris.sdk.internal.network.find.FindService +import io.nyris.sdk.internal.network.find.FindServiceParams +import io.nyris.sdk.internal.network.find.LinksDto +import io.nyris.sdk.internal.network.find.OfferDto import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.model.Links import io.nyris.sdk.model.MatchResponse +import io.nyris.sdk.model.Offer -internal class ImageMatchingRequestBuilderImpl( - private val logger: Logger, - private val imageMatchingRepository: ImageMatchingRepository, +internal abstract class CommonImageMatchingRequestBuilderImpl( + protected val logger: Logger, + protected val imageMatchingRepository: ImageMatchingRepository, ) : ImageMatchingRequestBuilder { private var limit: Int? = null private var language: String? = null @@ -70,15 +77,6 @@ internal class ImageMatchingRequestBuilderImpl( this.session = session } - override suspend fun match(image: ByteArray): Result { - logger.log("[ImageMatchingRequestBuilderImpl] match") - - return imageMatchingRepository.match( - image = image, - params = createParams() - ) - } - internal fun createParams(): ImageMatchingParams = ImageMatchingParams( limit = limit, language = language, @@ -106,3 +104,105 @@ private const val LIMIT_MIN = 1 private const val LIMIT_MAX = 100 private const val THRESHOLD_MIN = 0.01F private const val THRESHOLD_MAX = 1.0F + +internal expect class ImageMatchingRequestBuilderImpl( + logger: Logger, + imageMatchingRepository: ImageMatchingRepository, +) : CommonImageMatchingRequestBuilderImpl + +expect class DataType + + +internal interface ImageMatchingRepository { + suspend fun match( + image: ByteArray, + params: ImageMatchingParams, + ): Result +} + +internal class ImageMatchingRepositoryImpl( + private val logger: Logger, + private val findService: FindService, +) : ImageMatchingRepository { + override suspend fun match( + image: ByteArray, + params: ImageMatchingParams, + ): Result { + logger.log("[ImageMatchingRepositoryImpl] match") + return findService.find( + image, + params.toParams() + ).map { findResponse -> + logger.log("[ImageMatchingRepositoryImpl] mapping findResponse to match response") + findResponse.toMatchResponse() + } + } +} + +internal class ImageMatchingParams( + val limit: Int?, + val language: String?, + val threshold: Float?, + val geolocation: GeolocationParam?, + val filters: Map>, + val session: String?, +) + +internal class GeolocationParam( + val lat: Float, + val lon: Float, + val dist: Int, +) + +internal fun ImageMatchingParams.toParams(): FindServiceParams = FindServiceParams( + language = language, + limit = limit, + threshold = threshold, + geolocation = geolocation, + filters = filters, + session = session +) + + +internal fun FindResponse.toMatchResponse(): MatchResponse = with(this) { + MatchResponse( + requestId = requestId, + sessionId = sessionId, + offers = offers.toOfferList() + ) +} + +internal fun List.toOfferList(): List = map { dto -> + dto.toOffer() +} + +internal fun OfferDto.toOffer(): Offer = with(this) { + Offer( + id = id, + title = title, + description = description, + descriptionLong = descriptionLong, + language = language, + brand = brand, + catalogNumbers = catalogNumbers, + customIds = customIds, + keywords = keywords, + categories = categories, + availability = availability, + feedId = feedId, + groupId = groupId, + priceStr = priceStr, + salePrice = salePrice, + links = links.toLinks(), + images = images, + metadata = metadata, + sku = sku, + score = score, + ) +} + +internal fun LinksDto?.toLinks(): Links = Links( + main = this?.main, + mobile = this?.mobile +) + diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/MatchResponseMapper.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/MatchResponseMapper.kt deleted file mode 100644 index 790417f..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/imagematching/MatchResponseMapper.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.imagematching - -import io.nyris.sdk.internal.network.find.FindResponse -import io.nyris.sdk.internal.network.find.LinksDto -import io.nyris.sdk.internal.network.find.OfferDto -import io.nyris.sdk.model.Links -import io.nyris.sdk.model.MatchResponse -import io.nyris.sdk.model.Offer - -internal fun FindResponse.toMatchResponse(): MatchResponse = with(this) { - MatchResponse( - requestId = requestId, - sessionId = sessionId, - offers = offers.toOfferList() - ) -} - -internal fun List.toOfferList(): List = map { dto -> - dto.toOffer() -} - -internal fun OfferDto.toOffer(): Offer = with(this) { - Offer( - id = id, - title = title, - description = description, - descriptionLong = descriptionLong, - language = language, - brand = brand, - catalogNumbers = catalogNumbers, - customIds = customIds, - keywords = keywords, - categories = categories, - availability = availability, - feedId = feedId, - groupId = groupId, - priceStr = priceStr, - salePrice = salePrice, - links = links.toLinks(), - images = images, - metadata = metadata, - sku = sku, - score = score, - ) -} - -internal fun LinksDto?.toLinks(): Links = Links( - main = this?.main, - mobile = this?.mobile -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/DetectResponseMapper.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/DetectResponseMapper.kt deleted file mode 100644 index 3c22334..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/DetectResponseMapper.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.objectdetecting - -import io.nyris.sdk.internal.network.regions.PositionDto -import io.nyris.sdk.internal.network.regions.RegionDto -import io.nyris.sdk.internal.network.regions.RegionsResponse -import io.nyris.sdk.model.DetectResponse -import io.nyris.sdk.model.Position -import io.nyris.sdk.model.Region - -internal fun RegionsResponse.toDetectResponse(): DetectResponse = with(this) { - DetectResponse(regions = regionsDto.toRegions()) -} - -private fun List.toRegions(): List = map { dto -> - dto.toRegion() -} - -private fun RegionDto.toRegion(): Region = with(this) { - Region( - confidence = confidence, - position = positionDto?.toPosition() - ) -} - -private fun PositionDto.toPosition(): Position = with(this) { - Position( - left = left, - top = top, - right = right, - bottom - ) -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRepository.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRepository.kt deleted file mode 100644 index cd137c6..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRepository.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.objectdetecting - -import io.nyris.sdk.internal.network.regions.RegionsService -import io.nyris.sdk.internal.network.regions.RegionsServiceParams -import io.nyris.sdk.internal.util.Logger -import io.nyris.sdk.model.DetectResponse - -internal interface ObjectDetectingRepository { - suspend fun detect( - image: ByteArray, - params: ObjectDetectingParams, - ): Result -} - -internal class ObjectDetectingRepositoryImpl( - private val logger: Logger, - private val regionsService: RegionsService, -) : ObjectDetectingRepository { - override suspend fun detect( - image: ByteArray, - params: ObjectDetectingParams, - ): Result { - logger.log("[ObjectDetectingRepositoryImpl] detect") - return regionsService.detect(image, params.toParams()).map { regionsResponse -> - logger.log("[ObjectDetectingRepositoryImpl] mapping regions response to detect response") - regionsResponse.toDetectResponse() - } - } -} - -internal data class ObjectDetectingParams( - val session: String?, -) - -internal fun ObjectDetectingParams.toParams(): RegionsServiceParams = RegionsServiceParams( - session = session, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRequestBuilderImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRequestBuilderImpl.kt index 90f5201..a462e6b 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRequestBuilderImpl.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/objectdetecting/ObjectDetectingRequestBuilderImpl.kt @@ -16,8 +16,15 @@ package io.nyris.sdk.internal.repository.objectdetecting import io.nyris.sdk.builder.ObjectDetectingRequestBuilder +import io.nyris.sdk.internal.network.regions.PositionDto +import io.nyris.sdk.internal.network.regions.RegionDto +import io.nyris.sdk.internal.network.regions.RegionsResponse +import io.nyris.sdk.internal.network.regions.RegionsService +import io.nyris.sdk.internal.network.regions.RegionsServiceParams import io.nyris.sdk.internal.util.Logger import io.nyris.sdk.model.DetectResponse +import io.nyris.sdk.model.Position +import io.nyris.sdk.model.Region internal class ObjectDetectingRequestBuilderImpl( private val logger: Logger, @@ -47,3 +54,59 @@ internal class ObjectDetectingRequestBuilderImpl( session = null } } + + +internal interface ObjectDetectingRepository { + suspend fun detect( + image: ByteArray, + params: ObjectDetectingParams, + ): Result +} + +internal class ObjectDetectingRepositoryImpl( + private val logger: Logger, + private val regionsService: RegionsService, +) : ObjectDetectingRepository { + override suspend fun detect( + image: ByteArray, + params: ObjectDetectingParams, + ): Result { + logger.log("[ObjectDetectingRepositoryImpl] detect") + return regionsService.detect(image, params.toParams()).map { regionsResponse -> + logger.log("[ObjectDetectingRepositoryImpl] mapping regions response to detect response") + regionsResponse.toDetectResponse() + } + } +} + +internal class ObjectDetectingParams( + val session: String?, +) + +internal fun ObjectDetectingParams.toParams(): RegionsServiceParams = RegionsServiceParams( + session = session, +) + +internal fun RegionsResponse.toDetectResponse(): DetectResponse = with(this) { + DetectResponse(regions = regionsDto.toRegions()) +} + +private fun List.toRegions(): List = map { dto -> + dto.toRegion() +} + +private fun RegionDto.toRegion(): Region = with(this) { + Region( + confidence = confidence, + position = positionDto?.toPosition() + ) +} + +private fun PositionDto.toPosition(): Position = with(this) { + Position( + left = left, + top = top, + right = right, + bottom + ) +} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRepository.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRepository.kt deleted file mode 100644 index 08ad3e9..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRepository.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.skumatching - -import io.nyris.sdk.internal.network.recommend.RecommendService -import io.nyris.sdk.internal.util.Logger -import io.nyris.sdk.model.SkuResponse - -internal interface SkuMatchingRepository { - suspend fun match(sku: String): Result -} - -internal class SkuMatchingRepositoryImpl( - private val logger: Logger, - private val recommendService: RecommendService, -) : SkuMatchingRepository { - override suspend fun match(sku: String): Result { - logger.log("[SkuMatchingRepositoryImpl] match") - return recommendService.match(sku).map { recommendResponse -> - recommendResponse.toSkuResponse() - } - } -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRequestBuilderImpl.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRequestBuilderImpl.kt index 3fe5d04..eacc297 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRequestBuilderImpl.kt +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuMatchingRequestBuilderImpl.kt @@ -16,7 +16,11 @@ package io.nyris.sdk.internal.repository.skumatching import io.nyris.sdk.builder.SkuMatchingRequestBuilder +import io.nyris.sdk.internal.network.recommend.RecommendResponse +import io.nyris.sdk.internal.network.recommend.RecommendService +import io.nyris.sdk.internal.network.recommend.SkuOfferDto import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.model.SkuOffer import io.nyris.sdk.model.SkuResponse internal class SkuMatchingRequestBuilderImpl( @@ -28,3 +32,36 @@ internal class SkuMatchingRequestBuilderImpl( return skuMatchingRepository.match(sku) } } + +internal interface SkuMatchingRepository { + suspend fun match(sku: String): Result +} + +internal class SkuMatchingRepositoryImpl( + private val logger: Logger, + private val recommendService: RecommendService, +) : SkuMatchingRepository { + override suspend fun match(sku: String): Result { + logger.log("[SkuMatchingRepositoryImpl] match") + return recommendService.match(sku).map { recommendResponse -> + recommendResponse.toSkuResponse() + } + } +} + +internal fun RecommendResponse.toSkuResponse(): SkuResponse = SkuResponse( + requestId = requestId, + sessionId = sessionId, + offers = result.toSkuOfferList() +) + +internal fun List.toSkuOfferList() = this.map { dto -> + dto.toSkuOffer() +} + +internal fun SkuOfferDto.toSkuOffer() = with(this) { + SkuOffer( + sku = sku, + score = score + ) +} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuResponseMapper.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuResponseMapper.kt deleted file mode 100644 index 5310559..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/internal/repository/skumatching/SkuResponseMapper.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.internal.repository.skumatching - -import io.nyris.sdk.internal.network.recommend.RecommendResponse -import io.nyris.sdk.internal.network.recommend.SkuOfferDto -import io.nyris.sdk.model.SkuOffer -import io.nyris.sdk.model.SkuResponse - -internal fun RecommendResponse.toSkuResponse(): SkuResponse = SkuResponse( - requestId = requestId, - sessionId = sessionId, - offers = result.toSkuOfferList() -) - -internal fun List.toSkuOfferList() = this.map { dto -> - dto.toSkuOffer() -} - -internal fun SkuOfferDto.toSkuOffer() = with(this) { - SkuOffer( - sku = sku, - score = score - ) -} diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/DetectResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/DetectResponse.kt deleted file mode 100644 index 662b6d5..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/DetectResponse.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.model - -data class DetectResponse( - val regions: List = emptyList(), -) - -data class Region( - val confidence: Float = 0.0F, - val position: Position? = null, -) - -data class Position( - val left: Float = 0F, - val top: Float = 0F, - val right: Float = 0F, - val bottom: Float = 0F, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Feedback.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Feedback.kt deleted file mode 100644 index 784d6ab..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Feedback.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.model - -sealed class Feedback private constructor( - internal val requestId: String, - internal val sessionId: String, -) { - class Click( - requestId: String, - sessionId: String, - val positions: List, - val productIds: List, - ) : Feedback(requestId, sessionId) - - class Conversion( - requestId: String, - sessionId: String, - val positions: List, - val productIds: List, - ) : Feedback(requestId, sessionId) - - class Comment( - requestId: String, - sessionId: String, - val success: Boolean, - val comment: String? = null, - ) : Feedback(requestId, sessionId) - - class Region( - requestId: String, - sessionId: String, - val left: Float, - val top: Float, - val width: Float, - val height: Float, - ) : Feedback(requestId, sessionId) { - init { - require(left in RANGE_MIN..RANGE_MAX) { "left[$left] should be in range of 0.0 to 1.0" } - require(top in RANGE_MIN..RANGE_MAX) { "top[$top] should be in range of 0.0 to 1.0" } - require(width in RANGE_MIN..RANGE_MAX) { "width[$width] should be in range of 0.0 to 1.0" } - require(height in RANGE_MIN..RANGE_MAX) { "height[$height] should be in range of 0.0 to 1.0" } - } - } -} - -private const val RANGE_MIN = 0.0 -private const val RANGE_MAX = 1.0 diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/MatchResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/MatchResponse.kt deleted file mode 100644 index 228044f..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/MatchResponse.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.model - -data class MatchResponse( - val requestId: String? = null, - - val sessionId: String? = null, - - val offers: List = emptyList(), -) - -data class Offer( - val id: String? = null, - val title: String? = null, - val description: String? = null, - val descriptionLong: String? = null, - val language: String? = null, - val brand: String? = null, - val catalogNumbers: List = emptyList(), - val customIds: Map = emptyMap(), - val keywords: List? = null, - val categories: List = emptyList(), - val availability: String? = null, - val feedId: String? = null, - val groupId: String? = null, - val priceStr: String? = null, - val salePrice: String? = null, - val links: Links? = null, - val images: List = emptyList(), - val metadata: String? = null, - val sku: String? = null, - val score: Float? = null, -) - -data class Links( - val main: String? = null, - val mobile: String? = null, -) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Models.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Models.kt new file mode 100644 index 0000000..8ec66af --- /dev/null +++ b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/Models.kt @@ -0,0 +1,113 @@ +package io.nyris.sdk.model + +class DetectResponse( + val regions: List = emptyList(), +) + +class Region( + val confidence: Float = 0.0F, + val position: Position? = null, +) + +class Position( + val left: Float = 0F, + val top: Float = 0F, + val right: Float = 0F, + val bottom: Float = 0F, +) + +sealed class Feedback private constructor( + internal val requestId: String, + internal val sessionId: String, +) { + class Click( + requestId: String, + sessionId: String, + //TODO: Check if we can use @ShouldRefineInSwift + // https://kotlinlang.org/docs/native-objc-interop.html#hiding-kotlin-declarations + // @ShouldRefineInSwift + // TODO: try to rename KotlinInt to just NSNumber to make it more iOS friendly. + val positions: List, + val productIds: List, + ) : Feedback(requestId, sessionId) + + class Conversion( + requestId: String, + sessionId: String, + val positions: List, + val productIds: List, + ) : Feedback(requestId, sessionId) + + class Comment( + requestId: String, + sessionId: String, + val success: Boolean, + val comment: String? = null, + ) : Feedback(requestId, sessionId) + + class Region( + requestId: String, + sessionId: String, + val left: Float, + val top: Float, + val width: Float, + val height: Float, + ) : Feedback(requestId, sessionId) { + init { + require(left in RANGE_MIN..RANGE_MAX) { "left[$left] should be in range of 0.0 to 1.0" } + require(top in RANGE_MIN..RANGE_MAX) { "top[$top] should be in range of 0.0 to 1.0" } + require(width in RANGE_MIN..RANGE_MAX) { "width[$width] should be in range of 0.0 to 1.0" } + require(height in RANGE_MIN..RANGE_MAX) { "height[$height] should be in range of 0.0 to 1.0" } + } + } +} + +private const val RANGE_MIN = 0.0 +private const val RANGE_MAX = 1.0 + +class MatchResponse( + val requestId: String? = null, + + val sessionId: String? = null, + + val offers: List = emptyList(), +) + +class Offer( + val id: String? = null, + val title: String? = null, + val description: String? = null, + val descriptionLong: String? = null, + val language: String? = null, + val brand: String? = null, + val catalogNumbers: List = emptyList(), + val customIds: Map = emptyMap(), + val keywords: List? = null, + val categories: List = emptyList(), + val availability: String? = null, + val feedId: String? = null, + val groupId: String? = null, + val priceStr: String? = null, + val salePrice: String? = null, + val links: Links? = null, + val images: List = emptyList(), + val metadata: String? = null, + val sku: String? = null, + val score: Float? = null, +) + +class Links( + val main: String? = null, + val mobile: String? = null, +) + +class SkuResponse( + val requestId: String?, + val sessionId: String?, + val offers: List = emptyList(), +) + +class SkuOffer( + val sku: String?, + val score: Float?, +) diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/SkuResponse.kt b/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/SkuResponse.kt deleted file mode 100644 index 8294b79..0000000 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/model/SkuResponse.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023 nyris GmbH - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.nyris.sdk.model - -data class SkuResponse( - val requestId: String?, - val sessionId: String?, - val offers: List = emptyList(), -) - -data class SkuOffer( - val sku: String?, - val score: Float?, -) diff --git a/sdk.core/src/commonTest/kotlin/io/nyris/sdk/internal/NyrisImplTest.kt b/sdk.core/src/commonTest/kotlin/io/nyris/sdk/internal/NyrisImplTest.kt index 9ae7bca..bd2f67b 100644 --- a/sdk.core/src/commonTest/kotlin/io/nyris/sdk/internal/NyrisImplTest.kt +++ b/sdk.core/src/commonTest/kotlin/io/nyris/sdk/internal/NyrisImplTest.kt @@ -21,6 +21,7 @@ import io.mockk.justRun import io.mockk.mockk import io.mockk.mockkObject import io.mockk.verify +import io.nyris.sdk.Nyris import io.nyris.sdk.NyrisConfig import io.nyris.sdk.internal.di.ServiceLocator import kotlin.test.BeforeTest @@ -30,7 +31,7 @@ class NyrisImplTest { private val config = mockk(relaxed = true) private val requestBuilders = mockk(relaxed = true) - private val classToTest: NyrisImpl by lazy { + private val classToTest: Nyris by lazy { NyrisImpl.createInstance(API_KEY, config) } diff --git a/sdk.core/src/iosMain/kotlin/io/nyris/sdk/Nyris.kt b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/Nyris.kt new file mode 100644 index 0000000..14d31fb --- /dev/null +++ b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/Nyris.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2023 nyris GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.nyris.sdk + +import io.nyris.sdk.builder.FeedbackRequestBuilder +import io.nyris.sdk.builder.ImageMatchingRequestBuilder +import io.nyris.sdk.builder.ObjectDetectingRequestBuilder +import io.nyris.sdk.builder.SkuMatchingRequestBuilder +import io.nyris.sdk.internal.createInstanceNyrisImpl + +actual interface Nyris { + actual fun imageMatching(): ImageMatchingRequestBuilder + actual fun objectDetecting(): ObjectDetectingRequestBuilder + actual fun feedback(): FeedbackRequestBuilder + actual fun skuMatching(): SkuMatchingRequestBuilder +} + +actual fun createInstance( + apiKey: String, + config: NyrisConfig, +): Nyris = createInstanceNyrisImpl( + apiKey = apiKey, + config = config +) + +class NyrisService( + apiKey: String, + isDebug: Boolean, +) : Nyris { + private val instance = createInstance( + apiKey = apiKey, + config = NyrisConfig(isDebug = true, platform = NyrisPlatform.IOS) + ) + + override fun imageMatching(): ImageMatchingRequestBuilder { + return instance.imageMatching() + } + + override fun objectDetecting(): ObjectDetectingRequestBuilder { + return instance.objectDetecting() + } + + override fun feedback(): FeedbackRequestBuilder { + return instance.feedback() + } + + override fun skuMatching(): SkuMatchingRequestBuilder { + return instance.skuMatching() + } +} diff --git a/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal.repository.imagematching/ImageMatchingRequestBuilder.kt b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal.repository.imagematching/ImageMatchingRequestBuilder.kt new file mode 100644 index 0000000..05226ac --- /dev/null +++ b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal.repository.imagematching/ImageMatchingRequestBuilder.kt @@ -0,0 +1,23 @@ +package io.nyris.sdk.internal.repository.imagematching + +import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.internal.util.toByteArray +import io.nyris.sdk.model.MatchResponse +import platform.Foundation.NSData + +internal actual class ImageMatchingRequestBuilderImpl actual constructor( + logger: Logger, + imageMatchingRepository: ImageMatchingRepository, +) : CommonImageMatchingRequestBuilderImpl(logger, imageMatchingRepository) { + override suspend fun match(image: DataType): Result { + logger.log("[ImageMatchingRequestBuilderImpl] match") + + // Convert NSData to byte array + return imageMatchingRepository.match( + image = image.toByteArray(), + params = createParams() + ) + } +} + +internal actual typealias DataType = NSData diff --git a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/SkuMatchingRequestBuilder.kt b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/IOSLogger.kt similarity index 77% rename from sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/SkuMatchingRequestBuilder.kt rename to sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/IOSLogger.kt index 431dea9..2ea7311 100644 --- a/sdk.core/src/commonMain/kotlin/io/nyris/sdk/builder/SkuMatchingRequestBuilder.kt +++ b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/IOSLogger.kt @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.nyris.sdk.builder +package io.nyris.sdk.internal.util -import io.nyris.sdk.model.SkuResponse - -interface SkuMatchingRequestBuilder { - suspend fun match(sku: String): Result -} +/** + * Will print logs based on platform + */ +internal actual val Logger.Companion.DEFAULT: Logger + get() = TODO("Not yet implemented") diff --git a/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/NSDataUtilities.kt b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/NSDataUtilities.kt new file mode 100644 index 0000000..af071e2 --- /dev/null +++ b/sdk.core/src/iosMain/kotlin/io/nyris/sdk/internal/util/NSDataUtilities.kt @@ -0,0 +1,17 @@ +package io.nyris.sdk.internal.util + +import kotlinx.cinterop.addressOf +import kotlinx.cinterop.usePinned +import platform.Foundation.NSData +import platform.posix.memcpy + +internal fun NSData.toByteArray(): ByteArray { + val size = length.toInt() + val bytes = ByteArray(size) + if (size > 0) { + bytes.usePinned { pinned -> + memcpy(pinned.addressOf(0), this.bytes, this.length) + } + } + return bytes +} diff --git a/sdk.core/src/jvmMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt b/sdk.core/src/jvmMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt new file mode 100644 index 0000000..74461aa --- /dev/null +++ b/sdk.core/src/jvmMain/kotlin/io/nyris/sdk/internal/repository/imagematching/ImageMatchingRequestBuilderImpl.kt @@ -0,0 +1,20 @@ +package io.nyris.sdk.internal.repository.imagematching + +import io.nyris.sdk.internal.util.Logger +import io.nyris.sdk.model.MatchResponse + +internal actual class ImageMatchingRequestBuilderImpl actual constructor( + logger: Logger, + imageMatchingRepository: ImageMatchingRepository, +) : CommonImageMatchingRequestBuilderImpl(logger, imageMatchingRepository) { + override suspend fun match(image: DataType): Result { + logger.log("[ImageMatchingRequestBuilderImpl] match") + + return imageMatchingRepository.match( + image = image, + params = createParams() + ) + } +} + +internal actual typealias DataType = ByteArray diff --git a/sdk.demos/iOS/.gitignore b/sdk.demos/iOS/.gitignore index 8b13789..ba1ff08 100644 --- a/sdk.demos/iOS/.gitignore +++ b/sdk.demos/iOS/.gitignore @@ -1 +1,90 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ \ No newline at end of file diff --git a/sdk.ui/iOS/.gitignore b/sdk.ui/iOS/.gitignore index 8b13789..ba1ff08 100644 --- a/sdk.ui/iOS/.gitignore +++ b/sdk.ui/iOS/.gitignore @@ -1 +1,90 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ \ No newline at end of file diff --git a/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.pbxproj b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c7d59ad --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.pbxproj @@ -0,0 +1,507 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 1377BDE729C74D9B00B2839E /* NyrisSearcher.docc in Sources */ = {isa = PBXBuildFile; fileRef = 1377BDE629C74D9B00B2839E /* NyrisSearcher.docc */; }; + 1377BDED29C74D9B00B2839E /* NyrisSearcher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1377BDE229C74D9B00B2839E /* NyrisSearcher.framework */; }; + 1377BDF229C74D9B00B2839E /* NyrisSearcherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1377BDF129C74D9B00B2839E /* NyrisSearcherTests.swift */; }; + 1377BDF329C74D9B00B2839E /* NyrisSearcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1377BDE529C74D9B00B2839E /* NyrisSearcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1377BDFE29C74FEC00B2839E /* IntegrationKMP.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1377BDFD29C74FEC00B2839E /* IntegrationKMP.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 1377BDEE29C74D9B00B2839E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1377BDD929C74D9B00B2839E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1377BDE129C74D9B00B2839E; + remoteInfo = NyrisSearcher; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1377BDE229C74D9B00B2839E /* NyrisSearcher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NyrisSearcher.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 1377BDE529C74D9B00B2839E /* NyrisSearcher.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NyrisSearcher.h; sourceTree = ""; }; + 1377BDE629C74D9B00B2839E /* NyrisSearcher.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = NyrisSearcher.docc; sourceTree = ""; }; + 1377BDEC29C74D9B00B2839E /* NyrisSearcherTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NyrisSearcherTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 1377BDF129C74D9B00B2839E /* NyrisSearcherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NyrisSearcherTests.swift; sourceTree = ""; }; + 1377BDFD29C74FEC00B2839E /* IntegrationKMP.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationKMP.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1377BDDF29C74D9B00B2839E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1377BDE929C74D9B00B2839E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1377BDED29C74D9B00B2839E /* NyrisSearcher.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1377BDD829C74D9B00B2839E = { + isa = PBXGroup; + children = ( + 1377BDE429C74D9B00B2839E /* NyrisSearcher */, + 1377BDF029C74D9B00B2839E /* NyrisSearcherTests */, + 1377BDE329C74D9B00B2839E /* Products */, + ); + sourceTree = ""; + }; + 1377BDE329C74D9B00B2839E /* Products */ = { + isa = PBXGroup; + children = ( + 1377BDE229C74D9B00B2839E /* NyrisSearcher.framework */, + 1377BDEC29C74D9B00B2839E /* NyrisSearcherTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 1377BDE429C74D9B00B2839E /* NyrisSearcher */ = { + isa = PBXGroup; + children = ( + 1377BDE529C74D9B00B2839E /* NyrisSearcher.h */, + 1377BDE629C74D9B00B2839E /* NyrisSearcher.docc */, + 1377BDFD29C74FEC00B2839E /* IntegrationKMP.swift */, + ); + path = NyrisSearcher; + sourceTree = ""; + }; + 1377BDF029C74D9B00B2839E /* NyrisSearcherTests */ = { + isa = PBXGroup; + children = ( + 1377BDF129C74D9B00B2839E /* NyrisSearcherTests.swift */, + ); + path = NyrisSearcherTests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 1377BDDD29C74D9B00B2839E /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1377BDF329C74D9B00B2839E /* NyrisSearcher.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1377BDE129C74D9B00B2839E /* NyrisSearcher */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1377BDF629C74D9B00B2839E /* Build configuration list for PBXNativeTarget "NyrisSearcher" */; + buildPhases = ( + 1377BDFC29C74E8C00B2839E /* Run Script KMP integration */, + 1377BDDD29C74D9B00B2839E /* Headers */, + 1377BDDE29C74D9B00B2839E /* Sources */, + 1377BDDF29C74D9B00B2839E /* Frameworks */, + 1377BDE029C74D9B00B2839E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NyrisSearcher; + productName = NyrisSearcher; + productReference = 1377BDE229C74D9B00B2839E /* NyrisSearcher.framework */; + productType = "com.apple.product-type.framework"; + }; + 1377BDEB29C74D9B00B2839E /* NyrisSearcherTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1377BDF929C74D9B00B2839E /* Build configuration list for PBXNativeTarget "NyrisSearcherTests" */; + buildPhases = ( + 1377BDE829C74D9B00B2839E /* Sources */, + 1377BDE929C74D9B00B2839E /* Frameworks */, + 1377BDEA29C74D9B00B2839E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 1377BDEF29C74D9B00B2839E /* PBXTargetDependency */, + ); + name = NyrisSearcherTests; + productName = NyrisSearcherTests; + productReference = 1377BDEC29C74D9B00B2839E /* NyrisSearcherTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1377BDD929C74D9B00B2839E /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + 1377BDE129C74D9B00B2839E = { + CreatedOnToolsVersion = 14.2; + }; + 1377BDEB29C74D9B00B2839E = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = 1377BDDC29C74D9B00B2839E /* Build configuration list for PBXProject "NyrisSearcher" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1377BDD829C74D9B00B2839E; + productRefGroup = 1377BDE329C74D9B00B2839E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1377BDE129C74D9B00B2839E /* NyrisSearcher */, + 1377BDEB29C74D9B00B2839E /* NyrisSearcherTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1377BDE029C74D9B00B2839E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1377BDEA29C74D9B00B2839E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 1377BDFC29C74E8C00B2839E /* Run Script KMP integration */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Run Script KMP integration"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$SRCROOT/../..\"\n# Having this set to true will break iOS integration (with Xcode)\n./gradlew :core:embedAndSignAppleFrameworkForXcode --no-configuration-cache\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1377BDDE29C74D9B00B2839E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1377BDE729C74D9B00B2839E /* NyrisSearcher.docc in Sources */, + 1377BDFE29C74FEC00B2839E /* IntegrationKMP.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1377BDE829C74D9B00B2839E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1377BDF229C74D9B00B2839E /* NyrisSearcherTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 1377BDEF29C74D9B00B2839E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1377BDE129C74D9B00B2839E /* NyrisSearcher */; + targetProxy = 1377BDEE29C74D9B00B2839E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1377BDF429C74D9B00B2839E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../sdk.core/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + nyris, + ); + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 1377BDF529C74D9B00B2839E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../sdk.core/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", + ); + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + OTHER_LDFLAGS = ( + "$(inherited)", + "-framework", + nyris, + ); + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 1377BDF729C74D9B00B2839E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = JKPGZ623Z2; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.nyris.sdk.ui.NyrisSearcher; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1377BDF829C74D9B00B2839E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = JKPGZ623Z2; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.nyris.sdk.ui.NyrisSearcher; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 1377BDFA29C74D9B00B2839E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = JKPGZ623Z2; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.nyris.sdk.ui.NyrisSearcherTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1377BDFB29C74D9B00B2839E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = JKPGZ623Z2; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = io.nyris.sdk.ui.NyrisSearcherTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1377BDDC29C74D9B00B2839E /* Build configuration list for PBXProject "NyrisSearcher" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1377BDF429C74D9B00B2839E /* Debug */, + 1377BDF529C74D9B00B2839E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1377BDF629C74D9B00B2839E /* Build configuration list for PBXNativeTarget "NyrisSearcher" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1377BDF729C74D9B00B2839E /* Debug */, + 1377BDF829C74D9B00B2839E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1377BDF929C74D9B00B2839E /* Build configuration list for PBXNativeTarget "NyrisSearcherTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1377BDFA29C74D9B00B2839E /* Debug */, + 1377BDFB29C74D9B00B2839E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1377BDD929C74D9B00B2839E /* Project object */; +} diff --git a/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/sdk.ui/iOS/NyrisSearcher/IntegrationKMP.swift b/sdk.ui/iOS/NyrisSearcher/IntegrationKMP.swift new file mode 100644 index 0000000..0cadd2c --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher/IntegrationKMP.swift @@ -0,0 +1,46 @@ +/* + * Copyright 2023 nyris GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Foundation +import nyris + + +class IntegrationWithKMP { + + + func greetings() -> Bool { + let feedback = Feedback.Click(requestId: "", sessionId: "", positions: [0, 1, 2], productIds: ["", "", ""]) + + let a = NyrisService(apiKey: "", isDebug: true) + a.feedback().send(feedback: feedback) { result, error in + + guard result != NyrisResult.Fail.shared else { + return + } + + if(result == NyrisResult.Successfull.shared) { + print("1") + } + } + + + + return false + } +} + + + diff --git a/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.docc/NyrisSearcher.md b/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.docc/NyrisSearcher.md new file mode 100755 index 0000000..c7f0b91 --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.docc/NyrisSearcher.md @@ -0,0 +1,13 @@ +# ``NyrisSearcher`` + +Summary + +## Overview + +Text + +## Topics + +### Group + +- ``Symbol`` \ No newline at end of file diff --git a/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.h b/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.h new file mode 100644 index 0000000..8856462 --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcher/NyrisSearcher.h @@ -0,0 +1,18 @@ +// +// NyrisSearcher.h +// NyrisSearcher +// +// Created by MOSTEFAOUIM on 19/03/2023. +// + +#import + +//! Project version number for NyrisSearcher. +FOUNDATION_EXPORT double NyrisSearcherVersionNumber; + +//! Project version string for NyrisSearcher. +FOUNDATION_EXPORT const unsigned char NyrisSearcherVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/sdk.ui/iOS/NyrisSearcherTests/NyrisSearcherTests.swift b/sdk.ui/iOS/NyrisSearcherTests/NyrisSearcherTests.swift new file mode 100644 index 0000000..08a33b0 --- /dev/null +++ b/sdk.ui/iOS/NyrisSearcherTests/NyrisSearcherTests.swift @@ -0,0 +1,45 @@ +/* + * Copyright 2023 nyris GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import XCTest +@testable import NyrisSearcher + +final class NyrisSearcherTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +}