diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/clicks.md b/docs/net.thauvin.erik.bitly/-bitlinks/clicks.md
index 515e559..9d52289 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/clicks.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/clicks.md
@@ -2,7 +2,7 @@
# clicks
-`@JvmOverloads fun clicks(bitlink: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, unit: `[`Units`](../-units/index.md)` = Units.DAY, units: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` = -1, size: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` = 50, unit_reference: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L63)
+`@Synchronized @JvmOverloads fun clicks(bitlink: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, unit: `[`Units`](../-units/index.md)` = Units.DAY, units: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` = -1, size: `[`Int`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` = 50, unit_reference: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L70)
Returns the click counts for a specified Bitlink.
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/create.md b/docs/net.thauvin.erik.bitly/-bitlinks/create.md
index 5bbb8fc..05b33ed 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/create.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/create.md
@@ -2,7 +2,7 @@
# create
-`@JvmOverloads fun create(domain: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, title: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, group_guid: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, tags: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), deeplinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = emptyArray(), long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L99)
+`@Synchronized @JvmOverloads fun create(domain: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, title: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, group_guid: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, tags: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), deeplinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = emptyArray(), long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L107)
Converts a long url to a Bitlink and sets additional parameters.
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/expand.md b/docs/net.thauvin.erik.bitly/-bitlinks/expand.md
index 4888552..3e7f266 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/expand.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/expand.md
@@ -2,7 +2,7 @@
# expand
-`@JvmOverloads fun expand(bitlink_id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L137)
+`@Synchronized @JvmOverloads fun expand(bitlink_id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L146)
Expands a Bitlink.
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/index.md b/docs/net.thauvin.erik.bitly/-bitlinks/index.md
index 30dcc5d..4899f8e 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/index.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/index.md
@@ -14,6 +14,12 @@ See the [Bitly API](https://dev.bitly.com/v4/#tag/Bitlinks) for more information
|---|---|
| [<init>](-init-.md) | Provides functions to create and manage [Bitlinks](https://dev.bitly.com/v4/#tag/Bitlinks).`Bitlinks(accessToken: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` |
+### Properties
+
+| Name | Summary |
+|---|---|
+| [lastCallResponse](last-call-response.md) | The last API call response.`var lastCallResponse: `[`CallResponse`](../-call-response/index.md) |
+
### Functions
| Name | Summary |
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/last-call-response.md b/docs/net.thauvin.erik.bitly/-bitlinks/last-call-response.md
new file mode 100644
index 0000000..09644fb
--- /dev/null
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/last-call-response.md
@@ -0,0 +1,8 @@
+[docs](../../index.md) / [net.thauvin.erik.bitly](../index.md) / [Bitlinks](index.md) / [lastCallResponse](./last-call-response.md)
+
+# lastCallResponse
+
+`var lastCallResponse: `[`CallResponse`](../-call-response/index.md) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L51)
+
+The last API call response.
+
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/shorten.md b/docs/net.thauvin.erik.bitly/-bitlinks/shorten.md
index 1461a6f..9138986 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/shorten.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/shorten.md
@@ -2,7 +2,7 @@
# shorten
-`@JvmOverloads fun shorten(long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, group_guid: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, domain: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L185)
+`@Synchronized @JvmOverloads fun shorten(long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, group_guid: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, domain: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L195)
Shortens a long URL.
diff --git a/docs/net.thauvin.erik.bitly/-bitlinks/update.md b/docs/net.thauvin.erik.bitly/-bitlinks/update.md
index 169f21b..b7bb0c4 100644
--- a/docs/net.thauvin.erik.bitly/-bitlinks/update.md
+++ b/docs/net.thauvin.erik.bitly/-bitlinks/update.md
@@ -2,7 +2,7 @@
# update
-`@JvmOverloads fun update(bitlink: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, references: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyMap(), archived: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false, tags: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), created_at: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, title: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, deeplinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = emptyArray(), created_by: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, client_id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, custom_bitlinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), link: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L222)
+`@Synchronized @JvmOverloads fun update(bitlink: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, references: `[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyMap(), archived: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false, tags: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), created_at: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, title: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, deeplinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`Map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>> = emptyArray(), created_by: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, long_url: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, client_id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, custom_bitlinks: `[`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)`<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`> = emptyArray(), link: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, id: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` = Constants.EMPTY, toJson: `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` = false): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt#L233)
Updates fields in the Bitlink.
diff --git a/pom.xml b/pom.xml
index 5da4ba9..db15524 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
4.0.0
net.thauvin.erik
bitly-shorten
- 0.9.2
+ 0.9.3
@@ -30,13 +30,13 @@
com.squareup.okhttp3
okhttp
- 4.7.2
+ 4.8.0
runtime
com.squareup.okhttp3
logging-interceptor
- 4.7.2
+ 4.8.0
runtime
diff --git a/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt b/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt
index c18097a..7a6298c 100644
--- a/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt
+++ b/src/main/kotlin/net/thauvin/erik/bitly/Bitlinks.kt
@@ -45,6 +45,12 @@ import java.util.logging.Level
* See the [Bitly API](https://dev.bitly.com/v4/#tag/Bitlinks) for more information.
*/
open class Bitlinks(private val accessToken: String) {
+ /**
+ * The last API call response.
+ */
+ var lastCallResponse = CallResponse()
+ private set
+
/**
* Returns the click counts for a specified Bitlink.
*
@@ -59,6 +65,7 @@ open class Bitlinks(private val accessToken: String) {
* @param toJson Returns the full JSON response if `true`
* @return The click counts or JSON response object.
*/
+ @Synchronized
@JvmOverloads
fun clicks(
bitlink: String,
@@ -70,7 +77,7 @@ open class Bitlinks(private val accessToken: String) {
): String {
var clicks = if (toJson) Constants.EMPTY_JSON else Constants.EMPTY
if (bitlink.isNotBlank()) {
- val response = Utils.call(
+ lastCallResponse = Utils.call(
accessToken,
("/bitlinks/${bitlink.removeHttp()}/clicks/summary").toEndPoint(),
hashMapOf(
@@ -81,7 +88,7 @@ open class Bitlinks(private val accessToken: String) {
),
Methods.GET
)
- clicks = parseJsonResponse(response, "total_clicks", clicks, toJson)
+ clicks = parseJsonResponse(lastCallResponse, "total_clicks", clicks, toJson)
}
return clicks
}
@@ -95,6 +102,7 @@ open class Bitlinks(private val accessToken: String) {
* @param toJson Returns the full JSON response if `true`
* @return The shorten URL or JSON response, or on error, an empty string/JSON object.
*/
+ @Synchronized
@JvmOverloads
fun create(
domain: String = Constants.EMPTY,
@@ -107,7 +115,7 @@ open class Bitlinks(private val accessToken: String) {
): String {
var link = if (toJson) Constants.EMPTY_JSON else Constants.EMPTY
if (long_url.isNotBlank()) {
- val response = Utils.call(
+ lastCallResponse = Utils.call(
accessToken,
"/bitlinks".toEndPoint(),
mutableMapOf(Pair("long_url", long_url)).apply {
@@ -119,7 +127,7 @@ open class Bitlinks(private val accessToken: String) {
},
Methods.POST
)
- link = parseJsonResponse(response, "link", link, toJson)
+ link = parseJsonResponse(lastCallResponse, "link", link, toJson)
}
return link
}
@@ -133,17 +141,18 @@ open class Bitlinks(private val accessToken: String) {
* @param toJson Returns the full JSON response if `true`
* @return The long URL or JSON response, or on error, an empty string/JSON object.
*/
+ @Synchronized
@JvmOverloads
fun expand(bitlink_id: String, toJson: Boolean = false): String {
var longUrl = if (toJson) Constants.EMPTY_JSON else Constants.EMPTY
if (bitlink_id.isNotBlank()) {
- val response = Utils.call(
+ lastCallResponse = Utils.call(
accessToken,
"/expand".toEndPoint(),
mapOf(Pair("bitlink_id", bitlink_id.removeHttp())),
Methods.POST
)
- longUrl = parseJsonResponse(response, "long_url", longUrl, toJson)
+ longUrl = parseJsonResponse(lastCallResponse, "long_url", longUrl, toJson)
}
return longUrl
@@ -181,6 +190,7 @@ open class Bitlinks(private val accessToken: String) {
* @param toJson Returns the full JSON response if `true`
* @return The short URL or JSON response, or on error, the [long_url] or an empty JSON object.
*/
+ @Synchronized
@JvmOverloads
fun shorten(
long_url: String,
@@ -201,9 +211,9 @@ open class Bitlinks(private val accessToken: String) {
}
params["long_url"] = long_url
- val response = Utils.call(accessToken, "/shorten".toEndPoint(), params)
+ lastCallResponse = Utils.call(accessToken, "/shorten".toEndPoint(), params)
- bitlink = parseJsonResponse(response, "link", bitlink, toJson)
+ bitlink = parseJsonResponse(lastCallResponse, "link", bitlink, toJson)
}
return bitlink
@@ -218,6 +228,7 @@ open class Bitlinks(private val accessToken: String) {
* @param toJson Returns the full JSON response if `true`
* @return `true` is the update was successful, `false` otherwise, or JSON response.
*/
+ @Synchronized
@JvmOverloads
fun update(
bitlink: String,
@@ -237,7 +248,7 @@ open class Bitlinks(private val accessToken: String) {
): String {
var result = if (toJson) Constants.EMPTY_JSON else Constants.FALSE
if (bitlink.isNotBlank()) {
- val response = Utils.call(
+ lastCallResponse = Utils.call(
accessToken, "/bitlinks/${bitlink.removeHttp()}".toEndPoint(), mutableMapOf().apply {
if (references.isNotEmpty()) put("references", references)
if (archived) put("archived", archived)
@@ -255,9 +266,9 @@ open class Bitlinks(private val accessToken: String) {
Methods.PATCH
)
- if (response.isSuccessful) {
+ if (lastCallResponse.isSuccessful) {
result = if (toJson) {
- response.body
+ lastCallResponse.body
} else {
Constants.TRUE
}
diff --git a/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt b/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt
index e97c4e9..5bdeaa2 100644
--- a/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt
@@ -123,6 +123,15 @@ class BitlyTest {
assertEquals(longUrl, Bitlinks(bitly.accessToken).expand(shortUrl))
}
+ @Test
+ fun `bitlinks lastCallResponse`() {
+ val bl = Bitlinks(bitly.accessToken)
+ bl.shorten(longUrl, domain="bit.ly")
+ assertEquals(true, bl.lastCallResponse.isSuccessful, "is successful")
+ assertEquals(200, bl.lastCallResponse.resultCode, "resultCode == 200")
+ assertTrue(bl.lastCallResponse.body.contains("\"link\":\"$shortUrl\""), "valid body")
+ }
+
@Test
fun `clicks summary`() {
assertNotEquals(Constants.EMPTY, bitly.bitlinks().clicks(shortUrl))