Last active
February 2, 2023 00:39
-
-
Save catalinaturlea/1430433f85d5405e15e6 to your computer and use it in GitHub Desktop.
AlamofireWrapper - redefining enums
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @objc public enum RequestMethod: NSInteger { | |
| case OPTIONS = 0, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT | |
| } | |
| @objc public enum RequestParameterEncoding: NSInteger { | |
| case URL, URLEncodedInURL, JSON | |
| } | |
| public class AlamofireWrapper: NSObject { | |
| // ..... | |
| // Maps the custom RequestMethod enum values to the Alamofire.Method values | |
| private class func translateMethod(method: RequestMethod) -> Alamofire.Method { | |
| switch method { | |
| case .GET: | |
| return .GET | |
| case .POST: | |
| return .POST | |
| case .DELETE: | |
| return .DELETE | |
| case .HEAD: | |
| return .HEAD | |
| case .PUT: | |
| return .PUT | |
| case .PATCH: | |
| return .PATCH | |
| case .TRACE: | |
| return .TRACE | |
| case .CONNECT: | |
| return .CONNECT | |
| case .OPTIONS: | |
| return .OPTIONS | |
| } | |
| } | |
| // Maps the custom RequestParameterEncoding enum values to the Alamofire.ParameterEncoding values | |
| private class func translateEncoding(encoding: RequestParameterEncoding) -> Alamofire.ParameterEncoding { | |
| switch encoding { | |
| case .JSON: | |
| return .JSON | |
| case .URLEncodedInURL: | |
| return .URLEncodedInURL | |
| case .URL: | |
| return .URL | |
| } | |
| } | |
| // ..... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment