Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab v4 #35

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.3
osx_image: xcode10
sudo: false
env:
global:
Expand All @@ -8,13 +8,13 @@ env:
- FASTLANE_LANE=ci_commit
matrix:
include:
- osx_image: xcode8.3
- osx_image: xcode10
env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default
- osx_image: xcode8.3
- osx_image: xcode10
env: FASTLANE_ENV=ios93
- osx_image: xcode8.3
- osx_image: xcode10
env: FASTLANE_ENV=tvos92
- osx_image: xcode8.3
- osx_image: xcode10
env: FASTLANE_ENV=osx
before_install:
- make install
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "nerdishbynature/RequestKit" ~>2.0
github "nerdishbynature/RequestKit" "xcode-10"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "nerdishbynature/RequestKit" "2.0.2"
github "nerdishbynature/RequestKit" "2822fe0126d80377375b9cfde1c29198e0d3e7af"
117 changes: 20 additions & 97 deletions TanukiKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
287 changes: 0 additions & 287 deletions TanukiKit/Commit.swift

This file was deleted.

10 changes: 5 additions & 5 deletions TanukiKit/Configuration.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Foundation
import RequestKit

let gitlabBaseURL = "https://gitlab.com/api/v3/"
let gitlabWebURL = "https://gitlab.com/"
public let GitlabBaseURL = "https://gitlab.com/api/v4/"
public let GitlabWebURL = "https://gitlab.com/"

public struct TokenConfiguration: Configuration {
public var apiEndpoint: String
public var accessToken: String?
public let errorDomain = TanukiKitErrorDomain

public init(_ token: String? = nil, url: String = gitlabBaseURL) {
public init(_ token: String? = nil, url: String = GitlabBaseURL) {
apiEndpoint = url
accessToken = token
}
Expand All @@ -20,7 +20,7 @@ public struct PrivateTokenConfiguration: Configuration {
public var accessToken: String?
public let errorDomain = TanukiKitErrorDomain

public init(_ token: String? = nil, url: String = gitlabBaseURL) {
public init(_ token: String? = nil, url: String = GitlabBaseURL) {
apiEndpoint = url
accessToken = token
}
Expand All @@ -39,7 +39,7 @@ public struct OAuthConfiguration: Configuration {
public let webEndpoint: String
public let errorDomain = TanukiKitErrorDomain

public init(_ url: String = gitlabBaseURL, webURL: String = gitlabWebURL,
public init(_ url: String = GitlabBaseURL, webURL: String = GitlabWebURL,
token: String, secret: String, redirectURI: String) {
apiEndpoint = url
webEndpoint = webURL
Expand Down
18 changes: 12 additions & 6 deletions TanukiKit/Keys.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import Foundation
import RequestKit

// MARK: Model

@objc open class PublicKeyResponse: NSObject, Codable {
open var key: String = ""
open var title: String = ""
open var id: Int = 0
}

// MARK: request

public extension TanukiKit {
public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: @escaping (_ response:Response<String>) -> Void) -> URLSessionDataTaskProtocol? {
public func postPublicKey(_ session: RequestKitURLSession = URLSession.shared, publicKey: String, title: String, completion: @escaping (_ response:Response<PublicKeyResponse>) -> Void) -> URLSessionDataTaskProtocol? {
let router = PublicKeyRouter.postPublicKey(publicKey, title, configuration)
return router.loadJSON(session, expectedResultType: [String: AnyObject].self) { json, error in
return router.load(session, expectedResultType: PublicKeyResponse.self) { publicKey, error in
if let error = error {
completion(Response.failure(error))
} else {
if let _ = json {
completion(Response.success(publicKey))
}
} else if let publicKey = publicKey {
completion(Response.success(publicKey))
}
}
}
Expand Down
Loading