xtool.git
Publicgit clone https://git.maproj.org/xtool.gitxtool.git / Sources / XKit / GrandSlam / Requests / GrandSlamRequest.swift
GrandSlamRequest.swift35 lines · 766 BRaw
| 1 | // |
| 2 | // GrandSlamRequest.swift |
| 3 | // XKit |
| 4 | // |
| 5 | // Created by Kabir Oberai on 19/11/19. |
| 6 | // Copyright © 2019 Kabir Oberai. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | import Foundation |
| 10 | |
| 11 | enum GrandSlamMethod { |
| 12 | case get |
| 13 | case post([String: Any]) |
| 14 | |
| 15 | var httpMethod: HTTPRequest.Method { |
| 16 | switch self { |
| 17 | case .get: return .get |
| 18 | case .post: return .post |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | protocol GrandSlamDataDecoder { |
| 24 | associatedtype Value |
| 25 | static func decode(data: Data) throws -> Value |
| 26 | } |
| 27 | |
| 28 | protocol GrandSlamRequest: Sendable { |
| 29 | associatedtype Decoder: GrandSlamDataDecoder |
| 30 | |
| 31 | static var endpoint: GrandSlamEndpoint { get } |
| 32 | |
| 33 | func configure(request: inout HTTPRequest, anisetteData: AnisetteData) |
| 34 | func method(anisetteData: AnisetteData) -> GrandSlamMethod |
| 35 | } |