Implemented lastCallResponse property. Closes #2
This commit is contained in:
parent
683cb3aa35
commit
b12931c6ad
10 changed files with 53 additions and 19 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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 |
|
||||
|
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -8,7 +8,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.thauvin.erik</groupId>
|
||||
<artifactId>bitly-shorten</artifactId>
|
||||
<version>0.9.2</version>
|
||||
<version>0.9.3</version>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -30,13 +30,13 @@
|
|||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.7.2</version>
|
||||
<version>4.8.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>4.7.2</version>
|
||||
<version>4.8.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -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<String, Any>(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<String, Any>().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
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue