Skip to content
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ It will be:
```kotlin
dependencies {
implementation("com.github.User:Repo:Tag") // Example
implementation("com.github.Short-io:android-sdk:v1.0.4") // Use this
implementation("com.github.Short-io:android-sdk:v1.0.5") // Use this
}
```
### 3. Sync the Project
Expand Down Expand Up @@ -104,11 +104,11 @@ thread {
try {
when (val result = ShortioSdk.shortenUrl(apiKey, params)) {
is ShortIOResult.Success -> {
println("Shortened URL: ${result.data.shortURL}")
Log.d("ShortIOResult","Shortened URL: ${result.data.shortURL}")
}
is ShortIOResult.Error -> {
val error = result.data
println("Error ${error.statusCode}: ${error.message} (code: ${error.code})")
Log.d("ShortIOResult","Error ${error.statusCode}: ${error.message} (code: ${error.code})")
}
}
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.github.shortiosdk

val shortenUrl = "https://api.short.io/links/public"
val baseURL = "https://api.short.io/links/public"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.shortiosdk


data class ShortIOParameters(
val originalURL: String,
val cloaking: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.github.shortiosdk

import com.github.shortiosdk.ShortIOResponseModel

public sealed class ShortIOResult {
sealed class ShortIOResult {
data class Success(val data: ShortIOResponseModel) : ShortIOResult()
data class Error(val data: ShortIOErrorModel) : ShortIOResult()
}

public sealed class StringOrInt {
sealed class StringOrInt {
data class Str(val value: String) : StringOrInt()
data class IntVal(val value: Int) : StringOrInt()
}
9 changes: 4 additions & 5 deletions ShortIOSDK/src/main/java/com/github/shortiosdk/ShortIO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import com.google.gson.GsonBuilder
import android.content.Intent
import android.net.Uri
import android.util.Log
import com.github.shortiosdk.Helpers.StringOrIntSerializer
import com.github.shortiosdk.Helpers.HandleClick
Expand All @@ -25,7 +24,7 @@ object ShortioSdk {
val body = jsonBody.toRequestBody(mediaType)

val request = Request.Builder()
.url(shortenUrl)
.url(baseURL)
.post(body)
.addHeader("accept", "application/json")
.addHeader("content-type", "application/json")
Expand Down Expand Up @@ -80,15 +79,15 @@ object ShortioSdk {
var response: String? = null
val thread = Thread {
response = HandleClick(uri.toString())
Log.d("Response", "Response: $response")
Log.d("HandleClickResponse", "Response: $response")
}
thread.start()
thread.join()

if (response == "200") {
Log.d("Success","Response:-${response}")
Log.d("HandleClickResponse","Short SDK click call completed successfully.")
} else {
Log.d("Error","Error:- ${response}")
Log.d("HandleClickError","Error:- ${response}")
}
return UrlComponents(
scheme = scheme,
Expand Down