Revert "Added CallResponse and Bitlinks.udpate()."
This reverts commit 05ee938de7fac49026118a53f5af02ff26d82ccd.
This commit is contained in:
parent
87350f0d51
commit
9ba23fd6c3
24 changed files with 34 additions and 184 deletions
|
@ -20,10 +20,7 @@ bitly.bitlinks().expand("http://bit.ly/380ojFd")
|
||||||
bitly.bitlinks().clicks("http://bit.ly/380ojFd")
|
bitly.bitlinks().clicks("http://bit.ly/380ojFd")
|
||||||
|
|
||||||
// Create a bitlink
|
// Create a bitlink
|
||||||
bitly.bitlinks().create(title = "Erik's Weblog", long_url = "http://erik.thauvin.net/blog/")
|
bitly.bitlinks().create(title = "Erik's Weblog", long_url = "http://erik.thauvin.net/blog/")
|
||||||
|
|
||||||
// Update a bitlink
|
|
||||||
bitly.bitlinks().update("http://bit.ly/380ojFd", title="Erik's Weblog", tags = arrayOf("blog", "weblog"))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- View [Kotlin](https://github.com/ethauvin/bitly-shorten/blob/master/examples/src/main/kotlin/com/example/BitlyExample.kt) or [Java](https://github.com/ethauvin/bitly-shorten/blob/master/examples/src/main/java/com/example/BitlySample.java) Examples.
|
- View [Kotlin](https://github.com/ethauvin/bitly-shorten/blob/master/examples/src/main/kotlin/com/example/BitlyExample.kt) or [Java](https://github.com/ethauvin/bitly-shorten/blob/master/examples/src/main/java/com/example/BitlySample.java) Examples.
|
||||||
|
|
|
@ -2,19 +2,11 @@
|
||||||
<SmellBaseline>
|
<SmellBaseline>
|
||||||
<Blacklist></Blacklist>
|
<Blacklist></Blacklist>
|
||||||
<Whitelist>
|
<Whitelist>
|
||||||
<ID>ComplexMethod:Bitlinks.kt$Bitlinks$update</ID>
|
|
||||||
<ID>ComplexMethod:Utils.kt$Utils.Companion$call</ID>
|
<ID>ComplexMethod:Utils.kt$Utils.Companion$call</ID>
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$bitlink_id: String</ID>
|
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$bitlink_id: String</ID>
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$client_id: String = Constants.EMPTY</ID>
|
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_at: String = Constants.EMPTY</ID>
|
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$created_by: String = Constants.EMPTY</ID>
|
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$custom_bitlinks: Array<String> = emptyArray()</ID>
|
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$group_guid: String = Constants.EMPTY</ID>
|
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$group_guid: String = Constants.EMPTY</ID>
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String</ID>
|
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String</ID>
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$long_url: String = Constants.EMPTY</ID>
|
|
||||||
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$unit_reference: String = Constants.EMPTY</ID>
|
<ID>FunctionParameterNaming:Bitlinks.kt$Bitlinks$unit_reference: String = Constants.EMPTY</ID>
|
||||||
<ID>MagicNumber:CallResponse.kt$CallResponse$200</ID>
|
|
||||||
<ID>MagicNumber:CallResponse.kt$CallResponse$299</ID>
|
|
||||||
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$call</ID>
|
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$call</ID>
|
||||||
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$parseBody</ID>
|
<ID>NestedBlockDepth:Utils.kt$Utils.Companion$parseBody</ID>
|
||||||
</Whitelist>
|
</Whitelist>
|
||||||
|
|
|
@ -20,13 +20,6 @@ Provides functions to create and manage [Bitlinks](https://dev.bitly.com/v4/#tag
|
||||||
Provides access to the [Bitly API v4](https://dev.bitly.com/v4).
|
Provides access to the [Bitly API v4](https://dev.bitly.com/v4).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
||||||
##### [net.thauvin.erik.bitly.CallResponse](../net.thauvin.erik.bitly/-call-response/index.md)
|
|
||||||
|
|
||||||
Provides a data class to hold the JSON response.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
||||||
##### [net.thauvin.erik.bitly.Constants](../net.thauvin.erik.bitly/-constants/index.md)
|
##### [net.thauvin.erik.bitly.Constants](../net.thauvin.erik.bitly/-constants/index.md)
|
||||||
|
|
|
@ -10,11 +10,11 @@ See the [Bitly API](https://dev.bitly.com/v4/#operation/getClicksSummaryForBitli
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
`bitlink` - A Bitlink made of the domain and hash.
|
`bitlink` - The bitlink.
|
||||||
|
|
||||||
`unit` - A [unit of time](../-units/index.md).
|
`unit` - A unit of time.
|
||||||
|
|
||||||
`units` - An integer representing the time units to query data for. Pass -1 to return all units available.
|
`units` - An integer representing the time units to query data for. pass -1 to return all units available.
|
||||||
|
|
||||||
`size` - The quantity of items to be be returned.
|
`size` - The quantity of items to be be returned.
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,3 @@ See the [Bitly API](https://dev.bitly.com/v4/#tag/Bitlinks) for more information
|
||||||
| [create](create.md) | Converts a long url to a Bitlink and sets additional parameters.`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) |
|
| [create](create.md) | Converts a long url to a Bitlink and sets additional parameters.`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) |
|
||||||
| [expand](expand.md) | Expands a Bitlink.`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) |
|
| [expand](expand.md) | Expands a Bitlink.`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) |
|
||||||
| [shorten](shorten.md) | Shortens a long URL.`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) |
|
| [shorten](shorten.md) | Shortens a long URL.`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) |
|
||||||
| [update](update.md) | Updates fields in the Bitlink.`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) |
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# call
|
# call
|
||||||
|
|
||||||
`@JvmOverloads fun call(endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`CallResponse`](../-call-response/index.md) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Bitly.kt#L117)
|
`@JvmOverloads fun call(endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`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/Bitly.kt#L117)
|
||||||
|
|
||||||
Executes an API call.
|
Executes an API call.
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,4 @@ Provides access to the [Bitly API v4](https://dev.bitly.com/v4).
|
||||||
| Name | Summary |
|
| Name | Summary |
|
||||||
|---|---|
|
|---|---|
|
||||||
| [bitlinks](bitlinks.md) | Returns a new [Bitlinks](../-bitlinks/index.md) instance.`fun bitlinks(): `[`Bitlinks`](../-bitlinks/index.md) |
|
| [bitlinks](bitlinks.md) | Returns a new [Bitlinks](../-bitlinks/index.md) instance.`fun bitlinks(): `[`Bitlinks`](../-bitlinks/index.md) |
|
||||||
| [call](call.md) | Executes an API call.`fun call(endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`CallResponse`](../-call-response/index.md) |
|
| [call](call.md) | Executes an API call.`fun call(endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# API_BASE_URL
|
# API_BASE_URL
|
||||||
|
|
||||||
`const val API_BASE_URL: `[`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/Constants.kt#L43)
|
`const val API_BASE_URL: `[`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/Constants.kt#L42)
|
||||||
|
|
||||||
The Bitly API base URL.
|
The Bitly API base URL.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# EMPTY
|
# EMPTY
|
||||||
|
|
||||||
`const val EMPTY: `[`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/Constants.kt#L53)
|
`const val EMPTY: `[`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/Constants.kt#L51)
|
||||||
|
|
||||||
Empty String.
|
Empty String.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# EMPTY_JSON
|
# EMPTY_JSON
|
||||||
|
|
||||||
`const val EMPTY_JSON: `[`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/Constants.kt#L56)
|
`const val EMPTY_JSON: `[`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/Constants.kt#L54)
|
||||||
|
|
||||||
Empty JSON Object.
|
Empty JSON Object.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# ENV_ACCESS_TOKEN
|
# ENV_ACCESS_TOKEN
|
||||||
|
|
||||||
`const val ENV_ACCESS_TOKEN: `[`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/Constants.kt#L50)
|
`const val ENV_ACCESS_TOKEN: `[`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/Constants.kt#L48)
|
||||||
|
|
||||||
The API access token environment variable.
|
The API access token environment variable.
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,3 @@ Provides the constants for this package.
|
||||||
| [EMPTY](-e-m-p-t-y.md) | Empty String.`const val EMPTY: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
| [EMPTY](-e-m-p-t-y.md) | Empty String.`const val EMPTY: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
| [EMPTY_JSON](-e-m-p-t-y_-j-s-o-n.md) | Empty JSON Object.`const val EMPTY_JSON: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
| [EMPTY_JSON](-e-m-p-t-y_-j-s-o-n.md) | Empty JSON Object.`const val EMPTY_JSON: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
| [ENV_ACCESS_TOKEN](-e-n-v_-a-c-c-e-s-s_-t-o-k-e-n.md) | The API access token environment variable.`const val ENV_ACCESS_TOKEN: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
| [ENV_ACCESS_TOKEN](-e-n-v_-a-c-c-e-s-s_-t-o-k-e-n.md) | The API access token environment variable.`const val ENV_ACCESS_TOKEN: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
| [FALSE](-f-a-l-s-e.md) | False`const val FALSE: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
|
||||||
| [TRUE](-t-r-u-e.md) | True`const val TRUE: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# call
|
# call
|
||||||
|
|
||||||
`@JvmOverloads fun call(accessToken: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`CallResponse`](../-call-response/index.md) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Utils.kt#L65)
|
`@JvmOverloads fun call(accessToken: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`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/Utils.kt#L65)
|
||||||
|
|
||||||
Executes an API call.
|
Executes an API call.
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ Provides useful generic functions.
|
||||||
|
|
||||||
| Name | Summary |
|
| Name | Summary |
|
||||||
|---|---|
|
|---|---|
|
||||||
| [call](call.md) | Executes an API call.`fun call(accessToken: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`CallResponse`](../-call-response/index.md) |
|
| [call](call.md) | Executes an API call.`fun call(accessToken: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, endPoint: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, params: `[`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)`, `[`Any`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)`> = emptyMap(), method: `[`Methods`](../-methods/index.md)` = Methods.POST): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
| [isValidUrl](is-valid-url.md) | Validates a URL.`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.isValidUrl(): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) |
|
| [isValidUrl](is-valid-url.md) | Validates a URL.`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.isValidUrl(): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) |
|
||||||
| [removeHttp](remove-http.md) | Removes http(s) scheme from string.`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.removeHttp(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
| [removeHttp](remove-http.md) | Removes http(s) scheme from string.`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.removeHttp(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
| [toEndPoint](to-end-point.md) | Builds the full API endpoint URL using the [Constants.API_BASE_URL](../-constants/-a-p-i_-b-a-s-e_-u-r-l.md).`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.toEndPoint(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
| [toEndPoint](to-end-point.md) | Builds the full API endpoint URL using the [Constants.API_BASE_URL](../-constants/-a-p-i_-b-a-s-e_-u-r-l.md).`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.toEndPoint(): `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# isValidUrl
|
# isValidUrl
|
||||||
|
|
||||||
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.isValidUrl(): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Utils.kt#L149)
|
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.isValidUrl(): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) [(source)](https://github.com/ethauvin/bitly-shorten/tree/master/src/main/kotlin/net/thauvin/erik/bitly/Utils.kt#L148)
|
||||||
|
|
||||||
Validates a URL.
|
Validates a URL.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# removeHttp
|
# removeHttp
|
||||||
|
|
||||||
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.removeHttp(): `[`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/Utils.kt#L164)
|
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.removeHttp(): `[`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/Utils.kt#L163)
|
||||||
|
|
||||||
Removes http(s) scheme from string.
|
Removes http(s) scheme from string.
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# toEndPoint
|
# toEndPoint
|
||||||
|
|
||||||
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.toEndPoint(): `[`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/Utils.kt#L171)
|
`fun `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`.toEndPoint(): `[`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/Utils.kt#L170)
|
||||||
|
|
||||||
Builds the full API endpoint URL using the [Constants.API_BASE_URL](../-constants/-a-p-i_-b-a-s-e_-u-r-l.md).
|
Builds the full API endpoint URL using the [Constants.API_BASE_URL](../-constants/-a-p-i_-b-a-s-e_-u-r-l.md).
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ Provides the classes necessary to access the [Bitly API v4](https://dev.bitly.co
|
||||||
|---|---|
|
|---|---|
|
||||||
| [Bitlinks](-bitlinks/index.md) | Provides functions to create and manage [Bitlinks](https://dev.bitly.com/v4/#tag/Bitlinks).`open class Bitlinks` |
|
| [Bitlinks](-bitlinks/index.md) | Provides functions to create and manage [Bitlinks](https://dev.bitly.com/v4/#tag/Bitlinks).`open class Bitlinks` |
|
||||||
| [Bitly](-bitly/index.md) | Provides access to the [Bitly API v4](https://dev.bitly.com/v4).`open class Bitly` |
|
| [Bitly](-bitly/index.md) | Provides access to the [Bitly API v4](https://dev.bitly.com/v4).`open class Bitly` |
|
||||||
| [CallResponse](-call-response/index.md) | Provides a data class to hold the JSON response.`data class CallResponse` |
|
|
||||||
| [Constants](-constants/index.md) | Provides the constants for this package.`open class Constants` |
|
| [Constants](-constants/index.md) | Provides the constants for this package.`open class Constants` |
|
||||||
| [Methods](-methods/index.md) | Provides HTTP methods definitions.`enum class Methods` |
|
| [Methods](-methods/index.md) | Provides HTTP methods definitions.`enum class Methods` |
|
||||||
| [Units](-units/index.md) | Provides units of time definitions.`enum class Units` |
|
| [Units](-units/index.md) | Provides units of time definitions.`enum class Units` |
|
||||||
|
|
|
@ -50,9 +50,9 @@ open class Bitlinks(private val accessToken: String) {
|
||||||
*
|
*
|
||||||
* See the [Bitly API](https://dev.bitly.com/v4/#operation/getClicksSummaryForBitlink) for more information.
|
* See the [Bitly API](https://dev.bitly.com/v4/#operation/getClicksSummaryForBitlink) for more information.
|
||||||
*
|
*
|
||||||
* @param bitlink A Bitlink made of the domain and hash.
|
* @param bitlink The bitlink.
|
||||||
* @param unit A [unit of time][Units].
|
* @param unit A unit of time.
|
||||||
* @param units An integer representing the time units to query data for. Pass -1 to return all units available.
|
* @param units An integer representing the time units to query data for. pass -1 to return all units available.
|
||||||
* @param size The quantity of items to be be returned.
|
* @param size The quantity of items to be be returned.
|
||||||
* @param unit_reference An ISO-8601 timestamp, indicating the most recent time for which to pull metrics.
|
* @param unit_reference An ISO-8601 timestamp, indicating the most recent time for which to pull metrics.
|
||||||
* Will default to current time.
|
* Will default to current time.
|
||||||
|
@ -72,7 +72,7 @@ open class Bitlinks(private val accessToken: String) {
|
||||||
if (bitlink.isNotBlank()) {
|
if (bitlink.isNotBlank()) {
|
||||||
val response = Utils.call(
|
val response = Utils.call(
|
||||||
accessToken,
|
accessToken,
|
||||||
("/bitlinks/${bitlink.removeHttp()}/clicks/summary").toEndPoint(),
|
("/bitlinks/" + bitlink.removeHttp() + "/clicks/summary").toEndPoint(),
|
||||||
hashMapOf(
|
hashMapOf(
|
||||||
Pair("unit", unit.toString().toLowerCase()),
|
Pair("unit", unit.toString().toLowerCase()),
|
||||||
Pair("units", units.toString()),
|
Pair("units", units.toString()),
|
||||||
|
@ -156,14 +156,14 @@ open class Bitlinks(private val accessToken: String) {
|
||||||
default
|
default
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseJsonResponse(response: CallResponse, key: String, default: String, toJson: Boolean): String {
|
private fun parseJsonResponse(response: String, key: String, default: String, toJson: Boolean): String {
|
||||||
var parsed = default
|
var parsed = default
|
||||||
if (response.body.isNotEmpty()) {
|
if (response.isNotEmpty()) {
|
||||||
if (toJson) {
|
if (toJson) {
|
||||||
parsed = response.body
|
parsed = response
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
parsed = JSONObject(response.body).getString(key, default)
|
parsed = JSONObject(response).getString(key, default)
|
||||||
} catch (jse: JSONException) {
|
} catch (jse: JSONException) {
|
||||||
Utils.logger.log(Level.SEVERE, "An error occurred parsing the response from Bitly.", jse)
|
Utils.logger.log(Level.SEVERE, "An error occurred parsing the response from Bitly.", jse)
|
||||||
}
|
}
|
||||||
|
@ -208,61 +208,4 @@ open class Bitlinks(private val accessToken: String) {
|
||||||
|
|
||||||
return bitlink
|
return bitlink
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates fields in the Bitlink.
|
|
||||||
*
|
|
||||||
* See the [Bit.ly API](https://dev.bitly.com/v4/#operation/updateBitlink) for more information.
|
|
||||||
*
|
|
||||||
* @oaran bitlink A Bitlink made of the domain and hash.
|
|
||||||
* @param toJson Returns the full JSON response if `true`
|
|
||||||
* @return `true` is the update was successful, `false` otherwise, or JSON response.
|
|
||||||
*/
|
|
||||||
@JvmOverloads
|
|
||||||
fun update(
|
|
||||||
bitlink: String,
|
|
||||||
references: Map<String, String> = emptyMap(),
|
|
||||||
archived: Boolean = false,
|
|
||||||
tags: Array<String> = emptyArray(),
|
|
||||||
created_at: String = Constants.EMPTY,
|
|
||||||
title: String = Constants.EMPTY,
|
|
||||||
deeplinks: Array<Map<String, String>> = emptyArray(),
|
|
||||||
created_by: String = Constants.EMPTY,
|
|
||||||
long_url: String = Constants.EMPTY,
|
|
||||||
client_id: String = Constants.EMPTY,
|
|
||||||
custom_bitlinks: Array<String> = emptyArray(),
|
|
||||||
link: String = Constants.EMPTY,
|
|
||||||
id: String = Constants.EMPTY,
|
|
||||||
toJson: Boolean = false
|
|
||||||
): String {
|
|
||||||
var result = if (toJson) Constants.EMPTY_JSON else Constants.FALSE
|
|
||||||
if (bitlink.isNotBlank()) {
|
|
||||||
val response = Utils.call(
|
|
||||||
accessToken, "/bitlinks/${bitlink.removeHttp()}".toEndPoint(), mutableMapOf<String, Any>().apply {
|
|
||||||
if (references.isNotEmpty()) put("references", references)
|
|
||||||
if (archived) put("archived", archived)
|
|
||||||
if (tags.isNotEmpty()) put("tags", tags)
|
|
||||||
if (created_at.isNotBlank()) put("created_at", created_at)
|
|
||||||
if (title.isNotBlank()) put("title", title)
|
|
||||||
if (deeplinks.isNotEmpty()) put("deeplinks", deeplinks)
|
|
||||||
if (created_by.isNotBlank()) put("created_by", created_by)
|
|
||||||
if (long_url.isNotBlank()) put("long_url", long_url)
|
|
||||||
if (client_id.isNotBlank()) put("client_id", client_id)
|
|
||||||
if (custom_bitlinks.isNotEmpty()) put("custom_bitlinks", custom_bitlinks)
|
|
||||||
if (link.isNotBlank()) put("link", link)
|
|
||||||
if (id.isNotBlank()) put("id", id)
|
|
||||||
},
|
|
||||||
Methods.PATCH
|
|
||||||
)
|
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
|
||||||
result = if (toJson) {
|
|
||||||
response.body
|
|
||||||
} else {
|
|
||||||
Constants.TRUE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ open class Bitly() {
|
||||||
* @return The response (JSON) from the API.
|
* @return The response (JSON) from the API.
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun call(endPoint: String, params: Map<String, Any> = emptyMap(), method: Methods = Methods.POST): CallResponse {
|
fun call(endPoint: String, params: Map<String, Any> = emptyMap(), method: Methods = Methods.POST): String {
|
||||||
return Utils.call(accessToken, endPoint, params, method)
|
return Utils.call(accessToken, endPoint, params, method)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Response.kt
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020, Erik C. Thauvin (erik@thauvin.net)
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* Neither the name of this project nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.thauvin.erik.bitly
|
|
||||||
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides a data class to hold the JSON response.
|
|
||||||
*/
|
|
||||||
data class CallResponse(var body: String = Constants.EMPTY_JSON, var resultCode: Int = -1) {
|
|
||||||
val isSuccessful: Boolean
|
|
||||||
get() = resultCode in 200..299
|
|
||||||
|
|
||||||
fun toJson(): JSONObject {
|
|
||||||
return JSONObject(body)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,15 +35,13 @@ package net.thauvin.erik.bitly
|
||||||
/** Provides the constants for this package. */
|
/** Provides the constants for this package. */
|
||||||
open class Constants private constructor() {
|
open class Constants private constructor() {
|
||||||
companion object Constants {
|
companion object Constants {
|
||||||
/**
|
/** The Bitly API base URL.
|
||||||
* The Bitly API base URL.
|
|
||||||
*
|
*
|
||||||
* @value `https://api-ssl.bitly.com/v4`
|
* @value `https://api-ssl.bitly.com/v4`
|
||||||
*/
|
*/
|
||||||
const val API_BASE_URL = "https://api-ssl.bitly.com/v4"
|
const val API_BASE_URL = "https://api-ssl.bitly.com/v4"
|
||||||
|
|
||||||
/**
|
/** The API access token environment variable.
|
||||||
* The API access token environment variable.
|
|
||||||
*
|
*
|
||||||
* @value `BITLY_ACCESS_TOKEN`
|
* @value `BITLY_ACCESS_TOKEN`
|
||||||
*/
|
*/
|
||||||
|
@ -54,19 +52,5 @@ open class Constants private constructor() {
|
||||||
|
|
||||||
/** Empty JSON Object. */
|
/** Empty JSON Object. */
|
||||||
const val EMPTY_JSON = "{}"
|
const val EMPTY_JSON = "{}"
|
||||||
|
|
||||||
/**
|
|
||||||
* False
|
|
||||||
*
|
|
||||||
* @value `false`
|
|
||||||
*/
|
|
||||||
const val FALSE = false.toString()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* True
|
|
||||||
*
|
|
||||||
* @value `true`
|
|
||||||
*/
|
|
||||||
const val TRUE = true.toString()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ open class Utils private constructor() {
|
||||||
endPoint: String,
|
endPoint: String,
|
||||||
params: Map<String, Any> = emptyMap(),
|
params: Map<String, Any> = emptyMap(),
|
||||||
method: Methods = Methods.POST
|
method: Methods = Methods.POST
|
||||||
): CallResponse {
|
): String {
|
||||||
val response = CallResponse()
|
var response = Constants.EMPTY
|
||||||
if (validateCall(accessToken, endPoint)) {
|
if (validateCall(accessToken, endPoint)) {
|
||||||
val apiUrl = endPoint.toHttpUrlOrNull()
|
val apiUrl = endPoint.toHttpUrlOrNull()
|
||||||
if (apiUrl != null) {
|
if (apiUrl != null) {
|
||||||
|
@ -99,8 +99,7 @@ open class Utils private constructor() {
|
||||||
}.addHeader("Authorization", "Bearer $accessToken")
|
}.addHeader("Authorization", "Bearer $accessToken")
|
||||||
|
|
||||||
val result = createHttpClient().newCall(builder.build()).execute()
|
val result = createHttpClient().newCall(builder.build()).execute()
|
||||||
response.body = parseBody(endPoint, result)
|
response = parseBody(endPoint, result)
|
||||||
response.resultCode = result.code
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -34,6 +34,7 @@ package net.thauvin.erik.bitly
|
||||||
|
|
||||||
import net.thauvin.erik.bitly.Utils.Companion.removeHttp
|
import net.thauvin.erik.bitly.Utils.Companion.removeHttp
|
||||||
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
|
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
|
||||||
|
import org.json.JSONObject
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
@ -96,16 +97,16 @@ class BitlyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `get user`() {
|
fun `get user`() {
|
||||||
assertTrue(bitly.call("/user".toEndPoint(), method = Methods.GET).isSuccessful)
|
assertTrue(bitly.call("/user".toEndPoint(), method = Methods.GET).contains("\"login\":"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `created by`() {
|
fun `created by`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"ethauvin",
|
"ethauvin",
|
||||||
bitly.call("/bitlinks/${shortUrl.removeHttp()}".toEndPoint(), method = Methods.GET)
|
JSONObject(
|
||||||
.toJson()
|
bitly.call("/bitlinks/${shortUrl.removeHttp()}".toEndPoint(), method = Methods.GET)
|
||||||
.getString("created_by")
|
).getString("created_by")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +138,4 @@ class BitlyTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `update bitlink`() {
|
|
||||||
assertEquals(
|
|
||||||
Constants.TRUE,
|
|
||||||
bitly.bitlinks().update(shortUrl, title = "Erik's Weblog", tags = arrayOf("blog", "weblog"))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue