Last active
October 18, 2017 13:52
-
-
Save serhatsezer/8fa5c68a8f72cd6514bdd9962258f2eb to your computer and use it in GitHub Desktop.
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
| public enum SSError { | |
| case error(description: String) | |
| case internetConnectionError | |
| } | |
| public protocol SSRequestRepresentable { | |
| typealias RequestParameters = [String: Any] | |
| typealias JSONBody = [String: Any] | |
| var baseURL: URL { get } | |
| var parameters: RequestParameters { get } | |
| var bodyData: JSONBody { get } | |
| } | |
| public protocol SSResponseRepresentable { | |
| typealias JSON = [String: Any] | |
| var response: JSON { get set } | |
| } | |
| fileprivate struct Response: SSResponseRepresentable { | |
| var result: SSResponseRepresentable.JSON = ["users": ["id": 1232, "name": "Serhat", "email": "[email protected]"]] | |
| } | |
| public struct SSProvider<T: SSRequestRepresentable> { | |
| func request(_ provider: T, _ completion: (_ data: SSResponseRepresentable?, _ error: SSError?) -> ()) { | |
| let stubResponse = Response() | |
| completion(stubResponse, nil) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment