diff --git a/Sources/BraintreeCore/BTGraphQLHTTP.swift b/Sources/BraintreeCore/BTGraphQLHTTP.swift index fc3d433c51..aebfbc5cd8 100644 --- a/Sources/BraintreeCore/BTGraphQLHTTP.swift +++ b/Sources/BraintreeCore/BTGraphQLHTTP.swift @@ -10,35 +10,19 @@ class BTGraphQLHTTP: BTHTTP { // MARK: - Overrides - override func get(_ path: String, completion: @escaping RequestCompletion) { + override func get(_ path: String, parameters: [String: Any]? = nil, shouldCache: Bool = false, completion: @escaping RequestCompletion) { NSException(name: exceptionName, reason: "GET is unsupported").raise() } - override func get(_ path: String, parameters: [String: Any]? = nil, completion: RequestCompletion?) { - NSException(name: exceptionName, reason: "GET is unsupported").raise() - } - - override func post(_ path: String, completion: @escaping RequestCompletion) { - httpRequest(method: "POST", parameters: nil, completion: completion) - } - override func post(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { httpRequest(method: "POST", parameters: parameters, completion: completion) } - override func put(_ path: String, completion: @escaping RequestCompletion) { + override func put(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { NSException(name: exceptionName, reason: "PUT is unsupported").raise() } - override func put(_ path: String, parameters: [String: Any]? = nil, completion: RequestCompletion?) { - NSException(name: exceptionName, reason: "PUT is unsupported").raise() - } - - override func delete(_ path: String, completion: @escaping RequestCompletion) { - NSException(name: exceptionName, reason: "DELETE is unsupported").raise() - } - - override func delete(_ path: String, parameters: [String: Any]? = nil, completion: RequestCompletion?) { + override func delete(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { NSException(name: exceptionName, reason: "DELETE is unsupported").raise() } diff --git a/Sources/BraintreeCore/BTHTTP.swift b/Sources/BraintreeCore/BTHTTP.swift index 600c5d5930..e134410ea6 100644 --- a/Sources/BraintreeCore/BTHTTP.swift +++ b/Sources/BraintreeCore/BTHTTP.swift @@ -99,11 +99,7 @@ class BTHTTP: NSObject, NSCopying, URLSessionDelegate { // MARK: - HTTP Methods - func get(_ path: String, completion: @escaping RequestCompletion) { - get(path, parameters: nil, completion: completion) - } - - func get(_ path: String, parameters: [String: Any]? = nil, shouldCache: Bool, completion: RequestCompletion?) { + func get(_ path: String, parameters: [String: Any]? = nil, shouldCache: Bool = false, completion: @escaping RequestCompletion) { if shouldCache { httpRequestWithCaching(method: "GET", path: path, parameters: parameters, completion: completion) } else { @@ -111,14 +107,6 @@ class BTHTTP: NSObject, NSCopying, URLSessionDelegate { } } - func get(_ path: String, parameters: [String: Any]? = nil, completion: RequestCompletion?) { - httpRequest(method: "GET", path: path, parameters: parameters, completion: completion) - } - - func post(_ path: String, completion: @escaping RequestCompletion) { - post(path, parameters: nil, completion: completion) - } - // TODO: - Remove when all POST bodies use Codable, instead of BTJSON/raw dictionaries func post(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { httpRequest(method: "POST", path: path, parameters: parameters, completion: completion) @@ -133,18 +121,10 @@ class BTHTTP: NSObject, NSCopying, URLSessionDelegate { } } - func put(_ path: String, completion: @escaping RequestCompletion) { - put(path, parameters: nil, completion: completion) - } - func put(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { httpRequest(method: "PUT", path: path, parameters: parameters, completion: completion) } - func delete(_ path: String, completion: @escaping RequestCompletion) { - delete(path, parameters: nil, completion: completion) - } - func delete(_ path: String, parameters: [String: Any]? = nil, completion: @escaping RequestCompletion) { httpRequest(method: "DELETE", path: path, parameters: parameters, completion: completion) } diff --git a/UnitTests/BraintreeTestShared/FakeHTTP.swift b/UnitTests/BraintreeTestShared/FakeHTTP.swift index a2c9388caa..33b978ba74 100644 --- a/UnitTests/BraintreeTestShared/FakeHTTP.swift +++ b/UnitTests/BraintreeTestShared/FakeHTTP.swift @@ -34,28 +34,6 @@ import Foundation stubEndpoint = endpoint cannedError = error } - - public override func get(_ path: String, parameters: [String: Any]? = nil, completion: ((BTJSON?, HTTPURLResponse?, Error?) -> Void)? = nil) { - GETRequestCount += 1 - lastRequestEndpoint = path - lastRequestParameters = parameters - lastRequestMethod = "GET" - - if cannedError != nil { - dispatchQueue.async { - completion?(nil, nil, self.cannedError) - } - } else { - let httpResponse = HTTPURLResponse(url: URL(string: path)!, statusCode: cannedStatusCode, httpVersion: nil, headerFields: nil) - dispatchQueue.async { - if path.contains("v1/configuration") { - completion?(self.cannedConfiguration, httpResponse, nil) - } else { - completion?(self.cannedResponse, httpResponse, nil) - } - } - } - } public override func get(_ path: String, parameters: [String: Any]? = nil, shouldCache: Bool, completion: BTHTTP.RequestCompletion?) { GETRequestCount += 1