Skip to content
David L. Whitehurst edited this page Jun 13, 2016 · 2 revisions

Welcome

Documentation for our TogglAPI connector is found here. We are currently preparing for the v1.0.0 and will address the public when this milestone is reached. Also, we hope to provide v1.0.0 with a software update via Anypoint Studio. The alpha release will be cloneable and can be built and used locally at your own risk.

Usage

Currently, the connector has 2 message processors: (Friendly names)

  • Unprocessed Detail Report Data by Project
  • Tag Unprocessed Time Records by Project

Example Flow

The process of persisting Toggl data by project to our relational database goes like this. An HTTP connector is set up to accept a single URL e.g. http://localhost:8081/process that sends the message (context: message, payload, inbound properties, etc.) to a TogglAPI connector that is configured to use the Unprocessed Detail Report Data by Project message processor method. The user, userpass, workspaceId, and projectId inputs are needed during configuration of the connector. The user is the Toggl user (email) but the userpass needs to be as follows, e.g. [email protected]:joespassword . The userpass is a user and password composite string but it will not work if the colon is omitted.

This first use of the TogglAPI connector pulls the data from the Toggl service. Please note that the data pulled is by project and also all records are untagged, i.e. no tags have been applied to the time records that are not in the database. This data (JSON) is passed to a JSON->Object connector and it's configured with a return Java class of java.lang.Object. This is the basic Java object and doesn't seem to mean much, however Mule knows how to convert the JSON data to a more complex Java Object that implements the Iterable interface. Once the data can be iterated over, the array of data can be inserted into the database using the #[payload.property] accessors in a parameterized insert and using the Mule bulk mode option.

After the JSON->Object connector, the message (Java object payload) is sent to a Database connector. In our case, we are using a local MySQL instance. The parameterized insert statement in the connector configuration is shown here:

INSERT INTO project_time (`id`, `pid`, `description`, `project`, `start`, `end`, `updated`, `duration`) VALUES (#[payload.id], #[payload.pid], #[payload.description], #[payload.project], #[payload.start], #[payload.end], #[payload.updated], #[payload.dur] )

Now that the data has been pulled and persisted to our database, we are not finished. A second TogglAPI connector follows the Database connector and it's configured with the message processor method Tag Unprocessed Time Records by Project. This configuration requires all the same information, user, userpass, workspaceId, and projectId. After the Database operation is complete, this connector process pulls all the same data and updates the records with a tag called processed. This message processor method returns a String to notify the flow caller that the flow was successful in the browser window.

Clone this wiki locally