From 54d6ce6b5271de115bccb7628626369690822210 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 25 Sep 2023 11:27:16 -0700 Subject: [PATCH 1/3] Made config fields private --- .../thauvin/erik/bitly/config/CreateConfig.kt | 16 ++--- .../thauvin/erik/bitly/config/UpdateConfig.kt | 40 ++++++------ .../net/thauvin/erik/bitly/BitlyTest.kt | 63 +++++++------------ 3 files changed, 51 insertions(+), 68 deletions(-) diff --git a/src/main/kotlin/net/thauvin/erik/bitly/config/CreateConfig.kt b/src/main/kotlin/net/thauvin/erik/bitly/config/CreateConfig.kt index e26b17a..3371648 100644 --- a/src/main/kotlin/net/thauvin/erik/bitly/config/CreateConfig.kt +++ b/src/main/kotlin/net/thauvin/erik/bitly/config/CreateConfig.kt @@ -52,17 +52,17 @@ class CreateConfig private constructor( **/ @Suppress("unused", "ArrayInDataClass") data class Builder( - var domain: String = Constants.EMPTY, - var title: String = Constants.EMPTY, - var group_guid: String = Constants.EMPTY, - var tags: Array = emptyArray(), - var deeplinks: Array> = emptyArray(), - var long_url: String = Constants.EMPTY, - var toJson: Boolean = false + private var domain: String = Constants.EMPTY, + private var title: String = Constants.EMPTY, + private var group_guid: String = Constants.EMPTY, + private var tags: Array = emptyArray(), + private var deeplinks: Array> = emptyArray(), + private var long_url: String = Constants.EMPTY, + private var toJson: Boolean = false ) { fun domain(domain: String) = apply { this.domain = domain } fun title(title: String) = apply { this.title = title } - fun group_guid(group_guid: String) = apply { this.group_guid = group_guid } + fun groupGuid(group_guid: String) = apply { this.group_guid = group_guid } fun tags(tags: Array) = apply { this.tags = tags } fun deeplinks(deeplinks: Array>) = apply { this.deeplinks = deeplinks } fun longUrl(long_url: String) = apply { this.long_url = long_url } diff --git a/src/main/kotlin/net/thauvin/erik/bitly/config/UpdateConfig.kt b/src/main/kotlin/net/thauvin/erik/bitly/config/UpdateConfig.kt index 0fda24f..556eb38 100644 --- a/src/main/kotlin/net/thauvin/erik/bitly/config/UpdateConfig.kt +++ b/src/main/kotlin/net/thauvin/erik/bitly/config/UpdateConfig.kt @@ -59,32 +59,32 @@ class UpdateConfig private constructor( **/ @Suppress("unused", "ArrayInDataClass") data class Builder( - var bitlink: String = Constants.EMPTY, - var references: Map = emptyMap(), - var archived: Boolean = false, - var tags: Array = emptyArray(), - var created_at: String = Constants.EMPTY, - var title: String = Constants.EMPTY, - var deeplinks: Array> = emptyArray(), - var created_by: String = Constants.EMPTY, - var long_url: String = Constants.EMPTY, - var client_id: String = Constants.EMPTY, - var custom_bitlinks: Array = emptyArray(), - var link: String = Constants.EMPTY, - var id: String = Constants.EMPTY, - var toJson: Boolean = false + private var bitlink: String = Constants.EMPTY, + private var references: Map = emptyMap(), + private var archived: Boolean = false, + private var tags: Array = emptyArray(), + private var created_at: String = Constants.EMPTY, + private var title: String = Constants.EMPTY, + private var deeplinks: Array> = emptyArray(), + private var created_by: String = Constants.EMPTY, + private var long_url: String = Constants.EMPTY, + private var client_id: String = Constants.EMPTY, + private var custom_bitlinks: Array = emptyArray(), + private var link: String = Constants.EMPTY, + private var id: String = Constants.EMPTY, + private var toJson: Boolean = false ) { fun bitlink(bitlink: String) = apply { this.bitlink = bitlink } fun references(references: Map) = apply { this.references = references } fun archived(archived: Boolean) = apply { this.archived = archived } fun tags(tags: Array) = apply { this.tags = tags } - fun createdAt(created_at: String) = apply { this.created_at = created_at } + fun createdAt(createdAt: String) = apply { this.created_at = createdAt } fun title(title: String) = apply { this.title = title } - fun deeplinks(deeplinks: Array>) = apply { this.deeplinks = deeplinks } - fun createdBy(created_by: String) = apply { this.created_by = created_by } - fun longUrl(long_url: String) = apply { this.long_url = long_url } - fun clientId(client_id: String) = apply { this.client_id = client_id } - fun customBitlinks(custom_bitlinks: Array) = apply { this.custom_bitlinks = custom_bitlinks } + fun deepLinks(deepLinks: Array>) = apply { this.deeplinks = deepLinks } + fun createdBy(createdBy: String) = apply { this.created_by = createdBy } + fun longUrl(longUrl: String) = apply { this.long_url = longUrl } + fun clientId(clientId: String) = apply { this.client_id = clientId } + fun customBitlinks(customBitlinks: Array) = apply { this.custom_bitlinks = customBitlinks } fun link(link: String) = apply { this.link = link } fun id(id: String) = apply { this.id = id } fun toJson(toJson: Boolean) = apply { this.toJson = toJson } diff --git a/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt b/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt index aafde73..3048a94 100644 --- a/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt +++ b/src/test/kotlin/net/thauvin/erik/bitly/BitlyTest.kt @@ -33,15 +33,7 @@ package net.thauvin.erik.bitly import assertk.all import assertk.assertThat -import assertk.assertions.contains -import assertk.assertions.isEmpty -import assertk.assertions.isEqualTo -import assertk.assertions.isFalse -import assertk.assertions.isNotEqualTo -import assertk.assertions.isTrue -import assertk.assertions.matches -import assertk.assertions.prop -import assertk.assertions.startsWith +import assertk.assertions.* import net.thauvin.erik.bitly.Utils.isValidUrl import net.thauvin.erik.bitly.Utils.removeHttp import net.thauvin.erik.bitly.Utils.toEndPoint @@ -51,11 +43,7 @@ import org.json.JSONObject import org.junit.Before import java.io.File import java.util.logging.Level -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith -import kotlin.test.assertFalse -import kotlin.test.assertTrue +import kotlin.test.* class BitlyTest { private val bitly = with(File("local.properties")) { @@ -219,18 +207,15 @@ class BitlyTest { @Test fun `create bitlink with config`() { - var config = CreateConfig.Builder().apply { - long_url = longUrl - }.build() + var config = CreateConfig.Builder().longUrl(longUrl).build() assertThat(bitly.bitlinks().create(config), "create(config)") .matches("https://\\w+.\\w{2}/\\w{7}".toRegex()) - config = CreateConfig.Builder().apply { - domain = "bit.ly" - title = "Erik's Blog" - tags = arrayOf("erik", "thauvin", "blog", "weblog") - long_url = longUrl - }.build() + config = CreateConfig.Builder() + .domain("bit.ly") + .title("Erik's Blog") + .tags(arrayOf("erik", "thauvin", "blog", "weblog")) + .longUrl(longUrl).build() assertEquals( shortUrl, bitly.bitlinks().create(config) @@ -263,36 +248,34 @@ class BitlyTest { bl.update(shortUrl, link = longUrl) assertThat(bl.lastCallResponse).prop(CallResponse::isSuccessful).isTrue() - assertEquals(Constants.FALSE, bl.update("bit.ly/407GjJU", id = "foo")) - + assertEquals(Constants.FALSE, bl.update("bit.ly/407GjJU", id = "foo")) } @Test fun `update bitlink with config`() { val bl = bitly.bitlinks() - var config = UpdateConfig.Builder().apply { - bitlink(shortUrl) - title("Erik's Weblog") - tags(arrayOf("blog", "weblog")) - archived(true) - }.build() + var config = UpdateConfig.Builder() + .bitlink(shortUrl) + .title("Erik's Weblog") + .tags(arrayOf("blog", "weblog")) + .archived(true) + .build() assertEquals(Constants.TRUE, bl.update(config)) - config = UpdateConfig.Builder().apply { - bitlink(shortUrl) - toJson(true) - }.build() + config = UpdateConfig.Builder() + .bitlink(shortUrl) + .toJson(true) + .build() assertThat(bl.update(config), "update(tags)").contains("\"tags\":[]") - config = UpdateConfig.Builder().apply { - bitlink(shortUrl) - link(longUrl) - }.build() + config = UpdateConfig.Builder() + .bitlink(shortUrl) + .link(longUrl) + .build() assertEquals(Constants.TRUE, bl.update(config)) - } @Test From 5f40c8ba2466b5029e413bf99a173e4d931b648a Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 25 Sep 2023 11:33:41 -0700 Subject: [PATCH 2/3] Updated docs --- README.md | 8 +- config/dokka/packages.md | 2 +- .../-create-config/-builder/-builder.html | 48 +- .../-create-config/-builder/build.html | 48 +- .../-create-config/-builder/deeplinks.html | 50 +- .../-create-config/-builder/domain.html | 50 +- .../-create-config/-builder/group_guid.html | 50 +- .../-create-config/-builder/index.html | 159 +-- .../-create-config/-builder/long-url.html | 48 +- .../-create-config/-builder/long_url.html | 48 +- .../-create-config/-builder/tags.html | 50 +- .../-create-config/-builder/title.html | 50 +- .../-create-config/-builder/to-json.html | 50 +- .../-create-config/deep-links.html | 48 +- .../-create-config/domain.html | 48 +- .../-create-config/group_guid.html | 48 +- .../-create-config/index.html | 50 +- .../-create-config/long_url.html | 48 +- .../-create-config/tags.html | 48 +- .../-create-config/title.html | 48 +- .../-create-config/to-json.html | 48 +- .../-update-config/-builder/-builder.html | 48 +- .../-update-config/-builder/archived.html | 48 +- .../-update-config/-builder/bitlink.html | 48 +- .../-update-config/-builder/build.html | 48 +- .../-update-config/-builder/client-id.html | 48 +- .../-update-config/-builder/client_id.html | 48 +- .../-update-config/-builder/created-at.html | 48 +- .../-update-config/-builder/created-by.html | 48 +- .../-update-config/-builder/created_at.html | 48 +- .../-update-config/-builder/created_by.html | 48 +- .../-builder/custom-bitlinks.html | 48 +- .../-builder/custom_bitlinks.html | 48 +- .../-update-config/-builder/deeplinks.html | 48 +- .../-update-config/-builder/id.html | 48 +- .../-update-config/-builder/index.html | 48 +- .../-update-config/-builder/link.html | 48 +- .../-update-config/-builder/long-url.html | 48 +- .../-update-config/-builder/long_url.html | 48 +- .../-update-config/-builder/references.html | 48 +- .../-update-config/-builder/tags.html | 48 +- .../-update-config/-builder/title.html | 48 +- .../-update-config/-builder/to-json.html | 48 +- .../-update-config/archived.html | 48 +- .../-update-config/bitlink.html | 48 +- .../-update-config/client_id.html | 48 +- .../-update-config/created_at.html | 48 +- .../-update-config/created_by.html | 48 +- .../-update-config/custom_bitlinks.html | 48 +- .../-update-config/deep-links.html | 48 +- .../-update-config/id.html | 48 +- .../-update-config/index.html | 48 +- .../-update-config/link.html | 48 +- .../-update-config/long_url.html | 48 +- .../-update-config/references.html | 48 +- .../-update-config/tags.html | 48 +- .../-update-config/title.html | 48 +- .../-update-config/to-json.html | 48 +- .../net.thauvin.erik.bitly.config/index.html | 48 +- .../-bitlinks/-bitlinks.html | 48 +- .../-bitlinks/clicks.html | 48 +- .../-bitlinks/create.html | 48 +- .../-bitlinks/expand.html | 48 +- .../-bitlinks/index.html | 48 +- .../-bitlinks/last-call-response.html | 48 +- .../-bitlinks/shorten.html | 48 +- .../-bitlinks/update.html | 48 +- .../net.thauvin.erik.bitly/-bitly/-bitly.html | 48 +- .../-bitly/access-token.html | 48 +- .../-bitly/bitlinks.html | 48 +- .../net.thauvin.erik.bitly/-bitly/call.html | 48 +- .../net.thauvin.erik.bitly/-bitly/index.html | 48 +- .../-call-response/-call-response.html | 48 +- .../-call-response/body.html | 48 +- .../-call-response/description.html | 48 +- .../-call-response/index.html | 48 +- .../-call-response/is-bad-request.html | 48 +- .../-call-response/is-created.html | 48 +- .../-call-response/is-expectation-failed.html | 48 +- .../-call-response/is-forbidden.html | 48 +- .../-call-response/is-gone.html | 48 +- .../-call-response/is-internal-error.html | 48 +- .../-call-response/is-not-found.html | 48 +- .../-call-response/is-successful.html | 48 +- .../is-temporarily-unavailable.html | 48 +- .../-call-response/is-too-many-requests.html | 48 +- .../is-unprocessable-entity.html | 48 +- .../-call-response/is-upgrade-required.html | 48 +- .../-call-response/message.html | 48 +- .../-call-response/status-code.html | 48 +- .../-constants/-a-p-i_-b-a-s-e_-u-r-l.html | 48 +- .../-constants/-e-m-p-t-y.html | 48 +- .../-constants/-e-m-p-t-y_-j-s-o-n.html | 48 +- .../-e-n-v_-a-c-c-e-s-s_-t-o-k-e-n.html | 48 +- .../-constants/-f-a-l-s-e.html | 48 +- .../-constants/-t-r-u-e.html | 48 +- .../-constants/index.html | 48 +- .../-methods/-d-e-l-e-t-e/index.html | 48 +- .../-methods/-g-e-t/index.html | 48 +- .../-methods/-p-a-t-c-h/index.html | 48 +- .../-methods/-p-o-s-t/index.html | 48 +- .../-methods/entries.html | 80 ++ .../-methods/index.html | 65 +- .../-methods/value-of.html | 48 +- .../-methods/values.html | 48 +- .../-units/-d-a-y/index.html | 48 +- .../-units/-h-o-u-r/index.html | 48 +- .../-units/-m-i-n-u-t-e/index.html | 48 +- .../-units/-m-o-n-t-h/index.html | 48 +- .../-units/-w-e-e-k/index.html | 48 +- .../-units/entries.html | 80 ++ .../net.thauvin.erik.bitly/-units/index.html | 65 +- .../-units/value-of.html | 48 +- .../net.thauvin.erik.bitly/-units/values.html | 48 +- .../net.thauvin.erik.bitly/-utils/call.html | 48 +- .../net.thauvin.erik.bitly/-utils/index.html | 48 +- .../-utils/is-severe-loggable.html | 48 +- .../-utils/is-valid-url.html | 48 +- .../net.thauvin.erik.bitly/-utils/logger.html | 48 +- .../-utils/remove-http.html | 48 +- .../-utils/to-end-point.html | 48 +- .../net.thauvin.erik.bitly/index.html | 48 +- docs/bitly-shorten/package-list | 9 +- docs/images/burger.svg | 5 + docs/images/nav-icons/typealias-kotlin.svg | 9 + docs/images/theme-toggle.svg | 5 +- docs/index.html | 50 +- docs/scripts/main.js | 2 +- docs/scripts/pages.json | 2 +- docs/scripts/platform-content-handler.js | 12 +- docs/styles/font-jb-sans-auto.css | 32 + docs/styles/logo-styles.css | 18 +- docs/styles/main.css | 2 +- docs/styles/style.css | 1034 ++++++++++------- 134 files changed, 4209 insertions(+), 2964 deletions(-) create mode 100644 docs/bitly-shorten/net.thauvin.erik.bitly/-methods/entries.html create mode 100644 docs/bitly-shorten/net.thauvin.erik.bitly/-units/entries.html create mode 100644 docs/images/burger.svg create mode 100644 docs/images/nav-icons/typealias-kotlin.svg create mode 100644 docs/styles/font-jb-sans-auto.css diff --git a/README.md b/README.md index 0d182e8..c4bb8f6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ [![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) -[![Kotlin](https://img.shields.io/badge/kotlin-1.8.22-7f52ff)](https://kotlinlang.org/) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-7f52ff)](https://kotlinlang.org/) [![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/bitly-shorten?label=snapshot&server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/bitly-shorten/) [![Release](https://img.shields.io/github/release/ethauvin/bitly-shorten.svg)](https://github.com/ethauvin/bitly-shorten/releases/latest) -[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/bitly-shorten.svg?label=maven%20central)](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22bitly-shorten%22) +[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/bitly-shorten.svg?color=blue)](https://central.sonatype.com/artifact/net.thauvin.erik/bitly-shorten) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_bitly-shorten&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_bitly-shorten) [![GitHub CI](https://github.com/ethauvin/bitly-shorten/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/bitly-shorten/actions/workflows/gradle.yml) @@ -67,7 +67,7 @@ dependencies { } ``` -Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/bitly-shorten/0.9.3/jar). +Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/bitly-shorten). ## Java @@ -77,7 +77,7 @@ To make it easier to use the library with Java, configuration builders are avail var config = new CreateConfig.Builder() .title("Erik's Weblog") .tags(new String[] { "blog", "weblog"}) - .long_url("https://erik.thauvin.net/blog") + .longUrl("https://erik.thauvin.net/blog") .build(); bitly.bitlinks().create(config); diff --git a/config/dokka/packages.md b/config/dokka/packages.md index ccf2afd..a55184f 100644 --- a/config/dokka/packages.md +++ b/config/dokka/packages.md @@ -2,7 +2,7 @@ [Bitly Shortener for Kotlin, Java & Android](https://github.com/ethauvin/bitly-shorten) -A simple implementation of the [Bitly](https://bit.ly/) link shortening (Bitlinks) [API v4](https://dev.bitly.com/api-reference). +A simple implementation of the [Bitly](https://bit.ly/) link shortening (Bitlinks) [API v4](https://dev.bitly.com/api-reference/). # Package net.thauvin.erik.bitly diff --git a/docs/bitly-shorten/net.thauvin.erik.bitly.config/-create-config/-builder/-builder.html b/docs/bitly-shorten/net.thauvin.erik.bitly.config/-create-config/-builder/-builder.html index 4896895..bb895b3 100644 --- a/docs/bitly-shorten/net.thauvin.erik.bitly.config/-create-config/-builder/-builder.html +++ b/docs/bitly-shorten/net.thauvin.erik.bitly.config/-create-config/-builder/-builder.html @@ -1,10 +1,11 @@ - + Builder + + - + @@ -32,28 +34,33 @@ -