Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/agilie/dribbble-android-sdk

Dribbble Android SDK is an unofficial wrapper for Dribbble API v1. (Designer, Shot, Comment, User Story, Like, Follow)
https://github.com/agilie/dribbble-android-sdk

dribbble dribbble-android-sdk dribbble-api java oauth2 oauth2-client retrofit2 rxjava2 sdk

Last synced: 2 months ago
JSON representation

Dribbble Android SDK is an unofficial wrapper for Dribbble API v1. (Designer, Shot, Comment, User Story, Like, Follow)

Awesome Lists containing this project

README

        

# Dribbble API SDK

[ ![Download](https://api.bintray.com/packages/agilie/maven/Dribbble/images/download.svg) ](https://bintray.com/agilie/maven/Dribbble/_latestVersion)

Dribbble Android SDK is an unofficial wrapper for [Dribbble API v1](http://developer.dribbble.com/v1/).

## Link to iOS repo

Check out our [Dribbble iOS SDK](https://github.com/agilie/dribbble-ios-sdk)

## Download

- Android Studio

To use Dribbble API SDK as source code, clone the project and import [sdk-library/](sdk-sample) module into your project.

- Maven

Add rependency in your `.pom` file:
````xml

com.agilie
dribbble-sdk-library
1.1
pom

````

- Gradle

Add dependency in your `build.gradle` file:
````gradle
compile 'com.agilie:dribbble-sdk-library:1.1'
````

## Requirements

Android 4.4+ (API level 19+)

## Quick Start

The reason why min SDK level is so high is because Dribbble stopped supporting protocols lower than [TLS1.2](https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.2). As per [provided table](https://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers), it is supported since API level 16 and enabled automatically since API 20+. So, [the handshake](https://www.ssllabs.com/ssltest/analyze.html?d=dribbble.com) with [Dribbble](https://dribbble.com) fails for Android versions lower than 4.4.2 (this site does not even work in devices' browsers).

[Here](sdk-sample/src/main/java/com/agilie/dribbblesdk/sample/activity/DribbbleSdkSampleApplication.java) you can find the workaround how to enable TLS 1.2 support for Android OS lower than 5.0. __don't forget__ to add this in your project:

```java
// http://stackoverflow.com/questions/29249630/android-enable-tlsv1-2-in-okhttp
private void checkTls() {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
try {
ProviderInstaller.installIfNeededAsync(this, new ProviderInstaller.ProviderInstallListener() {
@Override
public void onProviderInstalled() {
// successfully enabled
}

@Override
public void onProviderInstallFailed(int i, Intent intent) {
// no Google Play Services provided?
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
```

Please follow sdk usage [example](sdk-sample/). It demonstrates how to login, logout and call API methods provided by SDK.
__Don't forget__ to fill the credentials to use Dribbble API:
```java
private static final String DRIBBBLE_CLIENT_ID = "";
private static final String DRIBBBLE_CLIENT_SECRET = "";
private static final String DRIBBBLE_CLIENT_ACCESS_TOKEN = "";
private static final String DRIBBBLE_CLIENT_REDIRECT_URL = "";
```
Authorization isn't required, you can use non-authorized access for some methods. In this case, API client uses default access token provided by Dribbble. You can get the app access token, client id and secret keys on your Dribbble app page, check out the next links:

- Register your app on https://dribbble.com/account/applications/new

- Documentation: http://developer.dribbble.com/v1/

## API usage

Use DribbbleAuthHelper.java class for authorization:
- Log into your Dribbble's account using startOauthDialog method:
```java
DribbbleAuthHelper.startOauthDialog(ExampleActivity.this, credentials, new DribbbleAuthHelper.AuthListener() {

@Override
public void onSuccess(final Credential credential) {
String authToken = credential.getAccessToken();

// TODO: Handle success login event
}

@Override
public void onError(Exception ex) {
ex.printStackTrace();

// TODO: Handle error here
}
});
```

- Logout is also easy:
```java
AuthCredentials credentials = AuthCredentials.newBuilder(
DRIBBBLE_CLIENT_ID,
DRIBBBLE_CLIENT_SECRET,
DRIBBBLE_CLIENT_ACCESS_TOKEN,
DRIBBBLE_CLIENT_REDIRECT_URL)
.build();

DribbbleAuthHelper.logout(YourActivity.this, credentials);
```

All Dribbble's API methods are mapped through Retrofit interfaces:
- DribbbleBucketsService.java
```java
@GET("buckets/{id}")
Call getBucket(@Path("id") long bucketId);

@POST("buckets")
Call createBucket(@Body Bucket bucket);

@PUT("buckets/{id}")
Call updateBucket(@Path("id") long bucketId, @Body Bucket bucket);

@DELETE("buckets/{id}")
Call deleteBucket(@Path("id") long bucketId);

@GET("buckets/{id}/shots")
Call> getShotsForBucket(@Path("id") long bucketId);

@PUT("buckets/{id}/shots")
Call addShotToBucket(@Path("id") long bucketId, @Query("shot_id") long shotId);

@DELETE("buckets/{id}/shots")
Call removeShotFromBucket(@Path("id") long bucketId, @Query("shot_id") long shotId);
```

- DribbbleProjectsService.java
```java
@GET("projects/{id}")
Call getProject(@Path("id") long projectId);

@GET("projects/{id}/shots")
Call> getShotsForProject(@Path("id") long projectId);
```

- DribbbleShotsService.java
```java
@GET("shots")
Call> fetchShots(@Query("page") int page);

@GET("shots")
Call> fetchShots(@Query("page") int page, @Query("per_page") int perPage);

@GET("shots")
Call> fetchShots(@Query("page") int page, @Query("per_page") int perPage, @Query("list") String list, @Query("sort") String sort);

@GET("shots")
Call> fetchShots(@Query("page") int page, @Query("per_page") int perPage, @Query("list") String list, @Query("sort") String sort, @Query("date") String date, @Query("timeframe") String timeframe);

@GET("shots")
Call> fetchShots(@Query("page") int page, @Query("list") String list, @Query("sort") String sort, @Query("date") String date, @Query("timeframe") String timeframe);

@GET("shots")
Call> fetchShots(@Query("list") String list);

@GET("shots")
Call> fetchShots(@QueryMap Map parameters);

@GET("shots")
Call> fetchSortedShots(@Query("sort") String sort);

@GET("shots/{id}")
Call getShot(@Path("id") long shotId);

@Multipart
@POST("shots")
Call createShot(@Part("title") String title, @Part MultipartBody.Part image, @Part("description") String description,
@Part("tags") String[] tags, @Part("team_id") int teamId, @Part("rebound_source_id") int reboundSourceId);
@Multipart
@POST("shots")
Call createShot(@Part("title") String title, @Part MultipartBody.Part image, @Part("description") String description,
@Part("tags") String[] tags);
@Multipart
@POST("shots")
Call createShot(@Part("title") String title, @Part MultipartBody.Part image);

@Multipart
@POST("shots")Call createShot(@PartMap Map partMap);

@Multipart
@PUT("shots/{id}")
Call updateShot(@Path("id") long shotId, @Part("title") String title, @Part("description") String description,
@Part("team_id") int teamId, @Part("tags") String[] tags);

@DELETE("shots/{id}")
Call deleteShot(@Path("id") long shotId);

@GET("shots/{id}/attachments")
Call> getShotAttachments(@Path("id") long shotId);

@POST("shots/{shot}/attachments")
Call createShotAttachment(@Path("shot") long shotId, @Part("file") RequestBody file);

@GET("shots/{shot}/attachments/{id}")
Call getShotAttachment(@Path("shot") long shotId, @Path("id") long attachmentId);

@DELETE("shots/{shot}/attachments/{id}")
Call deleteShotAttachment(@Path("shot") long shotId, @Path("id") long attachmentId);

@GET("shots/{id}/buckets")
Call> getShotBuckets(@Path("id") long shotId);

@GET("shots/{shot}/comments")
Call> getShotComments(@Path("shot") long shotId);

@GET("shots/{shot}/comments/{id}/likes")
Call> getCommentLikes(@Path("shot") long shotId, @Path("id") long commentId);

@POST("shots/{shot}/comments")
Call createComment(@Path("shot") long shotId, @Body Comment body);

@GET("shots/{shot}/comments/{id}")
Call getShotComment(@Path("shot") long shotId, @Path("id") long commentId);

@PUT("shots/{shot}/comments/{id}")
Call updateShotComment(@Path("shot") long shotId, @Path("id") long commentId, @Body Comment comment);

@DELETE("shots/{shot}/comments/{id}")
Call deleteShotComment(@Path("shot") long shotId, @Path("id") long commentId);

@GET("shots/{shot}/comments/{id}/like")
Call checkIsLikedShotComment(@Path("shot") long shotId, @Path("id") long commentId);

@POST("shots/{shot}/comments/{id}/like")
Call likeShotComment(@Path("shot") long shotId, @Path("id") long commentId);

@DELETE("shots/{shot}/comments/{id}/like")
Call unlikeShotComment(@Path("shot") long shotId, @Path("id") long commentId);

@GET("shots/{id}/likes")
Call> getShotLikes(@Path("id") long shotId);

@GET("shots/{id}/like")
Call checkShotIsLiked(@Path("id") long shotId);

@POST("shots/{id}/like")
Call likeShot(@Path("id") long shotId);

@DELETE("shots/{id}/like")
Call unlikeShot(@Path("id") long shotId);

@GET("shots/{id}/projects")
Call> getShotProjectsList(@Path("id") long shotId);

@GET("shots/{id}/rebounds")
Call> getShotReboundsList(@Path("id") long shotId);
```

- DribbbleTeamsService.java
```java
@GET("teams/{team}/members")
Call> getTeamMembersList(@Path("team") long teamId);

@GET("teams/{team}/shots")
Call> getTeamShotsList(@Path("team") long teamId);
```

- DribbbleUserService.java
```java
@GET("users/{user}")
Call getSingleUser(@Path("user") long userId);

@GET("user")
Call fetchAuthenticatedUser();

@GET("users/{user}/buckets")
Call> getUsersBuckets(@Path("user") long userId);

@GET("user/buckets")
Call> getAuthenticatedUsersBuckets();

@GET("users/{user}/followers")
Call> getUsersFollowers(@Path("user") long userId, @Query("page") int page, @Query("per_page") int perPage);

@GET("user/followers")
Call> getAuthenticatedUsersFollowers(@Query("page") int page, @Query("per_page") int perPage);

@GET("users/{user}/following")
Call> getFollowingByUser(@Path("user") long userId);

@GET("users/{user}/following")
Call> getFollowingByUser(@Path("user") long userId, @Query("page") int page, @Query("per_page") int perPage);

@GET("user/following")
Call> getFollowingByCurrentUser();

@GET("user/following/shots")
Call> shotsForUserFollowedByUser();

@GET("user/following/{user}")
Call checkUserIsFollowed(@Path("user") long userId);

@GET("users/{user}/following/{target_user}")
Call checkUserIsFollowingAnother(@Path("user") long userId, @Path("target_user") long targetUserId);

@PUT("users/{id}/follow")
Call followUser(@Path("id") long userId);

@DELETE("users/{id}/follow")
Call unfollowUser(@Path("id") long userId);

@GET("users/{user}/likes")
Call> getUsersLikes(@Path("user") long userId);

@GET("users/{user}/likes")
Call> getUsersLikes(@Path("user") long userId, @Query("page") int page, @Query("per_page") int perPage);

@GET("user/likes")
Call> getAuthenticatedUsersLikes();

@GET("users/{user}/projects")
Call> getUsersProjects(@Path("user") long userId);

@GET("user/projects")
Call> getAuthenticatedUsersProjects();

@GET("users/{user}/shots")
Call> getUsersShots(@Path("user") long userId);

@GET("users/{user}/shots")
Call> getUsersShots(@Path("user") long userId, @Query("page") int page, @Query("per_page") int perPage);

@GET("user/shots")
Call> getAuthenticatedUsersShots(@Query("page") int page, @Query("per_page") int perPage);

@GET("users/{user}/teams")
Call> getUsersTeams(@Path("user") long userId);

@GET("user/teams")
Call> getAuthenticatedUsersTeams(@Query("page") int page);
```

## Dependencies

- [Retrofit](https://github.com/square/retrofit)
- [Android OAuth Client](https://github.com/wuman/android-oauth-client)

## Troubleshooting

Problems? Check the [Issues](https://github.com/agilie/dribbble-android-sdk/issues) block
to find the solution or create an new issue that we will fix asap.

## Author

This library is open-sourced by [Agilie Team](https://www.agilie.com?utm_source=github&utm_medium=referral&utm_campaign=Git_Android_Java&utm_term=DribbbleSDK)

## Contributors

- [Alexander Kotsuba](https://github.com/akotsuba)

## Contact us
If you have any questions, suggestions or just need a help with web or mobile development, please email us at


You can ask us anything from basic to complex questions.

We will continue publishing new open-source projects. Stay with us, more updates will follow!

## License

The [MIT](LICENSE.md) License (MIT) Copyright © 2017 [Agilie Team](https://www.agilie.com?utm_source=github&utm_medium=referral&utm_campaign=Git_Android_Java&utm_term=DribbbleSDK)