Created
March 12, 2018 08:16
-
-
Save madcato/57426b3abdf65192f978c4c9d9811b00 to your computer and use it in GitHub Desktop.
Base classes to develop a network API service client. Use as a template.
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
class HttpRequest { | |
func post() { | |
} | |
func get() { | |
} | |
} | |
class HttpAPI { | |
var request: HttpRequest | |
required init(_ request: HttpRequest) { | |
self.request = request | |
} | |
} | |
class Service { | |
var api: HttpAPI | |
required init(_ api: HttpAPI) { | |
self.api = api | |
} | |
} | |
class ServiceFactory { | |
func sampleBuilder() -> Service { | |
let request = HttpRequest() | |
let api = HttpAPI(request) | |
let service = Service(api) | |
return service | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment