Skip to content

Instantly share code, notes, and snippets.

@steve228uk
Forked from crabcrabcam/organisations.swift
Last active November 21, 2016 10:36
Show Gist options
  • Save steve228uk/ef8cc27df15d68c62503fb548235972c to your computer and use it in GitHub Desktop.
Save steve228uk/ef8cc27df15d68c62503fb548235972c to your computer and use it in GitHub Desktop.
Organisation getter
extension GitKit {
public class func getMyOrganisations() -> Observable<[Organisation]> {
guard let organisationsURL = GitKit.currentUser.value?.organizationsUrl else { return Observable.just([]) }
return Alamofire.request(.GET, (organisationsURL))
.rx_responseJSON()
.map { response, json in
guard let array = json as? [[String:AnyObject]] else { return [] }
return array.map { [unowned self] json in
return Organisation(json: json) // this needed to be json and not array
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment