Latest 0.3.1
Homepage https://github.com/gkye/DribbbleSwift
License MIT
Platforms ios 8.0
Authors

codebeat badge
Version
License
Platform

Usage

Register Dribble application

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

Installation

Cocoapods

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 :pouch:

Get a bucket

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

List shots for a bucket

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

Project :page_facing_up:

Get a project

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

List shots for a project

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

Shots :camera:

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){
      apiData, shots in
      print(shots?.count)
      print(shots?[0].title)
    }

List attachments for a shot

    ShotsDS.getAttachments(shotID: 2694049){
      apiData, atts in
      print(atts?[0].url)
      print(atts?[0].thumbnail_url)
    }

List buckets for a shot

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

List comments for a shot

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

List likes for a shot

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

List projects for a shot

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

List rebounds for a shot

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

Team :busts_in_silhouette:

List a team’s members

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

Users :bowtie:

Get a single user

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

List a user’s buckets

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

List followers of a user

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

List users followed by a user

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

        }

Check if one user is following another

returns true if following, else false.

    UserDS.checkIfUserFollowingUser("dannpetty", targetUser: "SergeyValiukh"){
      apiData, followingStatus in
      print(followingStatus)
    }

List shot likes for a user

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

List a user’s projects

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

List shots for a user


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

List a user’s teams

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

Authenticated Request :lock:

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(){ apiData, user in  }

List a user’s buckets

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

List the authenticated user’s followers

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

List who the authenticated user is following

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

List shots for users followed by a user

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

Check if AuthUser following a user

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

Follow a user

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

Unfollow a user

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

List shot likes for user

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

List a user’s projects

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

List shots for a user

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

List a user’s teams

  UserDS.getAuthShots(perPage: 10, page: 3){apiData, shots in print(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"){
      apiData, returnCode, status in
      print(returnCode) //
      print(status)
    }

Unlike a shot

    ShotsDS.unlikeShot(shotId: "2678120"){
      apiData, returnCode, status in
      print(returnCode) //
      print(status)
    }

Checking if user liked a shot

  ShotsDS.checkIfShotLiked(shotId: "2687276"){
      apiData, returnCode, status in
      print(returnCode) //
      print(status)
    }

Latest podspec

{
    "name": "DribbbleSwift",
    "version": "0.3.1",
    "summary": "Swift wrapper for dribbble api v1",
    "description": "Swift wrapper for dribbble api v1 http://developer.dribbble.com/v1/",
    "homepage": "https://github.com/gkye/DribbbleSwift",
    "license": "MIT",
    "authors": {
        "gkye": "[email protected]"
    },
    "source": {
        "git": "https://github.com/gkye/DribbbleSwift.git",
        "tag": "0.3.1"
    },
    "social_media_url": "https://twitter.com/kyegeorge",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Source/**/*"
}

Pin It on Pinterest

Share This