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

17
Podfile Normal file
View file

@ -0,0 +1,17 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'repo-browser' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for repo-browser
pod 'GithubAPI'
pod 'FontAwesome.swift', '~> 1.7'
target 'repo-browserTests' do
inherit! :search_paths
# Pods for testing
end
end

24
Podfile.lock Normal file
View file

@ -0,0 +1,24 @@
PODS:
- BaseAPI (0.1.5)
- FontAwesome.swift (1.7.1)
- GithubAPI (0.0.6):
- BaseAPI
DEPENDENCIES:
- FontAwesome.swift (~> 1.7)
- GithubAPI
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- BaseAPI
- FontAwesome.swift
- GithubAPI
SPEC CHECKSUMS:
BaseAPI: 9248feed65933cd20283514e7a9917ecba1b69c0
FontAwesome.swift: 8d9792fa2d2347055da35bd97752b3960bd75952
GithubAPI: bc5bfd90489f5138a8d1e00003b18abe31579eb0
PODFILE CHECKSUM: eef7fefc5996c7f6fe77a452e2eef6c7a1ec6426
COCOAPODS: 1.7.1

151
Pods/BaseAPI/BaseAPI/Classes/BaseAPI.swift generated Normal file
View file

@ -0,0 +1,151 @@
//
// BaseAPI.swift
// BaseAPI
//
// Created by Serhii Londar on 12/8/17.
//
import Foundation
public typealias BaseAPICompletion = (Data?, URLResponse?, Error?) -> Swift.Void
public typealias BaseAPIResult = SynchronousDataTaskResult
open class BaseAPI {
var session: URLSession
public init() {
self.session = URLSession(configuration: URLSessionConfiguration.default)
}
public init(session: URLSession) {
self.session = session
}
public func get(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .GET, parameters: parameters, headers: headers, body: nil)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func get(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil) -> BaseAPIResult {
let request = Request(url: url, method: .GET, parameters: parameters, headers: headers, body: nil)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
public func head(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .HEAD, parameters: parameters, headers: headers, body: nil)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func head(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil) -> BaseAPIResult {
let request = Request(url: url, method: .HEAD, parameters: parameters, headers: headers, body: nil)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
public func post(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .POST, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func post(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> BaseAPIResult {
let request = Request(url: url, method: .POST, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
public func patch(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .PATCH, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func patch(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> BaseAPIResult {
let request = Request(url: url, method: .PATCH, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
public func put(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .PUT, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func put(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data?) -> BaseAPIResult {
let request = Request(url: url, method: .PUT, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
public func delete(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data? = nil, completion: @escaping BaseAPICompletion) {
let request = Request(url: url, method: .DELETE, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
let task = session.dataTask(with: urlRequest, completionHandler: completion)
task.resume()
} else {
completion(nil, nil, buildRequest.error)
}
}
public func delete(url: String, parameters: [String : String]? = nil, headers: [String: String]? = nil, body: Data? = nil) -> BaseAPIResult {
let request = Request(url: url, method: .DELETE, parameters: parameters, headers: headers, body: body)
let buildRequest = request.request()
if let urlRequest = buildRequest.request {
return session.synchronousDataTask(request: urlRequest)
} else {
return (nil, nil, buildRequest.error)
}
}
}

View file

@ -0,0 +1,18 @@
//
// File.swift
// BaseAPI
//
// Created by Serhii Londar on 1/5/18.
//
import Foundation
extension CharacterSet {
static func BaseAPI_URLQueryAllowedCharacterSet() -> CharacterSet {
let generalDelimitersToEncode = ":#[]@"
let subDelimitersToEncode = "!$&'()*+,;="
var allowedCharacterSet = CharacterSet.urlQueryAllowed
allowedCharacterSet.remove(charactersIn: generalDelimitersToEncode + subDelimitersToEncode)
return allowedCharacterSet
}
}

View file

@ -0,0 +1,12 @@
//
// String.swift
// BaseAPI
//
// Created by Serhii Londar on 1/5/18.
//
import Foundation
extension String: Error {
}

View file

@ -0,0 +1,55 @@
//
// URLSession.swift
// BaseAPI
//
// Created by Serhii Londar on 8/22/17.
//
//
import Foundation
import Dispatch
public typealias SynchronousDataTaskResult = (data: Data?, response: URLResponse?, error: Error?)
extension URLSession {
public func synchronousDataTask(request: URLRequest) -> SynchronousDataTaskResult {
var data: Data?
var response: URLResponse?
var error: Error?
let semaphore = DispatchSemaphore(value: 0)
let dataTask = self.dataTask(with: request) { (rData, rResponse, eError) in
data = rData
response = rResponse
error = eError
semaphore.signal()
}
dataTask.resume()
_ = semaphore.wait(timeout: .distantFuture)
return (data, response, error)
}
public func synchronousDataTask(url: URL) -> SynchronousDataTaskResult {
var data: Data?
var response: URLResponse?
var error: Error?
let semaphore = DispatchSemaphore(value: 0)
let dataTask = self.dataTask(with: url) {
data = $0
response = $1
error = $2
semaphore.signal()
}
dataTask.resume()
_ = semaphore.wait(timeout: .distantFuture)
return (data, response, error)
}
}

View file

@ -0,0 +1,59 @@
//
// Request.swift
// BaseAPI
//
// Created by Serhii Londar on 1/5/18.
//
import Foundation
public class Request {
public var url: String
public var method: RequestMethod
public var parameters: [String : String]?
public var headers: [String : String]?
public var body: Data?
public init(url: String, method: RequestMethod, parameters: [String : String]? = nil, headers: [String : String]? = nil, body: Data? = nil) {
self.url = url
self.method = method
self.parameters = parameters
self.headers = headers
self.body = body
}
public func request() -> (request: URLRequest?, error: Error?) {
let url = URL(string: self.urlWithParameters())
if let url = url {
var request = URLRequest(url: url)
if let headers = headers {
for headerKey in headers.keys {
request.addValue(headers[headerKey]!, forHTTPHeaderField: headerKey)
}
}
request.httpMethod = method.rawValue
request.httpBody = body
return (request, nil)
} else {
return (nil, "Unable to create URL")
}
}
func urlWithParameters() -> String {
var retUrl = url
if let parameters = parameters {
if parameters.count > 0 {
retUrl.append("?")
parameters.keys.forEach {
guard let value = parameters[$0] else { return }
let escapedValue = value.addingPercentEncoding(withAllowedCharacters: CharacterSet.BaseAPI_URLQueryAllowedCharacterSet())
if let escapedValue = escapedValue {
retUrl.append("\($0)=\(escapedValue)&")
}
}
retUrl.removeLast()
}
}
return retUrl
}
}

View file

@ -0,0 +1,29 @@
//
// RequestHeaderFields.swift
// BaseAPI
//
// Created by Serhii Londar on 1/5/18.
//
import Foundation
public enum RequestHeaderFields: String {
case acceptCharset = "Accept-Charset"
case acceptEncoding = "Accept-Encoding"
case acceptLanguage = "Accept-Language"
case authorization = "Authorization"
case expect = "Expect"
case from = "From"
case host = "Host"
case ifMatch = "If-Match"
case ifModifiedSince = "If-Modified-Since"
case ifNoneMatch = "If-None-Match"
case ifRange = "If-Range"
case ifUnmodifiedSince = "If-Unmodified-Since"
case maxForwards = "Max-Forwards"
case proxyAuthorization = "Proxy-Authorization"
case range = "Range"
case referer = "Referer"
case te = "TE"
case userAgent = "User-Agent"
}

View file

@ -0,0 +1,20 @@
//
// RequestMethod.swift
// BaseAPI
//
// Created by Serhii Londar on 1/5/18.
//
import Foundation
public enum RequestMethod: String {
case OPTIONS
case GET
case HEAD
case POST
case PATCH
case PUT
case DELETE
case TRACE
case CONNECT
}

19
Pods/BaseAPI/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.

31
Pods/BaseAPI/README.md generated Normal file
View file

@ -0,0 +1,31 @@
# BaseAPI
[![CI Status](http://img.shields.io/travis/serhii-londar/BaseAPI.svg?style=flat)](https://travis-ci.org/serhii-londar/BaseAPI)
[![Version](https://img.shields.io/cocoapods/v/BaseAPI.svg?style=flat)](http://cocoapods.org/pods/BaseAPI)
[![License](https://img.shields.io/cocoapods/l/BaseAPI.svg?style=flat)](http://cocoapods.org/pods/BaseAPI)
[![Platform](https://img.shields.io/cocoapods/p/BaseAPI.svg?style=flat)](http://cocoapods.org/pods/BaseAPI)
BaseAPI is a small Swift library which helps you to implement any REST API. The main goal is to simplify sending HTTP request and receiving response.
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
BaseAPI is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'BaseAPI'
```
## Author
serhii-londar, serhii.londar@gmail.com
## License
BaseAPI is available under the MIT license. See the LICENSE file for more info.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,257 @@
// FontAwesome.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
import CoreText
// MARK: - Public
/// A configuration namespace for FontAwesome.
public struct FontAwesomeConfig {
// Marked private to prevent initialization of this struct.
private init() { }
/// Taken from FontAwesome.io's Fixed Width Icon CSS.
public static let fontAspectRatio: CGFloat = 1.28571429
/// Whether Font Awesome Pro fonts should be used (not included).
///
/// To use Font Awesome Pro fonts, you should add these to your main project and
/// make sure they are added to the target and are included in the Info.plist file.
public static var usesProFonts: Bool = false
}
public enum FontAwesomeStyle: String {
case solid
/// WARNING: Font Awesome Free doesn't include a Light variant. Using this with Free will fallback to Regular.
case light
case regular
case brands
func fontName() -> String {
switch self {
case .solid:
return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Solid" : "FontAwesome5Free-Solid"
case .light:
return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Light" : "FontAwesome5Free-Regular"
case .regular:
return FontAwesomeConfig.usesProFonts ? "FontAwesome5Pro-Regular" : "FontAwesome5Free-Regular"
case .brands:
return "FontAwesome5Brands-Regular"
}
}
func fontFilename() -> String {
switch self {
case .solid:
return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Solid-900" : "Font Awesome 5 Free-Solid-900"
case .light:
return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Light-300" : "Font Awesome 5 Free-Regular-400"
case .regular:
return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro-Regular-400" : "Font Awesome 5 Free-Regular-400"
case .brands:
return "Font Awesome 5 Brands-Regular-400"
}
}
func fontFamilyName() -> String {
switch self {
case .brands:
return "Font Awesome 5 Brands"
case .regular,
.light,
.solid:
return FontAwesomeConfig.usesProFonts ? "Font Awesome 5 Pro" : "Font Awesome 5 Free"
}
}
}
/// A FontAwesome extension to UIFont.
public extension UIFont {
/// Get a UIFont object of FontAwesome.
///
/// - parameter ofSize: The preferred font size.
/// - returns: A UIFont object of FontAwesome.
class func fontAwesome(ofSize fontSize: CGFloat, style: FontAwesomeStyle) -> UIFont {
loadFontAwesome(ofStyle: style)
return UIFont(name: style.fontName(), size: fontSize)!
}
/// Loads the FontAwesome font in to memory.
/// This method should be called when setting icons without using code.
class func loadFontAwesome(ofStyle style: FontAwesomeStyle) {
if UIFont.fontNames(forFamilyName: style.fontFamilyName()).contains(style.fontName()) {
return
}
FontLoader.loadFont(style.fontFilename())
}
/// Get a UIFont object of FontAwesome for a given text style
///
/// - parameter forTextStyle: The preferred text style
/// - parameter style: FontAwesome font style
/// - returns: A UIFont object of FontAwesome
class func fontAwesome(forTextStyle textStyle: UIFont.TextStyle, style: FontAwesomeStyle) -> UIFont {
let userFont = UIFontDescriptor.preferredFontDescriptor(withTextStyle: textStyle)
let pointSize = userFont.pointSize
loadFontAwesome(ofStyle: style)
let awesomeFont = UIFont(name: style.fontName(), size: pointSize)!
if #available(iOS 11.0, *), #available(watchOSApplicationExtension 4.0, *), #available(tvOS 11.0, *) {
return UIFontMetrics.default.scaledFont(for: awesomeFont)
} else {
let scale = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body).pointSize / 17
return awesomeFont.withSize(scale * awesomeFont.pointSize)
}
}
}
/// A FontAwesome extension to String.
public extension String {
/// Get a FontAwesome icon string with the given icon name.
///
/// - parameter name: The preferred icon name.
/// - returns: A string that will appear as icon with FontAwesome.
static func fontAwesomeIcon(name: FontAwesome) -> String {
let toIndex = name.rawValue.index(name.rawValue.startIndex, offsetBy: 1)
return String(name.rawValue[name.rawValue.startIndex..<toIndex])
}
/// Get a FontAwesome icon string with the given CSS icon code. Icon code can be found here: http://fontawesome.io/icons/
///
/// - parameter code: The preferred icon name.
/// - returns: A string that will appear as icon with FontAwesome.
static func fontAwesomeIcon(code: String) -> String? {
guard let name = self.fontAwesome(code: code) else {
return nil
}
return self.fontAwesomeIcon(name: name)
}
/// Get a FontAwesome icon with the given CSS icon code. Icon code can be found here: http://fontawesome.io/icons/
///
/// - parameter code: The preferred icon name.
/// - returns: An internal corresponding FontAwesome code.
static func fontAwesome(code: String) -> FontAwesome? {
guard let raw = FontAwesomeIcons[code] else { return nil }
return FontAwesome(rawValue: raw)
}
}
/// A FontAwesome extension to UIImage.
public extension UIImage {
/// Get a FontAwesome image with the given icon name, text color, size and an optional background color.
///
/// - parameter name: The preferred icon name.
/// - parameter style: The font style. Either .solid, .regular or .brands.
/// - parameter textColor: The text color.
/// - parameter size: The image size.
/// - parameter backgroundColor: The background color (optional).
/// - returns: A string that will appear as icon with FontAwesome
static func fontAwesomeIcon(name: FontAwesome, style: FontAwesomeStyle, textColor: UIColor, size: CGSize, backgroundColor: UIColor = UIColor.clear, borderWidth: CGFloat = 0, borderColor: UIColor = UIColor.clear) -> UIImage {
// Prevent application crash when passing size where width or height is set equal to or less than zero, by clipping width and height to a minimum of 1 pixel.
var size = size
if size.width <= 0 { size.width = 1 }
if size.height <= 0 { size.height = 1 }
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = NSTextAlignment.center
let fontSize = min(size.width / FontAwesomeConfig.fontAspectRatio, size.height)
// stroke width expects a whole number percentage of the font size
let strokeWidth: CGFloat = fontSize == 0 ? 0 : (-100 * borderWidth / fontSize)
let attributedString = NSAttributedString(string: String.fontAwesomeIcon(name: name), attributes: [
NSAttributedString.Key.font: UIFont.fontAwesome(ofSize: fontSize, style: style),
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.backgroundColor: backgroundColor,
NSAttributedString.Key.paragraphStyle: paragraph,
NSAttributedString.Key.strokeWidth: strokeWidth,
NSAttributedString.Key.strokeColor: borderColor
])
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
attributedString.draw(in: CGRect(x: 0, y: (size.height - fontSize) / 2, width: size.width, height: fontSize))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image!
}
/// Get a FontAwesome image with the given icon css code, text color, size and an optional background color.
///
/// - parameter code: The preferred icon css code.
/// - parameter style: The font style. Either .solid, .regular or .brands.
/// - parameter textColor: The text color.
/// - parameter size: The image size.
/// - parameter backgroundColor: The background color (optional).
/// - returns: A string that will appear as icon with FontAwesome
static func fontAwesomeIcon(code: String, style: FontAwesomeStyle, textColor: UIColor, size: CGSize, backgroundColor: UIColor = UIColor.clear, borderWidth: CGFloat = 0, borderColor: UIColor = UIColor.clear) -> UIImage? {
guard let name = String.fontAwesome(code: code) else { return nil }
return fontAwesomeIcon(name: name, style: style, textColor: textColor, size: size, backgroundColor: backgroundColor, borderWidth: borderWidth, borderColor: borderColor)
}
}
// MARK: - Private
private class FontLoader {
class func loadFont(_ name: String) {
guard
let fontURL = URL.fontURL(for: name),
let data = try? Data(contentsOf: fontURL),
let provider = CGDataProvider(data: data as CFData),
let font = CGFont(provider)
else { return }
var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
let errorDescription: CFString = CFErrorCopyDescription(error!.takeUnretainedValue())
guard let nsError = error?.takeUnretainedValue() as AnyObject as? NSError else { return }
NSException(name: NSExceptionName.internalInconsistencyException, reason: errorDescription as String, userInfo: [NSUnderlyingErrorKey: nsError]).raise()
}
}
}
extension URL {
static func fontURL(for fontName: String) -> URL? {
let bundle = Bundle(for: FontLoader.self)
if let fontURL = bundle.url(forResource: fontName, withExtension: "otf") {
return fontURL
}
// If this framework is added using CocoaPods, resources is placed under a subdirectory
if let fontURL = bundle.url(forResource: fontName, withExtension: "otf", subdirectory: "FontAwesome.swift.bundle") {
return fontURL
}
return nil
}
}

View file

@ -0,0 +1,77 @@
// FontAwesomeBarButtonItem.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
@IBDesignable public class FontAwesomeBarButtonItem: UIBarButtonItem {
@IBInspectable public var isFontAwesomeCSSCode: Bool = true
@IBInspectable public var styleName: String = "Brands"
@IBInspectable public var size: CGFloat = 25.0
public override func awakeFromNib() {
super.awakeFromNib()
useFontAwesome()
}
public override func prepareForInterfaceBuilder() {
useFontAwesome()
}
private func useFontAwesome() {
updateText {
if let cssCode = title {
title = String.fontAwesomeIcon(code: cssCode)
}
}
updateFontAttributes { (state, font) in
let currentAttributes = titleTextAttributes(for: state) ?? [:]
var attributes = [NSAttributedString.Key: Any]()
currentAttributes.enumerated().forEach {
let currentAttribute = $0.element.key
attributes[currentAttribute] = $0.element.value
}
attributes[NSAttributedString.Key.font] = font
setTitleTextAttributes(attributes, for: state)
}
}
}
extension FontAwesomeBarButtonItem: FontAwesomeTextRepresentable {
var isTextCSSCode: Bool {
return isFontAwesomeCSSCode
}
var textSize: CGFloat {
return size
}
var fontStyle: FontAwesomeStyle {
return FontAwesomeStyle(rawValue: styleName) ?? .solid
}
static func supportedStates() -> [UIControl.State] {
return [.normal, .highlighted, .disabled]
}
}

View file

@ -0,0 +1,36 @@
// FontAwesomeExtension.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import Foundation
public extension FontAwesome {
/// Get a FontAwesome string from the given CSS icon code. Icon code can be found here: http://fontawesome.io/icons/
///
/// - parameter code: The preferred icon name.
/// - returns: FontAwesome icon.
static func fromCode(_ code: String) -> FontAwesome? {
guard let raw = FontAwesomeIcons[code], let icon = FontAwesome(rawValue: raw) else {
return nil
}
return icon
}
}

View file

@ -0,0 +1,56 @@
// FontAwesomeImageRepresentable.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
protocol FontAwesomeImageRepresentable: class {
typealias ImageConfig = (cssIconName: String, style: FontAwesomeStyle, color: UIColor?, backgroundColor: UIColor?)
var imageWidth: CGFloat { get }
var imageConfigs: [ImageConfig] { get }
func createImages(configurationHandler: (_ image: UIImage?, _ index: Int) -> Void)
}
extension FontAwesomeImageRepresentable {
func createImages(configurationHandler: (_ image: UIImage?, _ index: Int) -> Void) {
let imgSize = imageSizeForAspectRatio()
for (index, config) in imageConfigs.enumerated() {
let img = createImage(config: config, size: imgSize)
configurationHandler(img, index)
}
}
private func createImage(config: ImageConfig, size: CGSize) -> UIImage? {
return UIImage.fontAwesomeIcon(code: config.cssIconName,
style: config.style,
textColor: config.color ?? .black,
size: size,
backgroundColor: config.backgroundColor ?? .clear)
}
private func imageSizeForAspectRatio() -> CGSize {
return CGSize(width: imageWidth, height: imageWidth / FontAwesomeConfig.fontAspectRatio)
}
}

View file

@ -0,0 +1,60 @@
// FontAwesomeImageView.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
@IBDesignable public class FontAwesomeImageView: UIImageView {
@IBInspectable public var cssCode: String = "fa-font-awesome-flag"
@IBInspectable public var imageColor: UIColor = .black
@IBInspectable public var imageBackgroundColor: UIColor = .clear
@IBInspectable public var styleName: String = "Brands"
public override func awakeFromNib() {
super.awakeFromNib()
useFontAwesomeImage()
}
public override func prepareForInterfaceBuilder() {
useFontAwesomeImage()
}
private func useFontAwesomeImage() {
createImages { (img, _) in
image = img
}
}
}
extension FontAwesomeImageView: FontAwesomeImageRepresentable {
var imageWidth: CGFloat {
return frame.width
}
var imageConfigs: [ImageConfig] {
guard let style = FontAwesomeStyle(rawValue: styleName.lowercased()) else { return [] }
return [(cssCode, style, imageColor, imageBackgroundColor)]
}
}

View file

@ -0,0 +1,78 @@
// FontAwesomeSegmentedControl.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
@IBDesignable public class FontAwesomeSegmentedControl: UISegmentedControl {
@IBInspectable public var isFontAwesomeCSSCode: Bool = true
@IBInspectable public var styleName: String = "Brands"
@IBInspectable public var size: CGFloat = 22.0
public override func awakeFromNib() {
super.awakeFromNib()
useFontAwesome()
}
public override func prepareForInterfaceBuilder() {
useFontAwesome()
}
private func useFontAwesome() {
updateText {
for index in 0 ..< numberOfSegments {
if let cssCode = titleForSegment(at: index) {
setTitle(String.fontAwesomeIcon(code: cssCode), forSegmentAt: index)
}
}
}
updateFontAttributes { (state, font) in
var attributes = titleTextAttributes(for: state) ?? [:]
attributes[NSAttributedString.Key.font] = font
setTitleTextAttributes(attributes, for: state)
}
}
}
extension FontAwesomeSegmentedControl: FontAwesomeTextRepresentable {
var isTextCSSCode: Bool {
return isFontAwesomeCSSCode
}
var fontStyle: FontAwesomeStyle {
return FontAwesomeStyle(rawValue: styleName) ?? .solid
}
var textSize: CGFloat {
return size
}
static func supportedStates() -> [UIControl.State] {
if #available(iOS 9.0, *) {
return [.normal, .highlighted, .disabled, .focused, .selected, .application, .reserved]
} else {
return [.normal, .highlighted, .disabled, .selected, .application, .reserved]
}
}
}

View file

@ -0,0 +1,29 @@
// FontAwesomeStateRequirement.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
protocol FontAwesomeStateRequirement: class {
static func supportedStates() -> [UIControl.State]
}

View file

@ -0,0 +1,64 @@
// FontAwesomeTabBarItem.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
@IBDesignable public class FontAwesomeTabBarItem: UITabBarItem {
@IBInspectable public var iconName: String = "fa-font-awesome-flag"
@IBInspectable public var selectedIconName: String = "fa-font-awesome-flag"
@IBInspectable public var size: CGFloat = 38.0
@IBInspectable public var styleName: String = "Brands"
public override func awakeFromNib() {
super.awakeFromNib()
useFontAwesomeImage()
}
public override func prepareForInterfaceBuilder() {
useFontAwesomeImage()
}
private func useFontAwesomeImage() {
createImages { (img, index) in
if index == 0 {
image = img
} else {
selectedImage = img
}
}
}
}
extension FontAwesomeTabBarItem: FontAwesomeImageRepresentable {
var imageWidth: CGFloat {
return size
}
var imageConfigs: [ImageConfig] {
guard let style = FontAwesomeStyle(rawValue: styleName.lowercased()) else { return [] }
return [(iconName, style, nil, nil), (selectedIconName, style, nil, nil)]
}
}

View file

@ -0,0 +1,54 @@
// FontAwesomeTextRepresentable.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
protocol FontAwesomeTextRepresentable: FontAwesomeStateRequirement {
var textSize: CGFloat { get }
var isTextCSSCode: Bool { get }
var fontStyle: FontAwesomeStyle { get }
func updateText(_ updateTextBlock: () -> Void)
func updateFontAttributes(forStates stateBlock: (UIControl.State, UIFont) -> Void)
}
extension FontAwesomeTextRepresentable {
public func updateText(_ updateTextBlock: () -> Void) {
guard isTextCSSCode else {
return
}
updateTextBlock()
}
public func updateFontAttributes(forStates stateBlock: (UIControl.State, UIFont) -> Void) {
let states = type(of: self).supportedStates()
let font = UIFont.fontAwesome(ofSize: textSize, style: fontStyle)
for state in states {
stateBlock(state, font)
}
}
}

View file

@ -0,0 +1,75 @@
// FontAwesomeView.swift
//
// Copyright (c) 2014-present FontAwesome.swift contributors
//
// 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.
import UIKit
/// A view for FontAwesome icons.
@IBDesignable public class FontAwesomeView: UIView {
@IBInspectable
public var iconCode: String = "" {
didSet {
self.iconView.text = String.fontAwesomeIcon(code: iconCode)
}
}
@IBInspectable
public var styleName: String = "Brands"
private var iconView = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupViews()
}
override public func prepareForInterfaceBuilder() {
setupViews()
}
/// Add a UILabel subview containing FontAwesome icon
func setupViews() {
// Fits icon in the view
self.iconView.textAlignment = NSTextAlignment.center
self.iconView.text = String.fontAwesomeIcon(code: self.iconCode)
self.iconView.textColor = self.tintColor
self.addSubview(iconView)
}
override public func tintColorDidChange() {
self.iconView.textColor = self.tintColor
}
override public func layoutSubviews() {
super.layoutSubviews()
self.clipsToBounds = true
let size = bounds.size.width < bounds.size.height ? bounds.size.width : bounds.size.height
let style = FontAwesomeStyle(rawValue: styleName) ?? .solid
self.iconView.font = UIFont.fontAwesome(ofSize: size, style: style)
self.iconView.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: bounds.size.width, height: bounds.size.height))
}
}

19
Pods/FontAwesome.swift/LICENSE generated Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2014-present FontAwesome.swift contributors
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.

52
Pods/FontAwesome.swift/README.md generated Normal file
View file

@ -0,0 +1,52 @@
# FontAwesome.swift
[![Build Status](http://img.shields.io/travis/thii/FontAwesome.swift.svg?style=flat)](https://travis-ci.org/thii/FontAwesome.swift)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/FontAwesome.swift.svg)](https://img.shields.io/cocoapods/v/FontAwesome.swift.svg)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Platform](https://img.shields.io/cocoapods/p/FontAwesome.swift.svg?style=flat)](http://cocoadocs.org/docsets/FontAwesome.swift)
[![License](https://img.shields.io/cocoapods/l/FontAwesome.swift.svg)](https://raw.githubusercontent.com/thii/FontAwesome.swift/master/LICENSE)
Use Font Awesome in your Swift projects
To see the complete set of 3,978 icons in Font Awesome 5, please check the [FontAwesome.com](http://fontawesome.com/icons/) site.
## Examples
![](./.github/examples.png)
## Installation
### Carthage
github "thii/FontAwesome.swift"
### CocoaPods
pod 'FontAwesome.swift'
**Note**: If you install this using CocoaPods, the framework name will be
`FontAwesome_swift` (there is an underscore).
### Manually
- Drag and drop all `.otf` and `.swift` files into your project
## Requirements
iOS 8 or later.
## Development
To update this project to include all the latest icons from the new verison of
Font Awesome (replace `x.y.z` with the new font version):
bundle exec fastlane update_font version:x.y.z
To release a new version `x.y.z` (replace `x.y.z` with a real version number):
bundle exec fastlane release version:x.y.z
Since it will automatically make a new commit to bump version and push to CocoaPods
trunk, make sure you have write access to this repo and be one of the podspec owners.
If you are a maintainer but don't have these privilege yet, please let me know.
## License
- All font files licensed under [SIL OFL 1.1](http://scripts.sil.org/OFL)
- FontAwesome.swift licensed under [MIT](http://thi.mit-license.org/)

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.

24
Pods/Manifest.lock generated Normal file
View file

@ -0,0 +1,24 @@
PODS:
- BaseAPI (0.1.5)
- FontAwesome.swift (1.7.1)
- GithubAPI (0.0.6):
- BaseAPI
DEPENDENCIES:
- FontAwesome.swift (~> 1.7)
- GithubAPI
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- BaseAPI
- FontAwesome.swift
- GithubAPI
SPEC CHECKSUMS:
BaseAPI: 9248feed65933cd20283514e7a9917ecba1b69c0
FontAwesome.swift: 8d9792fa2d2347055da35bd97752b3960bd75952
GithubAPI: bc5bfd90489f5138a8d1e00003b18abe31579eb0
PODFILE CHECKSUM: eef7fefc5996c7f6fe77a452e2eef6c7a1ec6426
COCOAPODS: 1.7.1

1595
Pods/Pods.xcodeproj/project.pbxproj generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6D3AF0C6AF53B8F230647F79054EF73F"
BuildableName = "BaseAPI.framework"
BlueprintName = "BaseAPI"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4DC20DD2E50259D674257304EC016C93"
BuildableName = "FontAwesome.swift.bundle"
BlueprintName = "FontAwesome.swift-FontAwesome.swift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4DC20DD2E50259D674257304EC016C93"
BuildableName = "FontAwesome.swift.bundle"
BlueprintName = "FontAwesome.swift-FontAwesome.swift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BB240150692F32EC312F3CF346C8B9D1"
BuildableName = "FontAwesome_swift.framework"
BlueprintName = "FontAwesome.swift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BB240150692F32EC312F3CF346C8B9D1"
BuildableName = "FontAwesome_swift.framework"
BlueprintName = "FontAwesome.swift"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "46612857DE0B03605DCFF866695FF265"
BuildableName = "GithubAPI.framework"
BlueprintName = "GithubAPI"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1F23F2351DC311504812F672ADDDA30E"
BuildableName = "Pods_repo_browser.framework"
BlueprintName = "Pods-repo-browser"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1F23F2351DC311504812F672ADDDA30E"
BuildableName = "Pods_repo_browser.framework"
BlueprintName = "Pods-repo-browser"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "52A3A9E9E88D73EBB7A6F7550E196A91"
BuildableName = "Pods_repo_browserTests.framework"
BlueprintName = "Pods-repo-browserTests"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "52A3A9E9E88D73EBB7A6F7550E196A91"
BuildableName = "Pods_repo_browserTests.framework"
BlueprintName = "Pods-repo-browserTests"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View file

@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_BaseAPI : NSObject
@end
@implementation PodsDummy_BaseAPI
@end

View file

@ -0,0 +1,12 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif

Some files were not shown because too many files have changed in this diff Show more