DribbbleSwift 0.3.1

DribbbleSwift 0.3.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2016年12月
SPM支持 SPM

George Kye 维护。



codebeat badge

使用方法

注册 Dribble 应用程序

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

安装

Swift 3

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

Swift 2

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

手动安装

  • 将文件拖入 Xcode 项目中
  • 导入 DribbbleSwift

端点

GET

标记请求 (Authenticated Request)

示例 (GET)

任何获取请求都必须满足的条件(在每次 GET 请求之前必须设置访问令牌)

 ConfigDS.setAccessToken("YOUR ACCESS TOKEN")

桶 (Buckets)👝

获取桶信息

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

列出桶中的作品

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

项目📄

获取项目信息

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

列出项目中的作品

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

作品 (Shots)📷

列出作品

参数

 /**
     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)
        }

列出作品的附件

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

列出射击的存储桶

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

列出射击的评论

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

列出射击的点赞

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

列出射击的项目

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

列出射击的反弹

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

团队👥

列出团队的成员

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

用户 :领结:

获取单个用户

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

列出用户的存储桶

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

列出用户的关注者

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

列出用户跟する人

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

        }

检查一个用户是否关注另一个用户

如果关注则返回 true,否则返回 false。

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

列出用户的射击点赞

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

列出用户的某个项目

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

列出用户的射击

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

列出用户的团队

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

认证请求🔒

http://developer.dribbble.com/v1/oauth/ 关于认证过程更多信息。

配置

执行任何认证请求之前必须设置 CONFIG 令牌。

ConfigDS.setOAuth2Token("OAUTH2 TOKEN RECEIVED")

用户

获取认证用户

 UserDS.getAuthUser(){ user in  }

列出用户的存储桶

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

列出认证用户的关注者

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

列出认证用户跟する人

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

列出被用户跟する用户的射击

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

检查AuthUser是否关注用户

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

关注用户

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

取消关注用户

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

列出用户拍摄的喜爱内容

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

列出用户的计划

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

列出用户的照片

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

列出用户的团队

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

照片

喜欢和不喜欢照片需要用户具有写入权限的认证。

喜欢一张照片

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

不喜欢一张照片

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

        }

检查用户是否喜欢照片

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