5 // Created by phimage on 05/11/16.
6 // Copyright © 2016 Dongri Jin. All rights reserved.
11 extension OAuthSwift {
12 // swiftlint:disable:next type_name
13 public typealias Obj_FailureHandler = (_ error: Error) -> Void
16 extension OAuth1Swift {
18 open func objc_authorize(withCallbackURL urlString: String, success: @escaping TokenSuccessHandler, failure: Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
19 guard let url = URL(string: urlString) else {
20 failure?(OAuthSwiftError.encodingError(urlString: urlString))
23 return authorize(withCallbackURL: url, success: success, failure: failure)
28 extension OAuth2Swift {
30 open func objc_authorize(withCallbackURL urlString: String, scope: String, state: String, parameters: Parameters = [:], headers: OAuthSwift.Headers? = nil, success: @escaping TokenSuccessHandler, failure: Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
31 guard let url = URL(string: urlString) else {
32 failure?(OAuthSwiftError.encodingError(urlString: urlString))
35 return authorize(withCallbackURL: url, scope: scope, state: state, parameters: parameters, headers: headers, success: success, failure: failure)
38 open func objc_renewAccessToken(withRefreshToken refreshToken: String, headers: OAuthSwift.Headers? = nil, success: @escaping TokenSuccessHandler, failure: Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
39 return renewAccessToken(withRefreshToken: refreshToken, headers: headers, success: success, failure: failure)
44 extension OAuthSwiftHTTPRequest {
45 // swiftlint:disable:next type_name
46 public typealias Obj_FailureHandler = (_ error: Error) -> Void
49 extension OAuthSwiftClient {
51 open func objc_request(_ urlString: String, method: OAuthSwiftHTTPRequest.Method, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, body: Data? = nil, checkTokenExpiration: Bool = true, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
52 return request(urlString, method: method, parameters: parameters, headers: headers, body: body, checkTokenExpiration: checkTokenExpiration, success: success, failure: failure)
55 open func get(_ urlString: String, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
56 return self.request(urlString, method: .GET, parameters: parameters, headers: headers, success: success, failure: failure)
59 open func post(_ urlString: String, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, body: Data? = nil, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
60 return self.request(urlString, method: .POST, parameters: parameters, headers: headers, body: body, success: success, failure: failure)
63 open func put(_ urlString: String, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, body: Data? = nil, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
64 return self.request(urlString, method: .PUT, parameters: parameters, headers: headers, body: body, success: success, failure: failure)
67 open func delete(_ urlString: String, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
68 return self.request(urlString, method: .DELETE, parameters: parameters, headers: headers, success: success, failure: failure)
71 open func patch(_ urlString: String, parameters: OAuthSwift.Parameters = [:], headers: OAuthSwift.Headers? = nil, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.Obj_FailureHandler?) -> OAuthSwiftRequestHandle? {
72 return self.request(urlString, method: .PATCH, parameters: parameters, headers: headers, success: success, failure: failure)