pixela-java-client-api

pixela-java-client API

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

org.mikeneck.pixela
ArtifactId

ArtifactId

pixela-java-client-api
Last Version

Last Version

0.4
Release Date

Release Date

Type

Type

jar
Description

Description

pixela-java-client-api
pixela-java-client API
Project URL

Project URL

https://github.com/mike-neck/pixela-java-client
Source Code Management

Source Code Management

https://github.com/mike-neck/pixela-java-client

Download pixela-java-client-api

How to add to project

<!-- https://jarcasting.com/artifacts/org.mikeneck.pixela/pixela-java-client-api/ -->
<dependency>
    <groupId>org.mikeneck.pixela</groupId>
    <artifactId>pixela-java-client-api</artifactId>
    <version>0.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.mikeneck.pixela/pixela-java-client-api/
implementation 'org.mikeneck.pixela:pixela-java-client-api:0.4'
// https://jarcasting.com/artifacts/org.mikeneck.pixela/pixela-java-client-api/
implementation ("org.mikeneck.pixela:pixela-java-client-api:0.4")
'org.mikeneck.pixela:pixela-java-client-api:jar:0.4'
<dependency org="org.mikeneck.pixela" name="pixela-java-client-api" rev="0.4">
  <artifact name="pixela-java-client-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.mikeneck.pixela', module='pixela-java-client-api', version='0.4')
)
libraryDependencies += "org.mikeneck.pixela" % "pixela-java-client-api" % "0.4"
[org.mikeneck.pixela/pixela-java-client-api "0.4"]

Dependencies

compile (1)

Group / Artifact Type Version
io.projectreactor : reactor-core jar 3.2.10.RELEASE

test (9)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.9.9
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.9.9
org.eclipse.collections : eclipse-collections jar 9.2.0
org.junit.jupiter : junit-jupiter-api jar 5.4.2
org.junit.jupiter : junit-jupiter-params jar 5.4.2
org.mockito : mockito-core jar 2.28.2
io.projectreactor : reactor-test jar 3.2.10.RELEASE
org.assertj : assertj-core jar 3.12.2
net.javacrumbs.json-unit : json-unit-assertj jar 2.7.0

Project Modules

There are no modules declared in this project.

pixela-java-client

Pixela API async Client for Java.

CircleCI codecov Maven

Requirements

  • Java 11
    • Since this client uses Java 11's java.net.http package, user application is required to use Java11. But optionally this client has extension point for those who not using Java11, you can use this library on Java 8 implementing pixela.client.http.HttpClient interface.

Installation

Maven

<dependency>
  <groupId>org.mikeneck.pixela</groupId>
  <artifactId>pixela-java-client-api</artifactId>
  <version>0.4</version>
</dependency>
<dependency>
  <groupId>org.mikeneck.pixela</groupId>
  <artifactId>pixela-java-client-default-impl</artifactId>
  <version>0.4</version>
</dependency>

Gradle

dependencies {
  implementation "org.mikeneck.pixela:pixela-java-client-api:0.4"
  implementation "org.mikeneck.pixela:pixela-java-client-default-impl:0.4"
}

Usages

import pixela.client.*;
import java.time.ZoneId;

class Main {
    public static void main(final String... args) throws Exception {
        final PixelaClient client = Pixela.withDefaultJavaClient();

        // create a Pixela instance
        final Pixela pixela = client.username("YOUR_NAME").token("YOUR_TOKEN");

        // create a new user
        final Mono<Pixela> newUser =
            client.createUser()
                .withToken("new-token")
                .username("new-user-name")
                .agreeTermsOfService()
                .notMinor()
                .call();

        // create graph
        final Mono<Graph> graph =
            pixela
                .createGraph()
                .id("test-graph")
                .name("graph-name")
                .unit("commit")
                .integer()
                .shibafu()
                .timezone(ZoneId.of("Asia/Tokyo"))
                .call();
        final Mono<Pixel> pixel = graph
                .map(Graph::postPixel)
                .map(postPixel -> postPixel.date(LocalDate.of(2019, 1, 2)))
                .map(pixelQuantity -> pixelQuantity.quantity(5))
                .flatMap(PostPixel::call);

        // increment pixel
        final Mono<Grap> incrementPixel =
            pixel.map(Pixel::graph)
                .map(Graph::incrementPixel)
                .flatMap(IncrementPixel::call);

        // delete graph
        final Mono<Pixela> deleteGraph =
            incrementPixel
                .map(Graph::delete)
                .flatMap(DeleteGraph::call);

        // delete user
        final Mono<Void> deleteUser =
            deleteGraph.map(Pixela::deleteUser)
                .flatMap(DeleteUser::call);

        // subscribe
        final CountDownLatch latch = new CountDownLatch(1);
        final Disposable disposable = deleteUser
                .doOnTerminate(latch::countDown)
                .subscribe();

        latch.await();
        Disposables.composit(disposable, client).dispose();
    }    
}

Versions

Version
0.4
0.3
0.2
0.1