DribbbleSwift 0.3.1

DribbbleSwift 0.3.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SPMSupports SPM

Maintained by George Kye.



codebeat badge

Usage

Register Dribble application

https://dribbble.com/account/applications/new

Installation

Swift 3

pod 'DribbbleSwift', :git => "https://github.com/gkye/DribbbleSwift.git"

Swift 2

https://github.com/gkye/DribbbleSwift/tree/swift2

Manual

  • Drag files into Xcode project
  • import DribbbleSwift

Endpoints

GET

Authenticated Request

Examples (GET)

REQUIRED FOR ANY GET REQUEST TO WORK (AccessToken must be set before each GET request)

 ConfigDS.setAccessToken("YOUR ACCESS TOKEN")

Buckets 👝

Get a bucket

        BucketDS.getBucket(bucketId: 377694){
            bucket in
            print(bucket.bucket?.name)
            print(bucket.bucket?.user.username)
        }

List shots for a bucket

        BucketDS.getShots(bucketId: 377694){
            shots in
            print(shots.shots?.count)
            print(shots.shots?[0].title)
        }

Project 📄

Get a project

      ProjectDS.getProject(projectId: 3){
            project in
            print(project.project?.name)
            print(project.project?.user.username)
        }

List shots for a project

        ProjectDS.getShots(projectId: 3){
            shots in
            print(shots.shots?.count)
            print(shots.shots?[0].title)
        }

Shots 📷

List Shots

Parameters

 /**
     List shots
     - parameter perPage:           Resources per page, maximum = 100
     -parameter page: Current page of resource. Default = 1
     - parameter list:              Limit the results to a specific type with the following possible values: animated, attachments, debuts, playoffs, rebounds, teams     teams
     - parameter sort:              The sort field with the following possible values: comments, recent, views. Default = .views
     - parameter timeframe:         A period of time to limit the results to with the following possible values: week, month, year, ever
     - parameter date:              Limit the timeframe to a specific date, week, month, or year. Must be in the format of YYYY-MM-DD.
     - parameter completionHandler:   return NSError, JSON and an array of shots.
     */

        ShotsDS.getShots(perPage: 50, list: .animated, sort: .recent){
            shotz in
            print(shotz.shots?.count)
            print(shotz.shots?[0].title)
        }

List attachments for a shot

        ShotsDS.getAttachments(shotID: 2694049){
            atts in
            print(atts.0.json)
            print(atts.attachments?[0].url)
        }

List buckets for a shot

        ShotsDS.getBuckets(shotID: 2694049, perPage: 50){
            bucks in
            print(bucks.buckets?[0].description)
        }

List comments for a shot

        ShotsDS.getComments(shotID: 2694049, perPage: 50){
            cmnts in
            print(cmnts.comments?[0].body)
        }

List likes for a shot

        ShotsDS.getLikes(shotID: 2694049, perPage: 50){
            lks in
            print(lks.likes?[0].created_at)
            print(lks.likes?[0].user.username)
        }

List projects for a shot

        ShotsDS.getProjects(shotID: 2698163, perPage: 50){
            projs in
            print(projs.projects?[0].name)
        }

List rebounds for a shot

        ShotsDS.getRebounds(shotID: 2691323, perPage: 50){
            rbs in
            print(rbs.rebounds?[0].title)
        }

Team 👥

List a team’s members

        TeamDS.getTeamMembers("Dribbble"){
            api in
            print(api.members?[0].username)
        }
        TeamDS.getTeamShots("Dribbble", perPage: 10, page: 1){
            api in
            print(api.shots?[0].title)
        }

Users :bowtie:

Get a single user

        UserDS.getUser("Ramotion"){
            api in
            print(api.user?.bio)
        }

List a user’s buckets

        UserDS.getBuckets("SergeyValiukh"){
            api in
            print(api.buckets?[0].name)
        }

List followers of a user

        UserDS.getFollowers("simplebits", page: 1){
            api in
            print(api.followers?[0].follower.username)
            print(api.followers?[0].follower.name)
        }

List users followed by a user

        UserDS.getFollowing("simplebits", perPage: 20, page: 1){
            api in
            print(api.followees?[0].followee.username)
            print(api.followees?[0].followee.bio)

        }

Check if one user is following another

returns true if following, else false.

        UserDS.checkIfUserFollowingUser("dannpetty", targetUser: "SergeyValiukh"){
            api in
            print(api.isFollowing)
        }

List shot likes for a user

        UserDS.getLikes("simplebits", perPage: 20, page: 1){
            api in
            print(api.likes?[0].shot.title)
            print(api.likes?[0].shot.user.username)
        }

List a user’s projects

        UserDS.getProjects("simplebits", perPage: 10, page: 1){
            api in
            print(api.projects?[0].name)
        }

List shots for a user

        UserDS.getShots("simplebits", perPage: 10, page: 3){
            api in
            print(api.shots?[0].title)
        }

List a user’s teams

        UserDS.getTeams("simplebits"){
            api in
            print(api.teams?[0].name)
            print(api.teams?[0].members_count)
        }

Authenticated Request 🔒

http://developer.dribbble.com/v1/oauth/ for more information about authentication process.

Config

MUST SET CONFIG TOKEN BEFORE ANY AUTHENTICATED REQUEST CAN BE EXECUTED

ConfigDS.setOAuth2Token("OAUTH2 TOKEN RECEIVED")

Users

Get the authenticated user

 UserDS.getAuthUser(){ user in  }

List a user’s buckets

 UserDS.getAuthUserBuckets(perPage: 10, page: 1){bks in print(bks.0.json)   }

List the authenticated user’s followers

 UserDS.getAuthUserFollowers(perPage: 10, page: 1){ flwrs in print(flwrs.followers?.count)}

List who the authenticated user is following

 UserDS.getAuthUserFollowing(perPage: 10, page: 2){ fllwee in print(fllwee.followees?.count)}

List shots for users followed by a user

   UserDS.userFollowingShots(){  shots in print(shots.shots?[0].title) }

Check if AuthUser following a user

 UserDS.checkIfAuthUserFollowingUser("Ramotion"){ status in print(status.isFollowing) }

Follow a user

   UserDS.followUser("wearepanic"){ status in print(status.followed) }

Unfollow a user

  UserDS.unfollowUser("Shopify"){ status in print(status.unfollowed) }

List shot likes for user

  UserDS.getAuthLikes(perPage: 20, page: 1){ likedShots in print(likedShots.likes?[0].shot.title) }

List a user’s projects

  UserDS.getAuthBuckets(){ api in print(api.buckets?[0].name) }

List shots for a user

  UserDS.getAuthProjects(perPage: 10, page: 1){ api in print(api.projects?[0].name) }

List a user’s teams

  UserDS.getAuthShots(perPage: 10, page: 3){ api in print(api.shots?[0].title) }

Shots

Liking and Unliking shot requires the user to be authenticated with the write scope.

Like a shot

 ShotsDS.likeShot(shotId: "2678120"){
            api in
            print(api.statusCode)
            print(api.success)
        }

Unlike a shot

ShotsDS.unlikeShot(shotId: "2678120"){
            api in
            print(api.statusCode)
            print(api.unliked)

        }

Checking if user liked a shot

ShotsDS.checkIfShotLiked(shotId: "2687276"){
            api in
            print(api.statusCode)
            print(api.liked)
        }