Skip to content

Instantly share code, notes, and snippets.

@serhatsezer
Last active October 18, 2017 13:52
Show Gist options
  • Save serhatsezer/8fa5c68a8f72cd6514bdd9962258f2eb to your computer and use it in GitHub Desktop.
Save serhatsezer/8fa5c68a8f72cd6514bdd9962258f2eb to your computer and use it in GitHub Desktop.
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