WiseTime Java Connector Library
Branch: master
Clone or download
alvinllobrera Merge pull request #24 from wisetime-io/add-first-observed-in-hour-in…
…-activity-time

Take into account the `firstObservedInHour` when calculating start time
Latest commit 715f623 Feb 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle
src Small tweak to return stronger type Feb 18, 2019
.gitignore
.openapi-generator-ignore
LICENSE Open sourcing WiseTime Connector Java library Nov 27, 2018
README.md
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

WiseTime Java Connector

Javadocs

WiseTime Java Connector is an open source library that enables you to write a WiseTime connector with a few lines of Java code. It calls the WiseTime Connect API to communicate with WiseTime.

WiseTime is a passive, privacy-first timekeeping system that summarises your tasks while you work. With WiseTime Connect, you can connect your systems to WiseTime, so that you can automatically:

  • Create tags and tag keywords in WiseTime when records are added to your system
  • Receive posted time when users post their time sheets to WiseTime

Getting Started

Set Up the Dependency

The WiseTime Connector Library is available on Maven Central. You can include it in your Java projects like so:

Gradle

compile 'io.wisetime:wisetime-connector:1.1.3'

Maven

<dependency>
  <groupId>io.wisetime</groupId>
  <artifactId>wisetime-connector</artifactId>
  <version>1.1.3</version>
</dependency>

Implement the WiseTimeConnector Interface

To create a connector, simply implement the WiseTimeConnector interface. Here's an example of a minimal implementation.

public class HelloConnector implements WiseTimeConnector {

  private ConnectorModule cm;

  /**
   * Called by the WiseTime Connector library on connector initialization.
   */
  @Override
  public void init(final ConnectorModule connectorModule) {
    cm = connectorModule;
  }

  /**
   * Called by the WiseTime Connector library on a regular schedule.
   */
  @Override
  public void performTagUpdate() {
    // This is where you would query the connected system and send new tags to WiseTime.
    cm.apiClient.tagUpsert(
        new UpsertTagRequest()
            .name("Hello, World!")
            .path("/hello/connector/")
    );
  }

  /**
   * Called by the WiseTime Connector library whenever a user posts time to the team.
   */
  @Override
  public PostResult postTime(final Request request, final TimeGroup userPostedTime) {
    // This is where you would process the userPostedTime and create relevant
    // records in the connected system.
    return PostResult.SUCCESS;
  }
}

Start the Connector

Then, use your connector implementation when starting the server.

public class ConnectorLauncher {

  /**
   * Application entry point
   */
  public static void main(final String... args) throws Exception {
    ServerRunner.createServerBuilder()
        .withWiseTimeConnector(new HelloConnector())
        .withPort(8080)
        .build()
        .startServer();
  }
}

The connector will launch a web server at port 8080. The server implements the Posted Time Webhook that WiseTime will call whenever a user posts time to the team.

Sample Project

Take a look at our open source Jira Connector for an example of a fully implemented, production-ready connector project. The connector is implemented in just 3 classes and comes with great test coverage.

Javadoc

The latest javadoc for the WiseTime Connector Library can be accessed here.