Skip to content

brentwatson/hockeyapp-sdk

Repository files navigation

HockeyApp Java/Kotlin SDK

Implementation of the HockeyApp API endpoints in Kotlin/Java using Retrofit and GSON.

Setup

Builds can be found on jitpack.

Gradle

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

...

dependencies {
    compile 'com.github.brentwatson:hockeyapp-sdk:0.1'
}

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

...

<dependency>
    <groupId>com.github.brentwatson</groupId>
    <artifactId>hockeyapp-sdk</artifactId>
    <version>0.1</version>
</dependency>

Demo

Start by creating an instance of HockeyApp by providing it a HockeyApp token. This object contains methods for each endpoint available from the HockeyApp API.

Eg: new HockeyApp("-HOCKEYAPP-TOKEN).apps(). returns a list of apps.

The return value is a Retrofit Call object that can either be execute()-ed to make the network request on the current thread, or can be enqueue()-d along with a Callback to make the request on a new thread.

Java Example

HockeyApp hockeyApp = new HockeyApp("-HOCKEYAPP-TOKEN-");

// Get list of apps
Call<Apps> call = hockeyApp.apps().list();
Response<Apps> response = call.execute();
Apps apps = response.body();
App app = apps.getApps().get(0);
System.out.println(app);

// Get versions for a app
Call<Versions> versionsCall = hockeyApp.versions().list(app.getPublicIdentifier());
Response<Versions> versionsResponse = versionsCall.execute();
Versions versions = versionsResponse.body();
Version version = versions.getAppVersions().get(0);
System.out.println(versions);

// Get crash groups for a version
Call<CrashGroups> crashGroupsCall = hockeyApp.crashGroups().list(
        app.getPublicIdentifier(), version.getId(),
        new CrashGroupsParams(1, 100, Boolean.FALSE,
                SortBy.LAST_CRASH_AT, SortDirection.DESC)
);
Response<CrashGroups> crashGroupsResponse = crashGroupsCall.execute();
CrashGroups crashGroups = crashGroupsResponse.body();
CrashGroup crashGroup = crashGroups.getCrashGroups().get(0);
System.out.println(crashGroup);

// Get crashes within a crash group
Call<Crashes> crashesCall = hockeyApp.crashes().list(app.getPublicIdentifier(), crashGroup.getId());
Response<Crashes> crashesResponse = crashesCall.execute();
Crashes crashes = crashesResponse.body();
System.out.println(crashes);

Kotlin Example

val hockeyApp = HockeyApp("-HOCKEYAPP-TOKEN-")

val apps = hockeyApp.apps().list()
        .execute()
        .body()
val app = apps.apps[0].also {
    println(it)
}

val versions = hockeyApp.versions().list(app.publicIdentifier)
        .execute()
        .body()
val version = versions.appVersions[0].also {
    println(it)
}

val crashGroups = hockeyApp.crashGroups().list(
        publicIdentifier = app.publicIdentifier,
        versionId = version.id,
        params = CrashGroupsParams(
                page = 1,
                perPage = 100,
                symbolicated = false,
                sort = SortBy.LAST_CRASH_AT,
                order = SortDirection.DESC
        )
).execute().body()
val crashGroup = crashGroups.crashGroups[0].also {
    println(it)
}

hockeyApp.crashes().list(app.publicIdentifier, crashGroup.id)
        .execute()
        .body()
        .let { crashes ->
            println(crashes)
        }

Limitations

Currently only GET endpoints are implemented. PRs welcome.

About

HockeyApp API - Java/kotlin wrapper using Retrofit

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages