Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.rocketbase-io:toggl-report-api:toggl-report-api-3.0.0'
}
dependencies {
implementation("com.github.rocketbase-io:toggl-report-api:toggl-report-api-3.0.0")
}
<dependency>
<groupId>com.github.rocketbase-io</groupId>
<artifactId>toggl-report-api</artifactId>
<version>toggl-report-api-3.0.0</version>
</dependency>
libraryDependencies += "com.github.rocketbase-io" % "toggl-report-api" % "toggl-report-api-3.0.0"
:dependencies [[com.github.rocketbase-io/toggl-report-api "toggl-report-api-3.0.0"]]
[!WARNING]
Toggl hat disabled this api-version. You need to port to v9.A new client has been generated -> toggl-api-v9
This project is a Java client for the public Toggl' Reports API. The client is based on a fluent java api that maps the cascade of methods to the Toggl's api endpoints. For example:
mvn compile
Thank's to jitpack it's very easy to use current builds
Step 1. Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Step 2. Add the dependency
<dependency>
<groupId>com.github.rocketbase-io</groupId>
<artifactId>toggl-report-api</artifactId>
<version>toggl-report-api-1.1.0</version>
</dependency>
Very short examples you can also find within the tests goto tests
public static void main(String[] args) {
TogglReportApi togglReportApi = new TogglReportApiBuilder()
.apiToken(API_TOKEN)
.userAgent(USER_AGENT)
.workspaceId(WORKSPACE_ID)
.build();
WeeklyUsersTimeResult result = togglReportApi.weeklyUsersTime()
.since(start)
.get();
System.out.println(result);
}
Fetch full list of all Detailed Results. The FetchAllDetailed cares about paging
List<TimeEntry> resultList = FetchAllDetailed.getAll(togglReportApi.detailed()
.until(start)
.since(end)
.billable(Billable.BOTH));
To use this client in a Spring application consider the following setup:
@Configuration
public class TogglReportApiConfiguration {
@Bean
public TogglReportApi togglReportApi(@Value("${toggl-api.token}") String token,
@Value("${toggl-api.user-agent}") String userAgent,
@Value("${toggl-api.workspace-id}") Long workspaceId) {
return new TogglReportApiBuilder()
.setApiToken(token)
.setUserAgent(userAgent)
.setWorkspaceId(workspaceId)
.build();
}
}
This API depends on these other popular modules (versions of spring-boot bom 2.1.8.RELEASE):
org.springframework
artifact spring-web
version 5.1.9.RELEASE
com.google.guava
artifact guava
version 28.1-jre
com.fasterxml.jackson.core
artifact jackson-databind
version 2.9.9.3
org.apache.httpcomponents
artifact httpclient
version 4.5.9
Since all these artifacts are pretty popular take with care the possible artifact's version conflicts. If you are going to use this software under an Android device consider the httpclient issues.