Added message and description to CallResponse

This commit is contained in:
Erik C. Thauvin 2023-01-30 23:22:17 -08:00
parent 191fa0ef44
commit a272599b09
4 changed files with 181 additions and 154 deletions

View file

@ -2,7 +2,7 @@ package com.example
import net.thauvin.erik.bitly.Bitly
import net.thauvin.erik.bitly.Methods
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
import net.thauvin.erik.bitly.Utils.toEndPoint
import org.json.JSONObject
import kotlin.system.exitProcess
@ -10,7 +10,7 @@ fun main() {
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
// See https://dev.bitly.com/v4/#operation/getBitlink
val response = bitly.call("/bitlinks/bit.ly/380ojFd".toEndPoint(), method = Methods.GET)
val response = bitly.call("/bitlinks/bit.ly/380ojFd", method = Methods.GET)
if (response.isSuccessful) {
val json = JSONObject(response.body)
@ -18,7 +18,7 @@ fun main() {
println("URL : " + json.getString("long_url"))
println("By : " + json.getString("created_by"))
} else {
println("Invalid Response: ${response.resultCode}")
println("${response.message}: ${response.description} (${response.statusCode})")
}
exitProcess(0)