-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Headbright/add-feedback-client
Allow sending feedback with attributes
- Loading branch information
Showing
14 changed files
with
147 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
core-sdk/src/androidMain/kotlin/com/feedbackbulb/libs/core/Platform.android.kt
This file was deleted.
Oops, something went wrong.
10 changes: 6 additions & 4 deletions
10
core-sdk/src/androidUnitTest/kotlin/com/feedbackbulb/libs/core/Test.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package com.feedbackbulb.libs.core | ||
|
||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class AndroidGreetingTest { | ||
|
||
@Test | ||
fun testExample() = runTest { | ||
val result = Greeting().greeting() | ||
kotlin.test.assertTrue(result.isNotEmpty()) | ||
fun testSubmittingFeedback() = runTest { | ||
val client = FeedbackSDKClient("01b7f627-37c0-43f8-8815-2d730f55134b") | ||
client.sendFeedback( | ||
"This is a test feedback from Feedback SDK for Kotlin Multiplatform send from Android", | ||
mapOf("example" to "Kotlin Multiplatform") | ||
) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
core-sdk/src/commonMain/kotlin/com/feedbackbulb/libs/core/FeedbackSDKClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.feedbackbulb.libs.core | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.setBody | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.contentType | ||
import io.ktor.serialization.kotlinx.json.json | ||
|
||
|
||
/** | ||
* This class represents the Feedback SDK client. | ||
* It is used to send feedback to the FeedbackBulb service. | ||
* | ||
* @property appKey The application key which will receive feedback reports. You can obtain it from the Feedbackbulb dashboard. | ||
*/ | ||
class FeedbackSDKClient(val appKey: String) { | ||
// HttpClient used for making HTTP requests. | ||
private val client = HttpClient { | ||
install(ContentNegotiation) { | ||
json() | ||
} | ||
} | ||
|
||
/** | ||
* Sends feedback to the Feedbackbulb service. | ||
* It makes a POST request to the FeedbackBulb API with the feedback content and attributes. | ||
* | ||
* @param content The content of the feedback. | ||
* @param attributes Additional attributes for the feedback. Default is an empty map. | ||
*/ | ||
suspend fun sendFeedback(content: String, attributes: Map<String, String> = emptyMap()) { | ||
// post value to https://feedbackbulb.com/api/values | ||
|
||
val report = FeedbackbulbReport(appKey, content, attributes) | ||
val value = FeedbackbulbValue(report) | ||
|
||
client.post("https://feedbackbulb.com/api/values") { | ||
contentType(ContentType.Application.Json) | ||
setBody(value) | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
core-sdk/src/commonMain/kotlin/com/feedbackbulb/libs/core/FeedbackbulbReport.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.feedbackbulb.libs.core | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FeedbackbulbReport( | ||
val key: String, | ||
val content: String, | ||
val attributes: Map<String, String> | ||
) |
6 changes: 6 additions & 0 deletions
6
core-sdk/src/commonMain/kotlin/com/feedbackbulb/libs/core/FeedbackbulbValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.feedbackbulb.libs.core | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FeedbackbulbValue(val value: FeedbackbulbReport) |
14 changes: 0 additions & 14 deletions
14
core-sdk/src/commonMain/kotlin/com/feedbackbulb/libs/core/Greeting.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
core-sdk/src/commonMain/kotlin/com/feedbackbulb/libs/core/Platform.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
core-sdk/src/iosMain/kotlin/com/feedbackbulb/libs/core/Platform.ios.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters