Cocoapods. Network layer. Fetching repos.

This commit is contained in:
Rodrigo Pedroso 2019-06-27 01:36:36 -04:00
commit 3dafdbc09c
143 changed files with 12470 additions and 47 deletions

View file

@ -0,0 +1,125 @@
//
// Authentication.swift
// GithubAPI
//
// Created by Serhii Londar on 1/2/18.
//
import Foundation
extension String {
func fromBase64() -> String? {
guard let data = Data(base64Encoded: self, options: Data.Base64DecodingOptions(rawValue: 0)) else {
return nil
}
return String(data: data as Data, encoding: String.Encoding.utf8)
}
func toBase64() -> String? {
guard let data = self.data(using: String.Encoding.utf8) else {
return nil
}
return data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0))
}
}
public enum AuthenticationType {
case none
case headers
case parameters
}
public class Authentication {
public var type: AuthenticationType {
return .none
}
public init() {
}
public var key: String {
return ""
}
public var value: String {
return ""
}
public func headers() -> [String : String] {
return [key : value]
}
}
public class BasicAuthentication: Authentication {
override public var type: AuthenticationType {
return .headers
}
public var username: String
public var password: String
public init(username: String, password: String) {
self.username = username
self.password = password
}
override public var key: String {
return "Authorization"
}
override public var value: String {
let authorization = self.username + ":" + self.password
return "Basic \(authorization.toBase64() ?? "")"
}
override public func headers() -> [String : String] {
let authorization = self.username + ":" + self.password
return ["Authorization": "Basic \(authorization.toBase64() ?? "")"]
}
}
public class TokenAuthentication: Authentication {
override public var type: AuthenticationType {
return .headers
}
public var token: String
public init(token: String) {
self.token = token
}
override public var key: String {
return "Authorization"
}
override public var value: String {
return "token \(self.token)"
}
override public func headers() -> [String : String] {
return [self.key: "token \(self.token)"]
}
}
public class AccessTokenAuthentication: Authentication {
override public var type: AuthenticationType {
return .parameters
}
public var access_token: String
public init(access_token: String) {
self.access_token = access_token
}
override public var key: String {
return "access_token"
}
override public var value: String {
return "\(self.access_token)"
}
override public func headers() -> [String : String] {
return [self.key: "\(self.access_token)"]
}
}

View file

@ -0,0 +1,196 @@
//
// GithubAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/2/18.
// Copyright © 2018 Serhii Londar. All rights reserved.
//
import Foundation
import BaseAPI
public class GithubAPI: BaseAPI {
var authentication: Authentication? = nil
var defaultHeaders = [
"Accept" : "application/vnd.github.v3+json",
RequestHeaderFields.acceptEncoding.rawValue : "gzip",
"Content-Type" : "application/json; charset=utf-8"
]
public init(authentication: Authentication) {
self.authentication = authentication
super.init()
}
public override init() {
super.init()
}
let baseUrl = "https://api.github.com"
public func get<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, completion: @escaping (T?, Error?) -> Swift.Void) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
self.get(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders) { (data, response, error) in
if let data = data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
completion(model, error)
} catch {
completion(nil, error)
}
} else {
completion(nil, error)
}
}
}
public func getSync<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil) -> (response: T?, error: Error?) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
let response = self.get(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders)
if let data = response.data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
return (model, response.error)
} catch {
return (nil, error)
}
} else {
return (nil, response.error)
}
}
public func put<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping (T?, Error?) -> Swift.Void) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
self.put(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body) { (data, response, error) in
if let data = data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
completion(model, error)
} catch {
completion(nil, error)
}
} else {
completion(nil, error)
}
}
}
public func putSync<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> (response: T?, error: Error?) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
let response = self.put(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body)
if let data = response.data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
return (model, response.error)
} catch {
return (nil, error)
}
} else {
return (nil, response.error)
}
}
public func post<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping (T?, Error?) -> Swift.Void) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
self.post(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body) { (data, response, error) in
if let data = data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
completion(model, error)
} catch {
completion(nil, error)
}
} else {
completion(nil, error)
}
}
}
public func postSync<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> (response: T?, error: Error?) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
let response = self.post(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body)
if let data = response.data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
return (model, response.error)
} catch {
return (nil, error)
}
} else {
return (nil, response.error)
}
}
public func patch<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping (T?, Error?) -> Swift.Void) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
self.patch(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body) { (data, response, error) in
if let data = data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
let error = try JSONDecoder().decode(OtherUserError.self, from: data)
completion(model, error)
} catch {
completion(nil, error)
}
} else {
completion(nil, error)
}
}
}
public func patchSync<T:Decodable>(path: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> (response: T?, error: Error?) {
let (newHeaders, newParameters) = self.addAuthenticationIfNeeded(headers, parameters: parameters)
let response = self.patch(url: self.baseUrl + path, parameters: newParameters, headers: newHeaders, body: body)
if let data = response.data {
do {
let model = try JSONDecoder().decode(T.self, from: data)
return (model, response.error)
} catch {
return (nil, error)
}
} else {
return (nil, response.error)
}
}
func addAuthenticationIfNeeded(_ headers: [String : String]?, parameters: [String : String]?) -> (headers: [String : String]?, parameters: [String : String]?) {
var newHeaders = headers
var newParameters = parameters
if let authentication = self.authentication {
if authentication.type == .headers {
if var newHeaders = newHeaders {
newHeaders[authentication.key] = authentication.value
return (newHeaders, newParameters)
} else {
newHeaders = [String : String]()
newHeaders![authentication.key] = authentication.value
return (newHeaders, newParameters)
}
} else if authentication.type == .parameters {
if var newParameters = newParameters {
newParameters[authentication.key] = authentication.value
return (newHeaders, newParameters)
} else {
newParameters = [String : String]()
newParameters![authentication.key] = authentication.value
return (newHeaders, newParameters)
}
}
}
return (newHeaders, newParameters)
}
func addDefaultHeaders(_ headers: [String : String]?) -> [String : String]? {
var newHeaders = headers
if newHeaders == nil {
newHeaders = [String : String]()
}
for header in defaultHeaders {
newHeaders![header.key] = header.value
}
return newHeaders
}
}

View file

@ -0,0 +1,139 @@
//
// IssuesAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/8/18.
//
import Foundation
public enum IssueFilter: String {
case assigned
case created
case mentioned
case subscribed
case all
}
public enum IssueState: String {
case open
case closed
case all
}
public enum IssueSort: String {
case created
case updated
case comments
}
public enum IssueDirection: String {
case asc
case desc
}
public class IssuesAPI: GithubAPI {
/// List all issues assigned to the authenticated user across all visible repositories including owned repositories, member repositories, and organization repositories:
///
/// - Parameter completion:
public func getIssues(filter: IssueFilter = .assigned, state: IssueState = .open, labels: [String] = [], sort: IssueSort = .created, direction: IssueDirection = .desc, /*since: TimeInterval,*/ completion: @escaping([GetIssueResponse]?, Error?) -> Void) {
let path = "/issues"
var parameters = [String : String]()
parameters["filter"] = filter.rawValue
parameters["state"] = state.rawValue
if labels.count > 0 {
var labelsString = ""
for label in labels {
labelsString += label + ","
}
labelsString.removeLast()
parameters["labels"] = labelsString
}
parameters["sort"] = sort.rawValue
parameters["direction"] = direction.rawValue
self.get(path: path, parameters: parameters, completion: completion)
}
/// List all issues across owned and member repositories assigned to the authenticated user:
///
/// - Parameter completion:
public func getUserIssues(filter: IssueFilter = .assigned, state: IssueState = .open, labels: [String] = [], sort: IssueSort = .created, direction: IssueDirection = .desc, completion: @escaping([GetIssueResponse]?, Error?) -> Void) {
let path = "/user/issues"
var parameters = [String : String]()
parameters["filter"] = filter.rawValue
parameters["state"] = state.rawValue
if labels.count > 0 {
var labelsString = ""
for label in labels {
labelsString += label + ","
}
labelsString.removeLast()
parameters["labels"] = labelsString
}
parameters["sort"] = sort.rawValue
parameters["direction"] = direction.rawValue
self.get(path: path, parameters: parameters, completion: completion)
}
public func getUserIssues(organization: String, filter: IssueFilter = .assigned, state: IssueState = .open, labels: [String] = [], sort: IssueSort = .created, direction: IssueDirection = .desc, completion: @escaping([GetIssueResponse]?, Error?) -> Void) {
let path = "/orgs/\(organization)/issues"
var parameters = [String : String]()
parameters["filter"] = filter.rawValue
parameters["state"] = state.rawValue
if labels.count > 0 {
var labelsString = ""
for label in labels {
labelsString += label + ","
}
labelsString.removeLast()
parameters["labels"] = labelsString
}
parameters["sort"] = sort.rawValue
parameters["direction"] = direction.rawValue
self.get(path: path, parameters: parameters, completion: completion)
}
public func getRepositoryIssues(owner: String, repository: String, milestone: String? = nil, state: IssueState = .open, assignee: String? = nil, creator: String? = nil, mentioned: String? = nil, labels: [String] = [], sort: IssueSort = .created, direction: IssueDirection = .desc, completion: @escaping([GetIssueResponse]?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/issues"
var parameters = [String : String]()
if let milestone = milestone {
parameters["milestone"] = milestone
}
parameters["state"] = state.rawValue
if let assignee = assignee {
parameters["assignee"] = assignee
}
if let creator = creator {
parameters["creator"] = creator
}
if let mentioned = mentioned {
parameters["mentioned"] = mentioned
}
if labels.count > 0 {
var labelsString = ""
for label in labels {
labelsString += label + ","
}
labelsString.removeLast()
parameters["labels"] = labelsString
}
parameters["sort"] = sort.rawValue
parameters["direction"] = direction.rawValue
self.get(path: path, parameters: parameters, completion: completion)
}
public func getIssue(owner: String, repository: String, number: Int, completion: @escaping(GetIssueResponse?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/issues/\(number)"
self.get(path: path, completion: completion)
}
public func createIssue(owner: String, repository: String, issue: Issue, completion: @escaping(GetIssueResponse?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/issues"
self.post(path: path, body: try? JSONEncoder().encode(issue), completion: completion)
}
public func updateIssue(owner: String, repository: String, number: Int, issue: Issue, completion: @escaping(GetIssueResponse?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/issues/\(number)"
self.patch(path: path, body: try? JSONEncoder().encode(issue), completion: completion)
}
}

View file

@ -0,0 +1,41 @@
//
// Issue.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct Issue : Codable {
public var assignees : [String]?
public var body : String?
public var labels : [String]?
public var milestone : Int?
public var title : String?
enum CodingKeys: String, CodingKey {
case assignees = "assignees"
case body = "body"
case labels = "labels"
case milestone = "milestone"
case title = "title"
}
public init(title: String) {
self.assignees = nil
self.body = nil
self.labels = nil
self.milestone = nil
self.title = title
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
assignees = try values.decodeIfPresent([String].self, forKey: .assignees)
body = try values.decodeIfPresent(String.self, forKey: .body)
labels = try values.decodeIfPresent([String].self, forKey: .labels)
milestone = try values.decodeIfPresent(Int.self, forKey: .milestone)
title = try values.decodeIfPresent(String.self, forKey: .title)
}
}

View file

@ -0,0 +1,88 @@
//
// GetIssueResponse.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponse : Codable {
public let assignee : GetIssueResponseAssignee?
public let assignees : [GetIssueResponseAssignee]?
public let body : String?
public let closedAt : String?
public let comments : Int?
public let commentsUrl : String?
public let createdAt : String?
public let eventsUrl : String?
public let htmlUrl : String?
public let id : Int?
public let labels : [GetIssueResponseLabel]?
public let labelsUrl : String?
public let locked : Bool?
public let milestone : GetIssueResponseMilestone?
public let number : Int?
public let pullRequest : GetIssueResponsePullRequest?
public let repository : GetIssueResponseRepository?
public let repositoryUrl : String?
public let state : String?
public let title : String?
public let updatedAt : String?
public let url : String?
public let user : GetIssueResponseAssignee?
enum CodingKeys: String, CodingKey {
case assignee
case assignees = "assignees"
case body = "body"
case closedAt = "closed_at"
case comments = "comments"
case commentsUrl = "comments_url"
case createdAt = "created_at"
case eventsUrl = "events_url"
case htmlUrl = "html_url"
case id = "id"
case labels = "labels"
case labelsUrl = "labels_url"
case locked = "locked"
case milestone
case number = "number"
case pullRequest
case repository
case repositoryUrl = "repository_url"
case state = "state"
case title = "title"
case updatedAt = "updated_at"
case url = "url"
case user
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
assignee = try values.decodeIfPresent(GetIssueResponseAssignee.self, forKey: .assignee)
assignees = try values.decodeIfPresent([GetIssueResponseAssignee].self, forKey: .assignees)
body = try values.decodeIfPresent(String.self, forKey: .body)
closedAt = try values.decodeIfPresent(String.self, forKey: .closedAt)
comments = try values.decodeIfPresent(Int.self, forKey: .comments)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
labels = try values.decodeIfPresent([GetIssueResponseLabel].self, forKey: .labels)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
locked = try values.decodeIfPresent(Bool.self, forKey: .locked)
milestone = try values.decodeIfPresent(GetIssueResponseMilestone.self, forKey: .milestone)
number = try values.decodeIfPresent(Int.self, forKey: .number)
pullRequest = try values.decodeIfPresent(GetIssueResponsePullRequest.self, forKey: .pullRequest)
repository = try values.decodeIfPresent(GetIssueResponseRepository.self, forKey: .repository)
repositoryUrl = try values.decodeIfPresent(String.self, forKey: .repositoryUrl)
state = try values.decodeIfPresent(String.self, forKey: .state)
title = try values.decodeIfPresent(String.self, forKey: .title)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
user = try values.decodeIfPresent(GetIssueResponseAssignee.self, forKey: .user)
}
}

View file

@ -0,0 +1,69 @@
//
// GetIssueResponseAssignee.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponseAssignee : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,33 @@
//
// GetIssueResponseLabel.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponseLabel : Codable {
public let color : String?
public let defaultField : Bool?
public let id : Int?
public let name : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case color = "color"
case defaultField = "default"
case id = "id"
case name = "name"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
color = try values.decodeIfPresent(String.self, forKey: .color)
defaultField = try values.decodeIfPresent(Bool.self, forKey: .defaultField)
id = try values.decodeIfPresent(Int.self, forKey: .id)
name = try values.decodeIfPresent(String.self, forKey: .name)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,63 @@
//
// GetIssueResponseMilestone.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponseMilestone : Codable {
public let closedAt : String?
public let closedIssues : Int?
public let createdAt : String?
public let creator : GetIssueResponseAssignee?
public let descriptionField : String?
public let dueOn : String?
public let htmlUrl : String?
public let id : Int?
public let labelsUrl : String?
public let number : Int?
public let openIssues : Int?
public let state : String?
public let title : String?
public let updatedAt : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case closedAt = "closed_at"
case closedIssues = "closed_issues"
case createdAt = "created_at"
case creator
case descriptionField = "description"
case dueOn = "due_on"
case htmlUrl = "html_url"
case id = "id"
case labelsUrl = "labels_url"
case number = "number"
case openIssues = "open_issues"
case state = "state"
case title = "title"
case updatedAt = "updated_at"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
closedAt = try values.decodeIfPresent(String.self, forKey: .closedAt)
closedIssues = try values.decodeIfPresent(Int.self, forKey: .closedIssues)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
creator = try values.decodeIfPresent(GetIssueResponseAssignee.self, forKey: .creator)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
dueOn = try values.decodeIfPresent(String.self, forKey: .dueOn)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
number = try values.decodeIfPresent(Int.self, forKey: .number)
openIssues = try values.decodeIfPresent(Int.self, forKey: .openIssues)
state = try values.decodeIfPresent(String.self, forKey: .state)
title = try values.decodeIfPresent(String.self, forKey: .title)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// GetIssueResponsePermission.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponsePermission : Codable {
public let admin : Bool?
public let pull : Bool?
public let push : Bool?
enum CodingKeys: String, CodingKey {
case admin = "admin"
case pull = "pull"
case push = "push"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
admin = try values.decodeIfPresent(Bool.self, forKey: .admin)
pull = try values.decodeIfPresent(Bool.self, forKey: .pull)
push = try values.decodeIfPresent(Bool.self, forKey: .push)
}
}

View file

@ -0,0 +1,30 @@
//
// GetIssueResponsePullRequest.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponsePullRequest : Codable {
public let diffUrl : String?
public let htmlUrl : String?
public let patchUrl : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case diffUrl = "diff_url"
case htmlUrl = "html_url"
case patchUrl = "patch_url"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
diffUrl = try values.decodeIfPresent(String.self, forKey: .diffUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
patchUrl = try values.decodeIfPresent(String.self, forKey: .patchUrl)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,237 @@
//
// GetIssueResponseRepository.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct GetIssueResponseRepository : Codable {
public let allowMergeCommit : Bool?
public let allowRebaseMerge : Bool?
public let allowSquashMerge : Bool?
public let archiveUrl : String?
public let archived : Bool?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let cloneUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let createdAt : String?
public let defaultBranch : String?
public let deploymentsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksCount : Int?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let gitUrl : String?
public let hasDownloads : Bool?
public let hasIssues : Bool?
public let hasPages : Bool?
public let hasWiki : Bool?
public let homepage : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Int?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let language : String?
public let languagesUrl : String?
public let mergesUrl : String?
public let milestonesUrl : String?
public let mirrorUrl : String?
public let name : String?
public let networkCount : Int?
public let notificationsUrl : String?
public let openIssuesCount : Int?
public let owner : GetIssueResponseAssignee?
public let permissions : GetIssueResponsePermission?
public let privateField : Bool?
public let pullsUrl : String?
public let pushedAt : String?
public let releasesUrl : String?
public let size : Int?
public let sshUrl : String?
public let stargazersCount : Int?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersCount : Int?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let svnUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let topics : [String]?
public let treesUrl : String?
public let updatedAt : String?
public let url : String?
public let watchersCount : Int?
enum CodingKeys: String, CodingKey {
case allowMergeCommit = "allow_merge_commit"
case allowRebaseMerge = "allow_rebase_merge"
case allowSquashMerge = "allow_squash_merge"
case archiveUrl = "archive_url"
case archived = "archived"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case cloneUrl = "clone_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case createdAt = "created_at"
case defaultBranch = "default_branch"
case deploymentsUrl = "deployments_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksCount = "forks_count"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case gitUrl = "git_url"
case hasDownloads = "has_downloads"
case hasIssues = "has_issues"
case hasPages = "has_pages"
case hasWiki = "has_wiki"
case homepage = "homepage"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case language = "language"
case languagesUrl = "languages_url"
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case mirrorUrl = "mirror_url"
case name = "name"
case networkCount = "network_count"
case notificationsUrl = "notifications_url"
case openIssuesCount = "open_issues_count"
case owner
case permissions
case privateField = "private"
case pullsUrl = "pulls_url"
case pushedAt = "pushed_at"
case releasesUrl = "releases_url"
case size = "size"
case sshUrl = "ssh_url"
case stargazersCount = "stargazers_count"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersCount = "subscribers_count"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case svnUrl = "svn_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case topics = "topics"
case treesUrl = "trees_url"
case updatedAt = "updated_at"
case url = "url"
case watchersCount = "watchers_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
allowMergeCommit = try values.decodeIfPresent(Bool.self, forKey: .allowMergeCommit)
allowRebaseMerge = try values.decodeIfPresent(Bool.self, forKey: .allowRebaseMerge)
allowSquashMerge = try values.decodeIfPresent(Bool.self, forKey: .allowSquashMerge)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
archived = try values.decodeIfPresent(Bool.self, forKey: .archived)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
cloneUrl = try values.decodeIfPresent(String.self, forKey: .cloneUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
defaultBranch = try values.decodeIfPresent(String.self, forKey: .defaultBranch)
deploymentsUrl = try values.decodeIfPresent(String.self, forKey: .deploymentsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksCount = try values.decodeIfPresent(Int.self, forKey: .forksCount)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
gitUrl = try values.decodeIfPresent(String.self, forKey: .gitUrl)
hasDownloads = try values.decodeIfPresent(Bool.self, forKey: .hasDownloads)
hasIssues = try values.decodeIfPresent(Bool.self, forKey: .hasIssues)
hasPages = try values.decodeIfPresent(Bool.self, forKey: .hasPages)
hasWiki = try values.decodeIfPresent(Bool.self, forKey: .hasWiki)
homepage = try values.decodeIfPresent(String.self, forKey: .homepage)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
language = try values.decodeIfPresent(String.self, forKey: .language)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
mirrorUrl = try values.decodeIfPresent(String.self, forKey: .mirrorUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
networkCount = try values.decodeIfPresent(Int.self, forKey: .networkCount)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
openIssuesCount = try values.decodeIfPresent(Int.self, forKey: .openIssuesCount)
owner = try values.decodeIfPresent(GetIssueResponseAssignee.self, forKey: .owner)
permissions = try values.decodeIfPresent(GetIssueResponsePermission.self, forKey: .permissions)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
pushedAt = try values.decodeIfPresent(String.self, forKey: .pushedAt)
releasesUrl = try values.decodeIfPresent(String.self, forKey: .releasesUrl)
size = try values.decodeIfPresent(Int.self, forKey: .size)
sshUrl = try values.decodeIfPresent(String.self, forKey: .sshUrl)
stargazersCount = try values.decodeIfPresent(Int.self, forKey: .stargazersCount)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersCount = try values.decodeIfPresent(Int.self, forKey: .subscribersCount)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
svnUrl = try values.decodeIfPresent(String.self, forKey: .svnUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
topics = try values.decodeIfPresent([String].self, forKey: .topics)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
watchersCount = try values.decodeIfPresent(Int.self, forKey: .watchersCount)
}
}

View file

@ -0,0 +1,69 @@
//
// NotificationsOwner.swift
//
// Create by Serhii Londar on 9/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct NotificationsOwner : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,153 @@
//
// NotificationsRepository.swift
//
// Create by Serhii Londar on 9/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct NotificationsRepository : Codable {
public let archiveUrl : String?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let deploymentsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Float?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let languagesUrl : String?
public let mergesUrl : String?
public let milestonesUrl : String?
public let name : String?
public let notificationsUrl : String?
public let owner : NotificationsOwner?
public let privateField : Bool?
public let pullsUrl : String?
public let releasesUrl : String?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let treesUrl : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case archiveUrl = "archive_url"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case deploymentsUrl = "deployments_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case languagesUrl = "languages_url"
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case name = "name"
case notificationsUrl = "notifications_url"
case owner
case privateField = "private"
case pullsUrl = "pulls_url"
case releasesUrl = "releases_url"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case treesUrl = "trees_url"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
deploymentsUrl = try values.decodeIfPresent(String.self, forKey: .deploymentsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Float.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
owner = try values.decodeIfPresent(NotificationsOwner.self, forKey: .owner)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
releasesUrl = try values.decodeIfPresent(String.self, forKey: .releasesUrl)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,45 @@
//
// NotificationsResponse.swift
//
// Create by Serhii Londar on 9/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct NotificationsResponse : Codable {
public let id : String?
public let lastReadAt : String?
public let reason : String?
public let repository : NotificationsRepository?
public let subject : NotificationsSubject?
public let subscriptionUrl : String?
public let unread : Bool?
public let updatedAt : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case id = "id"
case lastReadAt = "last_read_at"
case reason = "reason"
case repository
case subject
case subscriptionUrl = "subscription_url"
case unread = "unread"
case updatedAt = "updated_at"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
id = try values.decodeIfPresent(String.self, forKey: .id)
lastReadAt = try values.decodeIfPresent(String.self, forKey: .lastReadAt)
reason = try values.decodeIfPresent(String.self, forKey: .reason)
repository = try values.decodeIfPresent(NotificationsRepository.self, forKey: .repository)
subject = try values.decodeIfPresent(NotificationsSubject.self, forKey: .subject)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
unread = try values.decodeIfPresent(Bool.self, forKey: .unread)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,30 @@
//
// NotificationsSubject.swift
//
// Create by Serhii Londar on 9/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct NotificationsSubject : Codable {
public let latestCommentUrl : String?
public let title : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case latestCommentUrl = "latest_comment_url"
case title = "title"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
latestCommentUrl = try values.decodeIfPresent(String.self, forKey: .latestCommentUrl)
title = try values.decodeIfPresent(String.self, forKey: .title)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,64 @@
//
// NotificationsAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/9/18.
//
import Foundation
enum NotificationReasons: String {
case assign
case author
case comment
case invitation
case manual
case mention
case state_change
case subscribed
case team_mention
}
public class NotificationsAPI: GithubAPI {
public func notifications(all: Bool = false, participating: Bool = false, since: String? = nil, before: String? = nil, completion: @escaping([NotificationsResponse]?, Error?) -> Void) {
let path = "/notifications"
var parameters = [String : String]()
parameters["all"] = String(all)
parameters["participating"] = String(participating)
if let since = since {
parameters["since"] = since
}
if let before = before {
parameters["before"] = before
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func repositoryNotifications(owner: String, repository: String, all: Bool = false, participating: Bool = false, since: String? = nil, before: String? = nil, completion: @escaping([NotificationsResponse]?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/notifications"
var parameters = [String : String]()
parameters["all"] = String(all)
parameters["participating"] = String(participating)
if let since = since {
parameters["since"] = since
}
if let before = before {
parameters["before"] = before
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func markAsRead(last_read_at: String, completion: @escaping(Bool?, Error?) -> Void) {
let path = "/notifications"
var parameters = [String : String]()
parameters["last_read_at"] = last_read_at
self.put(path: path, parameters: parameters, headers: nil, body: nil, completion: completion)
}
public func markAsRead(owner: String, repository: String, last_read_at: String, completion: @escaping(Bool?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repository)/notifications"
var parameters = [String : String]()
parameters["last_read_at"] = last_read_at
self.put(path: path, parameters: parameters, headers: nil, body: nil, completion: completion)
}
}

View file

@ -0,0 +1,33 @@
//
// RepositoryLicense.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryLicense : Codable {
public let htmlUrl : String?
public let key : String?
public let name : String?
public let spdxId : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case htmlUrl = "html_url"
case key = "key"
case name = "name"
case spdxId = "spdx_id"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
key = try values.decodeIfPresent(String.self, forKey: .key)
name = try values.decodeIfPresent(String.self, forKey: .name)
spdxId = try values.decodeIfPresent(String.self, forKey: .spdxId)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,69 @@
//
// RepositoryOrganization.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryOrganization : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,70 @@
//
// RepositoriesOwner.swift
//
// Create by Serhii Londar on 2/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryOwner : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,237 @@
//
// RepositoryParent.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryParent : Codable {
public let allowMergeCommit : Bool?
public let allowRebaseMerge : Bool?
public let allowSquashMerge : Bool?
public let archiveUrl : String?
public let archived : Bool?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let cloneUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let createdAt : String?
public let defaultBranch : String?
public let deploymentsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksCount : Int?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let gitUrl : String?
public let hasDownloads : Bool?
public let hasIssues : Bool?
public let hasPages : Bool?
public let hasWiki : Bool?
public let homepage : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Int?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let language : String?
public let languagesUrl : String?
public let mergesUrl : String?
public let milestonesUrl : String?
public let mirrorUrl : String?
public let name : String?
public let networkCount : Int?
public let notificationsUrl : String?
public let openIssuesCount : Int?
public let owner : RepositoryOrganization?
public let permissions : RepositoryPermission?
public let privateField : Bool?
public let pullsUrl : String?
public let pushedAt : String?
public let releasesUrl : String?
public let size : Int?
public let sshUrl : String?
public let stargazersCount : Int?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersCount : Int?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let svnUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let topics : [String]?
public let treesUrl : String?
public let updatedAt : String?
public let url : String?
public let watchersCount : Int?
enum CodingKeys: String, CodingKey {
case allowMergeCommit = "allow_merge_commit"
case allowRebaseMerge = "allow_rebase_merge"
case allowSquashMerge = "allow_squash_merge"
case archiveUrl = "archive_url"
case archived = "archived"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case cloneUrl = "clone_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case createdAt = "created_at"
case defaultBranch = "default_branch"
case deploymentsUrl = "deployments_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksCount = "forks_count"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case gitUrl = "git_url"
case hasDownloads = "has_downloads"
case hasIssues = "has_issues"
case hasPages = "has_pages"
case hasWiki = "has_wiki"
case homepage = "homepage"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case language = "language"
case languagesUrl = "languages_url"
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case mirrorUrl = "mirror_url"
case name = "name"
case networkCount = "network_count"
case notificationsUrl = "notifications_url"
case openIssuesCount = "open_issues_count"
case owner
case permissions
case privateField = "private"
case pullsUrl = "pulls_url"
case pushedAt = "pushed_at"
case releasesUrl = "releases_url"
case size = "size"
case sshUrl = "ssh_url"
case stargazersCount = "stargazers_count"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersCount = "subscribers_count"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case svnUrl = "svn_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case topics = "topics"
case treesUrl = "trees_url"
case updatedAt = "updated_at"
case url = "url"
case watchersCount = "watchers_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
allowMergeCommit = try values.decodeIfPresent(Bool.self, forKey: .allowMergeCommit)
allowRebaseMerge = try values.decodeIfPresent(Bool.self, forKey: .allowRebaseMerge)
allowSquashMerge = try values.decodeIfPresent(Bool.self, forKey: .allowSquashMerge)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
archived = try values.decodeIfPresent(Bool.self, forKey: .archived)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
cloneUrl = try values.decodeIfPresent(String.self, forKey: .cloneUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
defaultBranch = try values.decodeIfPresent(String.self, forKey: .defaultBranch)
deploymentsUrl = try values.decodeIfPresent(String.self, forKey: .deploymentsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksCount = try values.decodeIfPresent(Int.self, forKey: .forksCount)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
gitUrl = try values.decodeIfPresent(String.self, forKey: .gitUrl)
hasDownloads = try values.decodeIfPresent(Bool.self, forKey: .hasDownloads)
hasIssues = try values.decodeIfPresent(Bool.self, forKey: .hasIssues)
hasPages = try values.decodeIfPresent(Bool.self, forKey: .hasPages)
hasWiki = try values.decodeIfPresent(Bool.self, forKey: .hasWiki)
homepage = try values.decodeIfPresent(String.self, forKey: .homepage)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
language = try values.decodeIfPresent(String.self, forKey: .language)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
mirrorUrl = try values.decodeIfPresent(String.self, forKey: .mirrorUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
networkCount = try values.decodeIfPresent(Int.self, forKey: .networkCount)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
openIssuesCount = try values.decodeIfPresent(Int.self, forKey: .openIssuesCount)
owner = try values.decodeIfPresent(RepositoryOrganization.self, forKey: .owner)
permissions = try values.decodeIfPresent(RepositoryPermission.self, forKey: .permissions)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
pushedAt = try values.decodeIfPresent(String.self, forKey: .pushedAt)
releasesUrl = try values.decodeIfPresent(String.self, forKey: .releasesUrl)
size = try values.decodeIfPresent(Int.self, forKey: .size)
sshUrl = try values.decodeIfPresent(String.self, forKey: .sshUrl)
stargazersCount = try values.decodeIfPresent(Int.self, forKey: .stargazersCount)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersCount = try values.decodeIfPresent(Int.self, forKey: .subscribersCount)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
svnUrl = try values.decodeIfPresent(String.self, forKey: .svnUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
topics = try values.decodeIfPresent([String].self, forKey: .topics)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
watchersCount = try values.decodeIfPresent(Int.self, forKey: .watchersCount)
}
}

View file

@ -0,0 +1,27 @@
//
// RepositoryPermission.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryPermission : Codable {
public let admin : Bool?
public let pull : Bool?
public let push : Bool?
enum CodingKeys: String, CodingKey {
case admin = "admin"
case pull = "pull"
case push = "push"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
admin = try values.decodeIfPresent(Bool.self, forKey: .admin)
pull = try values.decodeIfPresent(Bool.self, forKey: .pull)
push = try values.decodeIfPresent(Bool.self, forKey: .push)
}
}

View file

@ -0,0 +1,250 @@
//
// RepositoryReponse.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryResponse : Codable {
public let allowMergeCommit : Bool?
public let allowRebaseMerge : Bool?
public let allowSquashMerge : Bool?
public let archiveUrl : String?
public let archived : Bool?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let cloneUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let createdAt : String?
public let defaultBranch : String?
public let deploymentsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksCount : Int?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let gitUrl : String?
public let hasDownloads : Bool?
public let hasIssues : Bool?
public let hasPages : Bool?
public let hasWiki : Bool?
public let homepage : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Int?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let language : String?
public let languagesUrl : String?
public let license : RepositoryLicense?
public let mergesUrl : String?
public let milestonesUrl : String?
public let mirrorUrl : String?
public let name : String?
public let networkCount : Int?
public let notificationsUrl : String?
public let openIssuesCount : Int?
public let organization : RepositoryOrganization?
public let owner : RepositoryOrganization?
public let parent : RepositoryParent?
public let permissions : RepositoryPermission?
public let privateField : Bool?
public let pullsUrl : String?
public let pushedAt : String?
public let releasesUrl : String?
public let size : Int?
public let source : RepositoryParent?
public let sshUrl : String?
public let stargazersCount : Int?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersCount : Int?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let svnUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let topics : [String]?
public let treesUrl : String?
public let updatedAt : String?
public let url : String?
public let watchersCount : Int?
enum CodingKeys: String, CodingKey {
case allowMergeCommit = "allow_merge_commit"
case allowRebaseMerge = "allow_rebase_merge"
case allowSquashMerge = "allow_squash_merge"
case archiveUrl = "archive_url"
case archived = "archived"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case cloneUrl = "clone_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case createdAt = "created_at"
case defaultBranch = "default_branch"
case deploymentsUrl = "deployments_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksCount = "forks_count"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case gitUrl = "git_url"
case hasDownloads = "has_downloads"
case hasIssues = "has_issues"
case hasPages = "has_pages"
case hasWiki = "has_wiki"
case homepage = "homepage"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case language = "language"
case languagesUrl = "languages_url"
case license
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case mirrorUrl = "mirror_url"
case name = "name"
case networkCount = "network_count"
case notificationsUrl = "notifications_url"
case openIssuesCount = "open_issues_count"
case organization
case owner
case parent
case permissions
case privateField = "private"
case pullsUrl = "pulls_url"
case pushedAt = "pushed_at"
case releasesUrl = "releases_url"
case size = "size"
case source
case sshUrl = "ssh_url"
case stargazersCount = "stargazers_count"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersCount = "subscribers_count"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case svnUrl = "svn_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case topics = "topics"
case treesUrl = "trees_url"
case updatedAt = "updated_at"
case url = "url"
case watchersCount = "watchers_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
allowMergeCommit = try values.decodeIfPresent(Bool.self, forKey: .allowMergeCommit)
allowRebaseMerge = try values.decodeIfPresent(Bool.self, forKey: .allowRebaseMerge)
allowSquashMerge = try values.decodeIfPresent(Bool.self, forKey: .allowSquashMerge)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
archived = try values.decodeIfPresent(Bool.self, forKey: .archived)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
cloneUrl = try values.decodeIfPresent(String.self, forKey: .cloneUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
defaultBranch = try values.decodeIfPresent(String.self, forKey: .defaultBranch)
deploymentsUrl = try values.decodeIfPresent(String.self, forKey: .deploymentsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksCount = try values.decodeIfPresent(Int.self, forKey: .forksCount)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
gitUrl = try values.decodeIfPresent(String.self, forKey: .gitUrl)
hasDownloads = try values.decodeIfPresent(Bool.self, forKey: .hasDownloads)
hasIssues = try values.decodeIfPresent(Bool.self, forKey: .hasIssues)
hasPages = try values.decodeIfPresent(Bool.self, forKey: .hasPages)
hasWiki = try values.decodeIfPresent(Bool.self, forKey: .hasWiki)
homepage = try values.decodeIfPresent(String.self, forKey: .homepage)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
language = try values.decodeIfPresent(String.self, forKey: .language)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
license = try values.decodeIfPresent(RepositoryLicense.self, forKey: .license)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
mirrorUrl = try values.decodeIfPresent(String.self, forKey: .mirrorUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
networkCount = try values.decodeIfPresent(Int.self, forKey: .networkCount)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
openIssuesCount = try values.decodeIfPresent(Int.self, forKey: .openIssuesCount)
organization = try values.decodeIfPresent(RepositoryOrganization.self, forKey: .organization)
owner = try values.decodeIfPresent(RepositoryOrganization.self, forKey: .owner)
parent = try values.decodeIfPresent(RepositoryParent.self, forKey: .parent)
permissions = try values.decodeIfPresent(RepositoryPermission.self, forKey: .permissions)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
pushedAt = try values.decodeIfPresent(String.self, forKey: .pushedAt)
releasesUrl = try values.decodeIfPresent(String.self, forKey: .releasesUrl)
size = try values.decodeIfPresent(Int.self, forKey: .size)
source = try values.decodeIfPresent(RepositoryParent.self, forKey: .source)
sshUrl = try values.decodeIfPresent(String.self, forKey: .sshUrl)
stargazersCount = try values.decodeIfPresent(Int.self, forKey: .stargazersCount)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersCount = try values.decodeIfPresent(Int.self, forKey: .subscribersCount)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
svnUrl = try values.decodeIfPresent(String.self, forKey: .svnUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
topics = try values.decodeIfPresent([String].self, forKey: .topics)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
watchersCount = try values.decodeIfPresent(Int.self, forKey: .watchersCount)
}
}

View file

@ -0,0 +1,27 @@
//
// RepositoryContentsLink.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryContentsLink : Codable {
public let git : String?
public let html : String?
public let selfValue : String?
enum CodingKeys: String, CodingKey {
case git = "git"
case html = "html"
case selfValue = "self"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
git = try values.decodeIfPresent(String.self, forKey: CodingKeys.git)
html = try values.decodeIfPresent(String.self, forKey: CodingKeys.html)
selfValue = try values.decodeIfPresent(String.self, forKey: CodingKeys.selfValue)
}
}

View file

@ -0,0 +1,55 @@
//
// RepositoryContentsReponse.swift
//
// Create by Serhii Londar on 21/1/2018
// Copyright © 2018 Techmagic. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct RepositoryContentsReponse : Codable {
public let links : RepositoryContentsLink?
public let content : String?
public let downloadUrl : String?
public let encoding : String?
public let gitUrl : String?
public let htmlUrl : String?
public let name : String?
public let path : String?
public let sha : String?
public let size : Int?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case links
case content = "content"
case downloadUrl = "download_url"
case encoding = "encoding"
case gitUrl = "git_url"
case htmlUrl = "html_url"
case name = "name"
case path = "path"
case sha = "sha"
case size = "size"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
links = try values.decodeIfPresent(RepositoryContentsLink.self, forKey: .links)
content = try values.decodeIfPresent(String.self, forKey: .content)
downloadUrl = try values.decodeIfPresent(String.self, forKey: .downloadUrl)
encoding = try values.decodeIfPresent(String.self, forKey: .encoding)
gitUrl = try values.decodeIfPresent(String.self, forKey: .gitUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
path = try values.decodeIfPresent(String.self, forKey: .path)
sha = try values.decodeIfPresent(String.self, forKey: .sha)
size = try values.decodeIfPresent(Int.self, forKey: .size)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,120 @@
//
// RepositoriesAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/2/18.
//
import Foundation
import BaseAPI
public enum RepositoriesVisibility: String {
case all
case `public`
case `private`
}
public enum RepositoriesAffiliation: String {
case owner
case collaborator
case organization_member
}
public enum RepositoriesType: String {
case all
case owner
case `public`
case `private`
case member
}
public enum OrganizationRepositoriesType: String {
case all
case `public`
case `private`
case forks
case sources
case member
}
public enum RepositoriesSort: String {
case created
case updated
case pushed
case full_name
}
public enum RepositoriesDirection: String {
case asc
case desc
}
public class RepositoriesAPI: GithubAPI {
public func repositories(visibility: RepositoriesVisibility? = nil, affiliation: [RepositoriesAffiliation]? = nil, type: RepositoriesType? = nil, sort: RepositoriesSort? = nil, direction: RepositoriesDirection? = nil, completion: @escaping([RepositoryResponse]?, Error?) -> Void) {
let path = "/user/repos"
var parameters = [String : String]()
if let visibility = visibility {
parameters["visibility"] = visibility.rawValue
}
if let affiliation = affiliation {
if affiliation.count > 0 {
var affiliationValue = ""
for iterator in affiliation {
affiliationValue += iterator.rawValue + ","
}
affiliationValue.removeLast()
parameters["affiliation"] = affiliationValue
}
}
if let type = type {
parameters["type"] = type.rawValue
}
if let sort = sort {
parameters["sort"] = sort.rawValue
}
if let direction = direction {
parameters["direction"] = direction.rawValue
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func repositories(user: String, type: RepositoriesType? = nil, sort: RepositoriesSort? = nil, direction: RepositoriesDirection? = nil, completion: @escaping([RepositoryResponse]?, Error?) -> Void) {
let path = "/users/\(user)/repos"
var parameters = [String : String]()
if let type = type {
parameters["type"] = type.rawValue
}
if let sort = sort {
parameters["sort"] = sort.rawValue
}
if let direction = direction {
parameters["direction"] = direction.rawValue
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func repositories(organization: String, type: OrganizationRepositoriesType? = nil, completion: @escaping([RepositoryResponse]?, Error?) -> Void) {
let path = "/orgs/\(organization)/repos"
var parameters = [String : String]()
if let type = type {
parameters["type"] = type.rawValue
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func listRepositories(since: String, completion: @escaping([RepositoryResponse]?, Error?) -> Void) {
let path = "/repositories"
var parameters = [String : String]()
parameters["since"] = since
self.get(path: path, parameters: parameters, completion: completion)
}
public func get(owner: String, repo: String, completion: @escaping(RepositoryResponse?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repo)"
self.get(path: path, completion: completion)
}
}

View file

@ -0,0 +1,31 @@
//
// RepositoriesContentsAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/21/18.
//
import Foundation
import BaseAPI
public class RepositoriesContentsAPI: GithubAPI {
public func getReadme(owner: String, repo: String, ref: String? = nil, completion: @escaping(RepositoryContentsReponse?, Error?) -> Void) {
let path = "/repos/\(owner)/\(repo)/readme"
var parameters: [String : String]? = nil
if let ref = ref {
parameters = [String : String]()
parameters!["ref"] = ref
}
self.get(path: path, parameters: parameters, completion: completion)
}
public func getReadmeSync(owner: String, repo: String, ref: String? = nil) -> (response: RepositoryContentsReponse?, error: Error?) {
let path = "/repos/\(owner)/\(repo)/readme"
var parameters: [String : String]? = nil
if let ref = ref {
parameters = [String : String]()
parameters!["ref"] = ref
}
return self.getSync(path: path, parameters: parameters, headers: nil)
}
}

View file

@ -0,0 +1,42 @@
//
// SearchCodeItem.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCodeItem : Codable {
public let gitUrl : String?
public let htmlUrl : String?
public let name : String?
public let path : String?
public let repository : SearchCodeRepository?
public let score : Float?
public let sha : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case gitUrl = "git_url"
case htmlUrl = "html_url"
case name = "name"
case path = "path"
case repository
case score = "score"
case sha = "sha"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
gitUrl = try values.decodeIfPresent(String.self, forKey: .gitUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
path = try values.decodeIfPresent(String.self, forKey: .path)
repository = try values.decodeIfPresent(SearchCodeRepository.self, forKey: .repository)
score = try values.decodeIfPresent(Float.self, forKey: .score)
sha = try values.decodeIfPresent(String.self, forKey: .sha)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,69 @@
//
// SearchCodeOwner.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCodeOwner : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,147 @@
//
// SearchCodeRepository.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCodeRepository : Codable {
public let archiveUrl : String?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Int?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let languagesUrl : String?
public let mergesUrl : String?
public let milestonesUrl : String?
public let name : String?
public let notificationsUrl : String?
public let owner : SearchCodeOwner?
public let privateField : Bool?
public let pullsUrl : String?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let treesUrl : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case archiveUrl = "archive_url"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case languagesUrl = "languages_url"
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case name = "name"
case notificationsUrl = "notifications_url"
case owner
case privateField = "private"
case pullsUrl = "pulls_url"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case treesUrl = "trees_url"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
owner = try values.decodeIfPresent(SearchCodeOwner.self, forKey: .owner)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchCodeResponse.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCodeResponse : Codable {
public let incompleteResults : Bool?
public let items : [SearchCodeItem]?
public let totalCount : Int?
enum CodingKeys: String, CodingKey {
case incompleteResults = "incomplete_results"
case items = "items"
case totalCount = "total_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
incompleteResults = try values.decodeIfPresent(Bool.self, forKey: .incompleteResults)
items = try values.decodeIfPresent([SearchCodeItem].self, forKey: .items)
totalCount = try values.decodeIfPresent(Int.self, forKey: .totalCount)
}
}

View file

@ -0,0 +1,79 @@
//
// SearchCommitsAuthor.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsAuthor : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
public let date : String?
public let email : String?
public let name : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
case date = "date"
case email = "email"
case name = "name"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
date = try values.decodeIfPresent(String.self, forKey: .date)
email = try values.decodeIfPresent(String.self, forKey: .email)
name = try values.decodeIfPresent(String.self, forKey: .name)
}
}

View file

@ -0,0 +1,36 @@
//
// SearchCommitsCommit.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsCommit : Codable {
public let author : SearchCommitsAuthor?
public let commentCount : Int?
public let committer : SearchCommitsCommitter?
public let message : String?
public let tree : SearchCommitsTree?
public let url : String?
enum CodingKeys: String, CodingKey {
case author
case commentCount = "comment_count"
case committer
case message = "message"
case tree
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
author = try values.decodeIfPresent(SearchCommitsAuthor.self, forKey: .author)
commentCount = try values.decodeIfPresent(Int.self, forKey: .commentCount)
committer = try values.decodeIfPresent(SearchCommitsCommitter.self, forKey: .committer)
message = try values.decodeIfPresent(String.self, forKey: .message)
tree = try values.decodeIfPresent(SearchCommitsTree.self, forKey: .tree)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,79 @@
//
// SearchCommitsCommitter.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsCommitter : Codable {
public let date : String?
public let email : String?
public let name : String?
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case date = "date"
case email = "email"
case name = "name"
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
date = try values.decodeIfPresent(String.self, forKey: .date)
email = try values.decodeIfPresent(String.self, forKey: .email)
name = try values.decodeIfPresent(String.self, forKey: .name)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,48 @@
//
// SearchCommitsItem.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsItem : Codable {
public let author : SearchCommitsAuthor?
public let commentsUrl : String?
public let commit : SearchCommitsCommit?
public let committer : SearchCommitsCommitter?
public let htmlUrl : String?
public let parents : [SearchCommitsParent]?
public let repository : SearchCommitsRepository?
public let score : Float?
public let sha : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case author
case commentsUrl = "comments_url"
case commit
case committer
case htmlUrl = "html_url"
case parents = "parents"
case repository
case score = "score"
case sha = "sha"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
author = try values.decodeIfPresent(SearchCommitsAuthor.self, forKey: .author)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commit = try values.decodeIfPresent(SearchCommitsCommit.self, forKey: .commit)
committer = try values.decodeIfPresent(SearchCommitsCommitter.self, forKey: .committer)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
parents = try values.decodeIfPresent([SearchCommitsParent].self, forKey: .parents)
repository = try values.decodeIfPresent(SearchCommitsRepository.self, forKey: .repository)
score = try values.decodeIfPresent(Float.self, forKey: .score)
sha = try values.decodeIfPresent(String.self, forKey: .sha)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,69 @@
//
// SearchCommitsOwner.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsOwner : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchCommitsParent.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsParent : Codable {
public let htmlUrl : String?
public let sha : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case htmlUrl = "html_url"
case sha = "sha"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
sha = try values.decodeIfPresent(String.self, forKey: .sha)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,154 @@
//
// SearchCommitsRepository.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsRepository : Codable {
public let archiveUrl : String?
public let assigneesUrl : String?
public let blobsUrl : String?
public let branchesUrl : String?
public let collaboratorsUrl : String?
public let commentsUrl : String?
public let commitsUrl : String?
public let compareUrl : String?
public let contentsUrl : String?
public let contributorsUrl : String?
public let deploymentsUrl : String?
public let descriptionField : String?
public let downloadsUrl : String?
public let eventsUrl : String?
public let fork : Bool?
public let forksUrl : String?
public let fullName : String?
public let gitCommitsUrl : String?
public let gitRefsUrl : String?
public let gitTagsUrl : String?
public let hooksUrl : String?
public let htmlUrl : String?
public let id : Int?
public let issueCommentUrl : String?
public let issueEventsUrl : String?
public let issuesUrl : String?
public let keysUrl : String?
public let labelsUrl : String?
public let languagesUrl : String?
public let mergesUrl : String?
public let milestonesUrl : String?
public let name : String?
public let notificationsUrl : String?
public let owner : SearchCommitsOwner?
public let privateField : Bool?
public let pullsUrl : String?
public let releasesUrl : String?
public let stargazersUrl : String?
public let statusesUrl : String?
public let subscribersUrl : String?
public let subscriptionUrl : String?
public let tagsUrl : String?
public let teamsUrl : String?
public let treesUrl : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case archiveUrl = "archive_url"
case assigneesUrl = "assignees_url"
case blobsUrl = "blobs_url"
case branchesUrl = "branches_url"
case collaboratorsUrl = "collaborators_url"
case commentsUrl = "comments_url"
case commitsUrl = "commits_url"
case compareUrl = "compare_url"
case contentsUrl = "contents_url"
case contributorsUrl = "contributors_url"
case deploymentsUrl = "deployments_url"
case descriptionField = "description"
case downloadsUrl = "downloads_url"
case eventsUrl = "events_url"
case fork = "fork"
case forksUrl = "forks_url"
case fullName = "full_name"
case gitCommitsUrl = "git_commits_url"
case gitRefsUrl = "git_refs_url"
case gitTagsUrl = "git_tags_url"
case hooksUrl = "hooks_url"
case htmlUrl = "html_url"
case id = "id"
case issueCommentUrl = "issue_comment_url"
case issueEventsUrl = "issue_events_url"
case issuesUrl = "issues_url"
case keysUrl = "keys_url"
case labelsUrl = "labels_url"
case languagesUrl = "languages_url"
case mergesUrl = "merges_url"
case milestonesUrl = "milestones_url"
case name = "name"
case notificationsUrl = "notifications_url"
case owner
case privateField = "private"
case pullsUrl = "pulls_url"
case releasesUrl = "releases_url"
case stargazersUrl = "stargazers_url"
case statusesUrl = "statuses_url"
case subscribersUrl = "subscribers_url"
case subscriptionUrl = "subscription_url"
case tagsUrl = "tags_url"
case teamsUrl = "teams_url"
case treesUrl = "trees_url"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
archiveUrl = try values.decodeIfPresent(String.self, forKey: .archiveUrl)
assigneesUrl = try values.decodeIfPresent(String.self, forKey: .assigneesUrl)
blobsUrl = try values.decodeIfPresent(String.self, forKey: .blobsUrl)
branchesUrl = try values.decodeIfPresent(String.self, forKey: .branchesUrl)
collaboratorsUrl = try values.decodeIfPresent(String.self, forKey: .collaboratorsUrl)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
commitsUrl = try values.decodeIfPresent(String.self, forKey: .commitsUrl)
compareUrl = try values.decodeIfPresent(String.self, forKey: .compareUrl)
contentsUrl = try values.decodeIfPresent(String.self, forKey: .contentsUrl)
contributorsUrl = try values.decodeIfPresent(String.self, forKey: .contributorsUrl)
deploymentsUrl = try values.decodeIfPresent(String.self, forKey: .deploymentsUrl)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
downloadsUrl = try values.decodeIfPresent(String.self, forKey: .downloadsUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksUrl = try values.decodeIfPresent(String.self, forKey: .forksUrl)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
gitCommitsUrl = try values.decodeIfPresent(String.self, forKey: .gitCommitsUrl)
gitRefsUrl = try values.decodeIfPresent(String.self, forKey: .gitRefsUrl)
gitTagsUrl = try values.decodeIfPresent(String.self, forKey: .gitTagsUrl)
hooksUrl = try values.decodeIfPresent(String.self, forKey: .hooksUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
issueCommentUrl = try values.decodeIfPresent(String.self, forKey: .issueCommentUrl)
issueEventsUrl = try values.decodeIfPresent(String.self, forKey: .issueEventsUrl)
issuesUrl = try values.decodeIfPresent(String.self, forKey: .issuesUrl)
keysUrl = try values.decodeIfPresent(String.self, forKey: .keysUrl)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
languagesUrl = try values.decodeIfPresent(String.self, forKey: .languagesUrl)
mergesUrl = try values.decodeIfPresent(String.self, forKey: .mergesUrl)
milestonesUrl = try values.decodeIfPresent(String.self, forKey: .milestonesUrl)
name = try values.decodeIfPresent(String.self, forKey: .name)
notificationsUrl = try values.decodeIfPresent(String.self, forKey: .notificationsUrl)
owner = try values.decodeIfPresent(SearchCommitsOwner.self, forKey: .owner)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pullsUrl = try values.decodeIfPresent(String.self, forKey: .pullsUrl)
releasesUrl = try values.decodeIfPresent(String.self, forKey: .releasesUrl)
stargazersUrl = try values.decodeIfPresent(String.self, forKey: .stargazersUrl)
statusesUrl = try values.decodeIfPresent(String.self, forKey: .statusesUrl)
subscribersUrl = try values.decodeIfPresent(String.self, forKey: .subscribersUrl)
subscriptionUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionUrl)
tagsUrl = try values.decodeIfPresent(String.self, forKey: .tagsUrl)
teamsUrl = try values.decodeIfPresent(String.self, forKey: .teamsUrl)
treesUrl = try values.decodeIfPresent(String.self, forKey: .treesUrl)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchCommitsResponse.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsResponse : Codable {
public let incompleteResults : Bool?
public let items : [SearchCommitsItem]?
public let totalCount : Int?
enum CodingKeys: String, CodingKey {
case incompleteResults = "incomplete_results"
case items = "items"
case totalCount = "total_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
incompleteResults = try values.decodeIfPresent(Bool.self, forKey: .incompleteResults)
items = try values.decodeIfPresent([SearchCommitsItem].self, forKey: .items)
totalCount = try values.decodeIfPresent(Int.self, forKey: .totalCount)
}
}

View file

@ -0,0 +1,24 @@
//
// SearchCommitsTree.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchCommitsTree : Codable {
public let sha : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case sha = "sha"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
sha = try values.decodeIfPresent(String.self, forKey: .sha)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,69 @@
//
// SearchIssuesAssignee.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesAssignee : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,84 @@
//
// SearchIssuesItem.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesItem : Codable {
public let assignee : SearchIssuesAssignee?
public let assignees : [SearchIssuesAssignee]?
public let body : String?
public let closedAt : String?
public let comments : Int?
public let commentsUrl : String?
public let createdAt : String?
public let eventsUrl : String?
public let htmlUrl : String?
public let id : Int?
public let labels : [SearchIssuesLabel]?
public let labelsUrl : String?
public let milestone : SearchIssuesMilestone?
public let number : Int?
public let pullRequest : SearchIssuesPullRequest?
public let repositoryUrl : String?
public let score : Float?
public let state : String?
public let title : String?
public let updatedAt : String?
public let url : String?
public let user : SearchIssuesUser?
enum CodingKeys: String, CodingKey {
case assignee = "assignee"
case assignees = "assignees"
case body = "body"
case closedAt = "closed_at"
case comments = "comments"
case commentsUrl = "comments_url"
case createdAt = "created_at"
case eventsUrl = "events_url"
case htmlUrl = "html_url"
case id = "id"
case labels = "labels"
case labelsUrl = "labels_url"
case milestone = "milestone"
case number = "number"
case pullRequest
case repositoryUrl = "repository_url"
case score = "score"
case state = "state"
case title = "title"
case updatedAt = "updated_at"
case url = "url"
case user
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
assignee = try values.decodeIfPresent(SearchIssuesAssignee.self, forKey: .assignee)
assignees = try values.decodeIfPresent([SearchIssuesAssignee].self, forKey: .assignees)
body = try values.decodeIfPresent(String.self, forKey: .body)
closedAt = try values.decodeIfPresent(String.self, forKey: .closedAt)
comments = try values.decodeIfPresent(Int.self, forKey: .comments)
commentsUrl = try values.decodeIfPresent(String.self, forKey: .commentsUrl)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
labels = try values.decodeIfPresent([SearchIssuesLabel].self, forKey: .labels)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
milestone = try values.decodeIfPresent(SearchIssuesMilestone.self, forKey: .milestone)
number = try values.decodeIfPresent(Int.self, forKey: .number)
pullRequest = try values.decodeIfPresent(SearchIssuesPullRequest.self, forKey: .pullRequest)
repositoryUrl = try values.decodeIfPresent(String.self, forKey: .repositoryUrl)
score = try values.decodeIfPresent(Float.self, forKey: .score)
state = try values.decodeIfPresent(String.self, forKey: .state)
title = try values.decodeIfPresent(String.self, forKey: .title)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
user = try values.decodeIfPresent(SearchIssuesUser.self, forKey: .user)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchIssuesLabel.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesLabel : Codable {
public let color : String?
public let name : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case color = "color"
case name = "name"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
color = try values.decodeIfPresent(String.self, forKey: .color)
name = try values.decodeIfPresent(String.self, forKey: .name)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,63 @@
//
// SearchIssuesMilestone.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesMilestone : Codable {
public let closedAt : String?
public let closedIssues : Int?
public let createdAt : String?
public let creator : SearchIssuesMilestoneCreator?
public let descriptionField : String?
public let dueOn : String?
public let htmlUrl : String?
public let id : Int?
public let labelsUrl : String?
public let number : Int?
public let openIssues : Int?
public let state : String?
public let title : String?
public let updatedAt : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case closedAt = "closed_at"
case closedIssues = "closed_issues"
case createdAt = "created_at"
case creator
case descriptionField = "description"
case dueOn = "due_on"
case htmlUrl = "html_url"
case id = "id"
case labelsUrl = "labels_url"
case number = "number"
case openIssues = "open_issues"
case state = "state"
case title = "title"
case updatedAt = "updated_at"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
closedAt = try values.decodeIfPresent(String.self, forKey: .closedAt)
closedIssues = try values.decodeIfPresent(Int.self, forKey: .closedIssues)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
creator = try values.decodeIfPresent(SearchIssuesMilestoneCreator.self, forKey: .creator)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
dueOn = try values.decodeIfPresent(String.self, forKey: .dueOn)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
labelsUrl = try values.decodeIfPresent(String.self, forKey: .labelsUrl)
number = try values.decodeIfPresent(Int.self, forKey: .number)
openIssues = try values.decodeIfPresent(Int.self, forKey: .openIssues)
state = try values.decodeIfPresent(String.self, forKey: .state)
title = try values.decodeIfPresent(String.self, forKey: .title)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,69 @@
//
// SearchIssuesMilestoneCreator.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesMilestoneCreator : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchIssuesPullRequest.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesPullRequest : Codable {
public let diffUrl : String?
public let htmlUrl : String?
public let patchUrl : String?
enum CodingKeys: String, CodingKey {
case diffUrl = "diff_url"
case htmlUrl = "html_url"
case patchUrl = "patch_url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
diffUrl = try values.decodeIfPresent(String.self, forKey: .diffUrl)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
patchUrl = try values.decodeIfPresent(String.self, forKey: .patchUrl)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchIssuesResponse.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesResponse : Codable {
public let incompleteResults : Bool?
public let items : [SearchIssuesItem]?
public let totalCount : Int?
enum CodingKeys: String, CodingKey {
case incompleteResults = "incomplete_results"
case items = "items"
case totalCount = "total_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
incompleteResults = try values.decodeIfPresent(Bool.self, forKey: .incompleteResults)
items = try values.decodeIfPresent([SearchIssuesItem].self, forKey: .items)
totalCount = try values.decodeIfPresent(Int.self, forKey: .totalCount)
}
}

View file

@ -0,0 +1,67 @@
//
// SearchIssuesUser.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchIssuesUser : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,84 @@
//
// SearchRepositoriesItem.swift
//
// Create by Serhii Londar on 2/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchRepositoriesItem : Codable {
public let createdAt : String?
public let defaultBranch : String?
public let descriptionField : String?
public let fork : Bool?
public let forksCount : Int?
public let fullName : String?
public let homepage : String?
public let htmlUrl : String?
public let id : Int?
public let language : String?
public let masterBranch : String?
public let name : String?
public let openIssuesCount : Int?
public let owner : SearchRepositoriesOwner?
public let privateField : Bool?
public let pushedAt : String?
public let score : Float?
public let size : Int?
public let stargazersCount : Int?
public let updatedAt : String?
public let url : String?
public let watchersCount : Int?
enum CodingKeys: String, CodingKey {
case createdAt = "created_at"
case defaultBranch = "default_branch"
case descriptionField = "description"
case fork = "fork"
case forksCount = "forks_count"
case fullName = "full_name"
case homepage = "homepage"
case htmlUrl = "html_url"
case id = "id"
case language = "language"
case masterBranch = "master_branch"
case name = "name"
case openIssuesCount = "open_issues_count"
case owner
case privateField = "private"
case pushedAt = "pushed_at"
case score = "score"
case size = "size"
case stargazersCount = "stargazers_count"
case updatedAt = "updated_at"
case url = "url"
case watchersCount = "watchers_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
defaultBranch = try values.decodeIfPresent(String.self, forKey: .defaultBranch)
descriptionField = try values.decodeIfPresent(String.self, forKey: .descriptionField)
fork = try values.decodeIfPresent(Bool.self, forKey: .fork)
forksCount = try values.decodeIfPresent(Int.self, forKey: .forksCount)
fullName = try values.decodeIfPresent(String.self, forKey: .fullName)
homepage = try values.decodeIfPresent(String.self, forKey: .homepage)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
language = try values.decodeIfPresent(String.self, forKey: .language)
masterBranch = try values.decodeIfPresent(String.self, forKey: .masterBranch)
name = try values.decodeIfPresent(String.self, forKey: .name)
openIssuesCount = try values.decodeIfPresent(Int.self, forKey: .openIssuesCount)
owner = try values.decodeIfPresent(SearchRepositoriesOwner.self, forKey: .owner)
privateField = try values.decodeIfPresent(Bool.self, forKey: .privateField)
pushedAt = try values.decodeIfPresent(String.self, forKey: .pushedAt)
score = try values.decodeIfPresent(Float.self, forKey: .score)
size = try values.decodeIfPresent(Int.self, forKey: .size)
stargazersCount = try values.decodeIfPresent(Int.self, forKey: .stargazersCount)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
watchersCount = try values.decodeIfPresent(Int.self, forKey: .watchersCount)
}
}

View file

@ -0,0 +1,39 @@
//
// SearchRepositoriesOwner.swift
//
// Create by Serhii Londar on 2/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchRepositoriesOwner : Codable {
public let avatarUrl : String?
public let gravatarId : String?
public let id : Int?
public let login : String?
public let receivedEventsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case gravatarId = "gravatar_id"
case id = "id"
case login = "login"
case receivedEventsUrl = "received_events_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchRepositoriesResponse.swift
//
// Create by Serhii Londar on 2/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchRepositoriesResponse : Codable {
public let incompleteResults : Bool?
public let items : [SearchRepositoriesItem]?
public let totalCount : Int?
enum CodingKeys: String, CodingKey {
case incompleteResults = "incomplete_results"
case items = "items"
case totalCount = "total_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
incompleteResults = try values.decodeIfPresent(Bool.self, forKey: .incompleteResults)
items = try values.decodeIfPresent([SearchRepositoriesItem].self, forKey: .items)
totalCount = try values.decodeIfPresent(Int.self, forKey: .totalCount)
}
}

View file

@ -0,0 +1,57 @@
//
// SearchUsersItem.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchUsersItem : Codable {
public let avatarUrl : String?
public let followersUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let score : Float?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case followersUrl = "followers_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case score = "score"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
score = try values.decodeIfPresent(Float.self, forKey: .score)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,27 @@
//
// SearchUsersResponse.swift
//
// Create by Serhii Londar on 8/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct SearchUsersResponse : Codable {
public let incompleteResults : Bool?
public let items : [SearchUsersItem]?
public let totalCount : Int?
enum CodingKeys: String, CodingKey {
case incompleteResults = "incomplete_results"
case items = "items"
case totalCount = "total_count"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
incompleteResults = try values.decodeIfPresent(Bool.self, forKey: .incompleteResults)
items = try values.decodeIfPresent([SearchUsersItem].self, forKey: .items)
totalCount = try values.decodeIfPresent(Int.self, forKey: .totalCount)
}
}

View file

@ -0,0 +1,116 @@
//
// GithubAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/2/18.
// Copyright © 2018 Serhii Londar. All rights reserved.
//
import Foundation
public enum SearchOrder: String {
case asc
case desc
}
public enum SearchRepositoriesSort: String{
case stars
case forks
case updated
}
public enum SearchCommitsSort: String{
case authorDate = "author-date"
case committerDate = "committer-date"
}
public enum SearchCodeSort: String{
case bestMatch = "best-match"
case recentlyIndexed = "recently-indexed"
case leastRecentlyIndexed = "least-recently-indexed"
}
public enum SearchIssuesSort: String{
case comments
case created
case updated
}
public enum SearchUsersSort: String{
case followers
case repositories
case joined
}
public class SearchAPI: GithubAPI {
public func searchRepositories(q: String, page: Int = 1, per_page: Int = 100, sort: SearchRepositoriesSort? = nil, order: SearchOrder = .desc, completion: @escaping (SearchRepositoriesResponse?, Error?) -> Swift.Void) {
let path = "/search/repositories"
var parameters = [String : String]()
parameters["q"] = q
parameters["order"] = order.rawValue
if let sort = sort {
parameters["sort"] = sort.rawValue
}
parameters["page"] = "\(page)"
parameters["per_page"] = "\(per_page)"
self.get(path: path, parameters: parameters, completion: completion)
}
public func searchCommits(q: String, page: Int = 1, per_page: Int = 100, sort: SearchCommitsSort? = nil, order: SearchOrder = .desc, completion: @escaping (SearchCommitsResponse?, Error?) -> Swift.Void) {
let path = "/search/commits"
var parameters = [String : String]()
parameters["q"] = q
parameters["order"] = order.rawValue
if let sort = sort {
parameters["sort"] = sort.rawValue
}
parameters["page"] = "\(page)"
parameters["per_page"] = "\(per_page)"
self.get(path: path, parameters: parameters, completion: completion)
}
public func searchCode(q: String, page: Int = 1, per_page: Int = 100, sort: SearchCodeSort? = nil, order: SearchOrder = .desc, completion: @escaping (SearchCodeResponse?, Error?) -> Swift.Void) {
let path = "/search/code"
var parameters = [String : String]()
parameters["q"] = q
parameters["order"] = order.rawValue
if let sort = sort {
parameters["sort"] = sort.rawValue
}
parameters["page"] = "\(page)"
parameters["per_page"] = "\(per_page)"
self.get(path: path, parameters: parameters, completion: completion)
}
public func searchIssues(q: String, page: Int = 1, per_page: Int = 100, sort: SearchIssuesSort? = nil, order: SearchOrder = .desc, completion: @escaping (SearchIssuesResponse?, Error?) -> Swift.Void) {
let path = "/search/issues"
var parameters = [String : String]()
parameters["q"] = q
parameters["order"] = order.rawValue
if let sort = sort {
parameters["sort"] = sort.rawValue
}
parameters["page"] = "\(page)"
parameters["per_page"] = "\(per_page)"
self.get(path: path, parameters: parameters, completion: completion)
}
public func searchUsers(q: String, page: Int = 1, per_page: Int = 100, sort: SearchUsersSort? = nil, order: SearchOrder = .desc, completion: @escaping (SearchUsersResponse?, Error?) -> Swift.Void) {
let path = "/search/users"
var parameters = [String : String]()
parameters["q"] = q
parameters["order"] = order.rawValue
if let sort = sort {
parameters["sort"] = sort.rawValue
}
parameters["page"] = "\(page)"
parameters["per_page"] = "\(per_page)"
self.get(path: path, parameters: parameters, completion: completion)
}
}

View file

@ -0,0 +1,70 @@
//
// AllUsersResponse.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct AllUsersResponse : Codable {
public let avatarUrl : String?
public let eventsUrl : String?
public let followersUrl : String?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let htmlUrl : String?
public let id : Int?
public let login : String?
public let organizationsUrl : String?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case eventsUrl = "events_url"
case followersUrl = "followers_url"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case htmlUrl = "html_url"
case id = "id"
case login = "login"
case organizationsUrl = "organizations_url"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
login = try values.decodeIfPresent(String.self, forKey: .login)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,24 @@
//
// UserError.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct OtherUserError : Error, Codable {
public let documentationUrl : String?
public let message : String?
enum CodingKeys: String, CodingKey {
case documentationUrl = "documentation_url"
case message = "message"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
documentationUrl = try values.decodeIfPresent(String.self, forKey: .documentationUrl)
message = try values.decodeIfPresent(String.self, forKey: .message)
}
}

View file

@ -0,0 +1,109 @@
//
// OtherUserResponse.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct OtherUserResponse : Codable {
public let avatarUrl : String?
public let bio : String?
public let blog : String?
public let company : String?
public let createdAt : String?
public let email : String?
public let eventsUrl : String?
public let followers : Int?
public let followersUrl : String?
public let following : Int?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let hireable : Bool?
public let htmlUrl : String?
public let id : Int?
public let location : String?
public let login : String?
public let name : String?
public let organizationsUrl : String?
public let publicGists : Int?
public let publicRepos : Int?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let type : String?
public let updatedAt : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case bio = "bio"
case blog = "blog"
case company = "company"
case createdAt = "created_at"
case email = "email"
case eventsUrl = "events_url"
case followers = "followers"
case followersUrl = "followers_url"
case following = "following"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case hireable = "hireable"
case htmlUrl = "html_url"
case id = "id"
case location = "location"
case login = "login"
case name = "name"
case organizationsUrl = "organizations_url"
case publicGists = "public_gists"
case publicRepos = "public_repos"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case type = "type"
case updatedAt = "updated_at"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
bio = try values.decodeIfPresent(String.self, forKey: .bio)
blog = try values.decodeIfPresent(String.self, forKey: .blog)
company = try values.decodeIfPresent(String.self, forKey: .company)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
email = try values.decodeIfPresent(String.self, forKey: .email)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followers = try values.decodeIfPresent(Int.self, forKey: .followers)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
following = try values.decodeIfPresent(Int.self, forKey: .following)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
hireable = try values.decodeIfPresent(Bool.self, forKey: .hireable)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
location = try values.decodeIfPresent(String.self, forKey: .location)
login = try values.decodeIfPresent(String.self, forKey: .login)
name = try values.decodeIfPresent(String.self, forKey: .name)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
publicGists = try values.decodeIfPresent(Int.self, forKey: .publicGists)
publicRepos = try values.decodeIfPresent(Int.self, forKey: .publicRepos)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
type = try values.decodeIfPresent(String.self, forKey: .type)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,30 @@
//
// UserPlan.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct UserPlan : Codable {
public let collaborators : Int?
public let name : String?
public let privateRepos : Int?
public let space : Int?
enum CodingKeys: String, CodingKey {
case collaborators = "collaborators"
case name = "name"
case privateRepos = "private_repos"
case space = "space"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
collaborators = try values.decodeIfPresent(Int.self, forKey: .collaborators)
name = try values.decodeIfPresent(String.self, forKey: .name)
privateRepos = try values.decodeIfPresent(Int.self, forKey: .privateRepos)
space = try values.decodeIfPresent(Int.self, forKey: .space)
}
}

View file

@ -0,0 +1,130 @@
//
// UserResponse.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct UserResponse : Codable {
public let avatarUrl : String?
public let bio : String?
public let blog : String?
public let collaborators : Int?
public let company : String?
public let createdAt : String?
public let diskUsage : Int?
public let email : String?
public let eventsUrl : String?
public let followers : Int?
public let followersUrl : String?
public let following : Int?
public let followingUrl : String?
public let gistsUrl : String?
public let gravatarId : String?
public let hireable : Bool?
public let htmlUrl : String?
public let id : Int?
public let location : String?
public let login : String?
public let name : String?
public let organizationsUrl : String?
public let ownedPrivateRepos : Int?
public let plan : UserPlan?
public let privateGists : Int?
public let publicGists : Int?
public let publicRepos : Int?
public let receivedEventsUrl : String?
public let reposUrl : String?
public let siteAdmin : Bool?
public let starredUrl : String?
public let subscriptionsUrl : String?
public let totalPrivateRepos : Int?
public let twoFactorAuthentication : Bool?
public let type : String?
public let updatedAt : String?
public let url : String?
enum CodingKeys: String, CodingKey {
case avatarUrl = "avatar_url"
case bio = "bio"
case blog = "blog"
case collaborators = "collaborators"
case company = "company"
case createdAt = "created_at"
case diskUsage = "disk_usage"
case email = "email"
case eventsUrl = "events_url"
case followers = "followers"
case followersUrl = "followers_url"
case following = "following"
case followingUrl = "following_url"
case gistsUrl = "gists_url"
case gravatarId = "gravatar_id"
case hireable = "hireable"
case htmlUrl = "html_url"
case id = "id"
case location = "location"
case login = "login"
case name = "name"
case organizationsUrl = "organizations_url"
case ownedPrivateRepos = "owned_private_repos"
case plan
case privateGists = "private_gists"
case publicGists = "public_gists"
case publicRepos = "public_repos"
case receivedEventsUrl = "received_events_url"
case reposUrl = "repos_url"
case siteAdmin = "site_admin"
case starredUrl = "starred_url"
case subscriptionsUrl = "subscriptions_url"
case totalPrivateRepos = "total_private_repos"
case twoFactorAuthentication = "two_factor_authentication"
case type = "type"
case updatedAt = "updated_at"
case url = "url"
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
avatarUrl = try values.decodeIfPresent(String.self, forKey: .avatarUrl)
bio = try values.decodeIfPresent(String.self, forKey: .bio)
blog = try values.decodeIfPresent(String.self, forKey: .blog)
collaborators = try values.decodeIfPresent(Int.self, forKey: .collaborators)
company = try values.decodeIfPresent(String.self, forKey: .company)
createdAt = try values.decodeIfPresent(String.self, forKey: .createdAt)
diskUsage = try values.decodeIfPresent(Int.self, forKey: .diskUsage)
email = try values.decodeIfPresent(String.self, forKey: .email)
eventsUrl = try values.decodeIfPresent(String.self, forKey: .eventsUrl)
followers = try values.decodeIfPresent(Int.self, forKey: .followers)
followersUrl = try values.decodeIfPresent(String.self, forKey: .followersUrl)
following = try values.decodeIfPresent(Int.self, forKey: .following)
followingUrl = try values.decodeIfPresent(String.self, forKey: .followingUrl)
gistsUrl = try values.decodeIfPresent(String.self, forKey: .gistsUrl)
gravatarId = try values.decodeIfPresent(String.self, forKey: .gravatarId)
hireable = try values.decodeIfPresent(Bool.self, forKey: .hireable)
htmlUrl = try values.decodeIfPresent(String.self, forKey: .htmlUrl)
id = try values.decodeIfPresent(Int.self, forKey: .id)
location = try values.decodeIfPresent(String.self, forKey: .location)
login = try values.decodeIfPresent(String.self, forKey: .login)
name = try values.decodeIfPresent(String.self, forKey: .name)
organizationsUrl = try values.decodeIfPresent(String.self, forKey: .organizationsUrl)
ownedPrivateRepos = try values.decodeIfPresent(Int.self, forKey: .ownedPrivateRepos)
plan = try values.decodeIfPresent(UserPlan.self, forKey: .plan)
privateGists = try values.decodeIfPresent(Int.self, forKey: .privateGists)
publicGists = try values.decodeIfPresent(Int.self, forKey: .publicGists)
publicRepos = try values.decodeIfPresent(Int.self, forKey: .publicRepos)
receivedEventsUrl = try values.decodeIfPresent(String.self, forKey: .receivedEventsUrl)
reposUrl = try values.decodeIfPresent(String.self, forKey: .reposUrl)
siteAdmin = try values.decodeIfPresent(Bool.self, forKey: .siteAdmin)
starredUrl = try values.decodeIfPresent(String.self, forKey: .starredUrl)
subscriptionsUrl = try values.decodeIfPresent(String.self, forKey: .subscriptionsUrl)
totalPrivateRepos = try values.decodeIfPresent(Int.self, forKey: .totalPrivateRepos)
twoFactorAuthentication = try values.decodeIfPresent(Bool.self, forKey: .twoFactorAuthentication)
type = try values.decodeIfPresent(String.self, forKey: .type)
updatedAt = try values.decodeIfPresent(String.self, forKey: .updatedAt)
url = try values.decodeIfPresent(String.self, forKey: .url)
}
}

View file

@ -0,0 +1,49 @@
//
// UpdateUser.swift
//
// Create by Serhii Londar on 7/1/2018
// Copyright © 2018 Serhii Londar. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
public struct UpdateUser : Codable {
public var bio : String?
public var blog : String?
public var company : String?
public var email : String?
public var hireable : Bool?
public var location : String?
public var name : String?
enum CodingKeys: String, CodingKey {
case bio = "bio"
case blog = "blog"
case company = "company"
case email = "email"
case hireable = "hireable"
case location = "location"
case name = "name"
}
public init() {
bio = nil
blog = nil
company = nil
email = nil
hireable = nil
location = nil
name = nil
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
bio = try values.decodeIfPresent(String.self, forKey: .bio)
blog = try values.decodeIfPresent(String.self, forKey: .blog)
company = try values.decodeIfPresent(String.self, forKey: .company)
email = try values.decodeIfPresent(String.self, forKey: .email)
hireable = try values.decodeIfPresent(Bool.self, forKey: .hireable)
location = try values.decodeIfPresent(String.self, forKey: .location)
name = try values.decodeIfPresent(String.self, forKey: .name)
}
}

View file

@ -0,0 +1,30 @@
//
// UserAPI.swift
// GithubAPI
//
// Created by Serhii Londar on 1/6/18.
//
import Foundation
import BaseAPI
public class UserAPI: GithubAPI {
public func getUser(completion: @escaping(UserResponse?, Error?) -> Void) {
self.get(path: "/user", completion: completion)
}
public func updateUser(user: UpdateUser, completion: @escaping(UserResponse?, Error?) -> Void) {
let data = try? JSONEncoder().encode(user)
self.patch(path: "/user", body: data, completion: completion)
}
public func getUser(username: String, completion: @escaping(OtherUserResponse?, Error?) -> Void) {
let encodedUsername = username.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlPathAllowed)!
self.get(path: "/users/\(encodedUsername)", completion: completion)
}
public func getAllUsers(since: String, completion: @escaping([AllUsersResponse]?, Error?) -> Void) {
super.get(path: "/users?since=\(since)", completion: completion)
}
}

19
Pods/GithubAPI/LICENSE generated Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2018 serhii-londar <serhii.londar@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

171
Pods/GithubAPI/README.md generated Normal file
View file

@ -0,0 +1,171 @@
# GithubAPI
[![CI Status](http://img.shields.io/travis/serhii-londar/GithubAPI.svg?style=flat)](https://travis-ci.org/serhii-londar/GithubAPI)
[![Version](https://img.shields.io/cocoapods/v/GithubAPI.svg?style=flat)](http://cocoapods.org/pods/GithubAPI)
[![License](https://img.shields.io/cocoapods/l/GithubAPI.svg?style=flat)](http://cocoapods.org/pods/GithubAPI)
[![Platform](https://img.shields.io/cocoapods/p/GithubAPI.svg?style=flat)](http://cocoapods.org/pods/GithubAPI)
Swift implementation of Github REST api v3. Library support swift 4.0. Work is in progress.
Currently supported:
- [x] [Issues API](https://developer.github.com/v3/issues/).
- [x] [Activity API(Notification)](https://developer.github.com/v3/activity/notifications/).
- [x] [Repositories API](https://developer.github.com/v3/repos/).
- [x] [Search API](https://developer.github.com/v3/search/).
- [x] [User API](https://developer.github.com/v3/users/).
TODO:
- [ ] [Activity API (Events, Feeds, Starring, Watching)](https://developer.github.com/v3/activity/).
- [ ] [Organizations API](https://developer.github.com/v3/orgs/).
- [ ] [Projects API](https://developer.github.com/v3/projects/).
- [ ] [Pull Requests API](https://developer.github.com/v3/pulls/).
- [ ] [Reactions API](https://developer.github.com/v3/reactions/).
- [ ] [Repositories API](https://developer.github.com/v3/repos/).
- [ ] [Users API (Emails, Followers, Public Keys, GPG Keys, Block Another User)](https://developer.github.com/v3/users/).
- [ ] Documentation.
## Example Usage
### Authentication
#### Basic Authentication
This lib support Basic Authentication with login/password:
```swift
let authentication = BasicAuthentication(username: "username", password: "password")
UserAPI(authentication: authentication).getUser { (response, error) in
if let response = response {
print(response)
} else {
print(error ?? "")
}
}
```
#### OAuth2 Token (sent in a header)
If you generate personal access token or receive access token from OAuth2, you can use it with AccessTokenAuthentication:
```swift
let authentication = AccessTokenAuthentication(access_token: "token")
UserAPI(authentication: authentication).getUser(username: "serhii-londar") { (response, error) in
if let response = response {
print(response)
} else {
print(error ?? "")
}
}
```
#### OAuth2 Token (sent as a parameter)
If you generate personal access token or receive access token from OAuth2, you can use it in next way:
```swift
let authentication = TokenAuthentication(token: "token")
UserAPI(authentication: authentication).getAllUsers(since: "1") { (reposne, error) in
if let response = response {
print(response)
} else {
print(error ?? "")
}
}
```
### Issues API
#### Create Issue:
```swift
let issue = Issue(title: "New Issue")
IssuesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).createIssue(owner: "owner", repository: "repository", issue: issue) { (response, error) in
if let response = response {
} else {
print(error ?? "")
}
}
```
#### Update Issue:
```swift
let issue = Issue(title: "Updated Issue")
IssuesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).updateIssue(owner: "owner", repository: "repository", number: number, issue: issue) { (response, error) in
if let response = response {
} else {
print(error ?? "")
}
}
```
### Repositories API
#### Get list of all repositories of user:
```swift
RepositoriesAPI(authentication: AccessTokenAuthentication(access_token: "access_token")).repositories(user: "user", type: .all) { (response, error) in
if let response = response {
} else {
print(error ?? "")
}
}
```
### Search API
#### Seart all repositories which contains qwer in name:
```swift
SearchAPI().searchRepositories(q: "qwer", page: 1, per_page: 100) { (response, error) in
if let response = response {
} else {
print(error ?? "")
}
}
```
## Example Application
To run the example project, clone the repo, and run `pod install` from the Example directory first.
Example project contains example app with list of all user's github notification.
<p align="center">
<img src="./Screenshots/main_screen.png" width="350"/>
</p>
## Requirements
* Xcode 9 or later
* iOS 9.0 or later
* macOS 10.12 or later
* Ubuntu 16.04 or later
* Swift 4.0 or later
## Installation
GithubAPI is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'GithubAPI'
```
## Author
Serhii Londar, serhii.londar@gmail.com
## License
GithubAPI is available under the MIT license. See the LICENSE file for more info.