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
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;
}
/**
* Identifies the type of the connector.
*/
@Override
public String getConnectorType() {
// Custom implementation type
return "HELLO";
}
}
Then, use your connector implementation when starting the connector.
public class ConnectorLauncher {
/**
* Application entry point
*/
public static void main(final String... args) throws Exception {
Connector.newBuilder()
.useFetchClient()
.withWiseTimeConnector(new HelloConnector())
.build()
.start();
}
}
The connector will launch a web server at port 8080 when calling useWebhook(). The server implements the Posted Time Webhook that WiseTime will call whenever a user posts time to the team.
If you use .useFetchClient()
instead, the connector will start in long polling mode to retrieve time posted to the team from WiseTime.
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.
The latest javadoc for the WiseTime Connector Library can be accessed here.