一個用RxSwift實現的GitHubAPI庫
來自: http://fengdeng.github.io/blog/2016/01/29/a-github-api-by-rxswift/
一個用RxSwift實現的GitHubAPI庫
倉庫地址 https://github.com/FengDeng/RxGitHubAPI
這個庫還未完善,由于最近工作比較忙,剛剛實現小部分的功能。
也希望大家pull request 來完善它
目前實現的功能:
- 登錄
- 獲取一個用戶信息(自己的或者別人的)
- 獲取這個用戶的其他信息,請看 #YYUser
- star,unStar,checkStar等等對倉庫的一些行為,請看#YYRepository
- search Repos 和 search Users
Start
- 設置
RxGitHubUserName
RxGitHubPassword
獲取 login user
static var yy_user : Requestable<YYUser>
- 訂閱
Requestable<YYUser>
就可以獲取到你登錄的用戶了。
</ol>
- returns: return value description */ public var action_star : Actionable<Bool>{ return Actionable(mothod: .PUT, url: self.action_star_url.yy_clear(),headers:AuthHeader()) }
- returns: return value description */ public var action_unStar : Actionable<Bool>{ return Actionable(mothod: .DELETE, url: self.action_star_url.yy_clear(),headers:AuthHeader()) }
- returns: */ public var action_checkStar : Actionable<Bool>{ return Actionable(mothod: .GET, url: self.action_star_url.yy_clear(),headers:AuthHeader()) }
- returns: return value description */ public var action_watch : Actionable<Bool>{ return Actionable(mothod: .PUT, url: self.action_watch_url.yy_clear(),headers:AuthHeader()) }
- returns: return value description */ public var action_unWatch : Actionable<Bool>{ return Actionable(mothod: .DELETE, url: self.action_watch_url.yy_clear(),headers:AuthHeader()) }
- returns: */ public var action_checkWatch : Actionable<Bool>{ return Actionable(mothod: .GET, url: self.action_watch_url.yy_clear(),headers:AuthHeader()) }</pre>
Search
搜索倉庫
RxGitHubAPI.searchRepos(q:String)
訂閱其獲取YYRepository實例數組
搜索用戶
RxGitHubAPI.searchUsers(q:String)
訂閱其獲取YYUser實例數組
YYUser
通過登錄獲取YYUser實例,先實現前面start方法
RxGitHubAPI.yy_user
訂閱其獲取YYUser實例
通過username獲取YYUser實例
RxGitHubAPI.yy_user(username:)
訂閱其獲取YYUser實例
使用這個YYUser實例,獲取更多信息
list followers
public var yy_followers:Pageable<[YYUser]list followings public var yy_followings : Pageable<[YYUser]> list gists public var yy_gist : Pageable<[YYGist]> list starred repo public var yy_starred : Pageable<[YYRepository]> list subscriptions repo public var yy_subscriptions : Pageable<[YYRepository]> list subscriptions orgs public var yy_organizations : Pageable<[YYOrganization]> list user repo public var yy_repos : Pageable<[YYRepository]> //fix me //public var yy_events //public var yy_received_events //action needs Auth follow this user public var action_follow : Actionable<Bool> unFollow this user public var action_unFollow : Actionable<Bool> check you are following this user public var action_checkFollow : Actionable<Bool></pre> <h1>YYRepository</h1>
獲取到YYRepository實例,你可以
/** star this repo
/** unStar this repo
/** check you are starring this repo
/** watch this repo
/** unWatch this repo
/** check you are watching this repo
本文由用戶 RosKeegan 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!