Created
June 15, 2020 11:48
-
-
Save omochi/72f7f71a9c9aed3a7ca481c78f98fe6d 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
import Foundation | |
enum HTTPMethod { | |
case get, post, patch | |
} | |
protocol SampleRequest { | |
var method: HTTPMethod { get } | |
var path: String { get } | |
var parameters: Any? { get } | |
} | |
struct InstallationPostRequest: SampleRequest { | |
static var path: String { "/installation" } | |
var token: String | |
var method: HTTPMethod { .post } | |
var path: String { Self.path } | |
var parameters: Any? { | |
return ["token": token] | |
} | |
init(token: String) { | |
self.token = token | |
} | |
} | |
struct InstallationPatchRequest: SampleRequest { | |
var id: String | |
var token: String | |
var method: HTTPMethod { .patch } | |
var path: String { InstallationPostRequest.path } | |
var parameters: Any? { | |
return ["id": id, | |
"token": token] | |
} | |
init(id: String, token: String) { | |
self.id = id | |
self.token = token | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment