Added pin config builder. Closes #10
This commit is contained in:
parent
045ad0f276
commit
fc77b73399
7 changed files with 225 additions and 31 deletions
46
README.md
46
README.md
|
@ -1,10 +1,13 @@
|
|||
# [Pinboard](https://pinboard.in) Poster for Kotlin/Java
|
||||
# [Pinboard](https://pinboard.in) Poster for Kotlin, Java and Android
|
||||
|
||||
[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/pinboard-poster/releases/latest) [](https://search.maven.org/search?q=g:%22net.thauvin.erik%22%20AND%20a:%22pinboard-poster%22)
|
||||
[](https://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/pinboard-poster/releases/latest)
|
||||
[](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster)
|
||||
|
||||
[](https://sonarcloud.io/dashboard?id=ethauvin_pinboard-poster) [](https://github.com/ethauvin/pinboard-poster/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master)
|
||||
[](https://sonarcloud.io/dashboard?id=ethauvin_pinboard-poster)
|
||||
[](https://github.com/ethauvin/pinboard-poster/actions/workflows/gradle.yml)
|
||||
[](https://circleci.com/gh/ethauvin/pinboard-poster/tree/master)
|
||||
|
||||
A small Kotlin/Java/Android library for posting to [Pinboard](https://pinboard.in).
|
||||
A small library for posting to [Pinboard](https://pinboard.in).
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -15,19 +18,28 @@ A small Kotlin/Java/Android library for posting to [Pinboard](https://pinboard.i
|
|||
val poster = PinboardPoster("user:TOKEN")
|
||||
|
||||
poster.addPin("https://www.example.com/foo", "This is a test")
|
||||
poster.addPin("https://examples.com", "This is a test", tags = arrayOf("foo", "bar"))
|
||||
poster.deletePin("https:///www.example.com/bar")
|
||||
|
||||
```
|
||||
|
||||
[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/kotlin/src/main/kotlin/net/thauvin/erik/pinboard/samples/KotlinExample.kt)
|
||||
|
||||
### Java
|
||||
|
||||
```java
|
||||
|
||||
final PinboardPoster poster = new PinBboardPoster("user:TOKEN");
|
||||
|
||||
poster.addPin("https://www.example.com/foo", "This is a test");
|
||||
poster.addPin(new AddConfig.Builder()
|
||||
.url("https://example.com")
|
||||
.description("This is a test")
|
||||
.tags("foo", "bar")
|
||||
.build());
|
||||
poster.deletePin("https:///www.example.com/bar");
|
||||
```
|
||||
|
||||
[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/java/src/main/java/net/thauvin/erik/pinboard/samples/JavaExample.java)
|
||||
|
||||
Your API authentication token is available on the [Pinboard settings page](https://pinboard.in/settings/password).
|
||||
|
@ -45,24 +57,29 @@ dependencies {
|
|||
compile 'net.thauvin.erik:pinboard-poster:1.0.4'
|
||||
}
|
||||
```
|
||||
|
||||
[View Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/java/build.gradle)
|
||||
[View Kotlin DSL Example](https://github.com/ethauvin/pinboard-poster/blob/master/samples/kotlin/build.gradle.kts)
|
||||
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://search.maven.org/artifact/net.thauvin.erik/pinboard-poster/1.0.4/jar).
|
||||
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/pinboard-poster).
|
||||
|
||||
## Adding
|
||||
|
||||
The `addPin` function support all of the [Pinboard API parameters](https://pinboard.in/api/#posts_add):
|
||||
|
||||
```kotlin
|
||||
poster.addPin(url = "https://www.example.com",
|
||||
description = "This is the title",
|
||||
extended = "This is the extended description.",
|
||||
tags = "tag1 tag2 tag3",
|
||||
dt = "2010-12-11T19:48:02Z",
|
||||
replace = true,
|
||||
shared = true,
|
||||
toRead = false)
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
poster.addPin(
|
||||
url = "https://www.example.com",
|
||||
description = "This is the title",
|
||||
extended = "This is the extended description.",
|
||||
tags = arrayOf("tag1", "tag2", "tag3"),
|
||||
dt = ZonedDateTime.now(),
|
||||
replace = true,
|
||||
shared = true,
|
||||
toRead = false
|
||||
)
|
||||
```
|
||||
|
||||
`url` and `description` are required.
|
||||
|
@ -84,13 +101,16 @@ It returns `true` if the bookmark was deleted successfully, `false` otherwise.
|
|||
The library used [`java.util.logging`](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html) to log errors. Logging can be configured as follows:
|
||||
|
||||
#### Kotlin
|
||||
|
||||
```kotlin
|
||||
with(poster.logger) {
|
||||
addHandler(ConsoleHandler().apply { level = Level.FINE })
|
||||
level = Level.FINE
|
||||
}
|
||||
```
|
||||
|
||||
#### Java
|
||||
|
||||
```java
|
||||
final ConsoleHandler consoleHandler = new ConsoleHandler();
|
||||
consoleHandler.setLevel(Level.FINE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue