@@ -31,7 +31,7 @@ public final class APIClient {
31
31
private let domainUrl : String
32
32
private let baseUrl : String
33
33
34
- enum HttpMethod : String {
34
+ enum Method : String {
35
35
case get, post, patch, put, delete
36
36
}
37
37
@@ -80,17 +80,17 @@ public final class APIClient {
80
80
/// Sends a request to the API.
81
81
/// - Parameters:
82
82
/// - path: The path for the request.
83
- /// - httpMethod : The HTTP method to use for the request.
83
+ /// - method : The HTTP method to use for the request.
84
84
/// - basic: Whether to include basic authorization.
85
- /// - httpBody : The HTTP body to include in the request.
85
+ /// - body : The HTTP body to include in the request.
86
86
/// - Returns: A tuple containing the data and the HTTP response.
87
87
/// - Throws: `VRCKitError` if an error occurs during the request.
88
88
func request(
89
89
path: String ,
90
- httpMethod : HttpMethod ,
90
+ method : Method ,
91
91
basic: Bool = false ,
92
92
queryItems: [ URLQueryItem ] = [ ] ,
93
- httpBody : Data ? = nil
93
+ body : Data ? = nil
94
94
) async throws -> HTTPResponse {
95
95
guard var urlComponents = URLComponents ( string: " \( baseUrl) / \( path) " ) else {
96
96
throw VRCKitError . urlError
@@ -102,7 +102,7 @@ public final class APIClient {
102
102
throw VRCKitError . urlError
103
103
}
104
104
var request = URLRequest ( url: url)
105
- request. httpMethod = httpMethod . description
105
+ request. httpMethod = method . description
106
106
107
107
// Add authorization header if required.
108
108
if basic, let username = username, let password = password {
@@ -114,9 +114,9 @@ public final class APIClient {
114
114
request. allHTTPHeaderFields = HTTPCookie . requestHeaderFields ( with: cookies)
115
115
116
116
// Add HTTP body and content type if body is provided.
117
- if let httpBody = httpBody {
117
+ if let body = body {
118
118
request. addValue ( ContentType . json. rawValue, forHTTPHeaderField: " Content-Type " )
119
- request. httpBody = httpBody
119
+ request. httpBody = body
120
120
}
121
121
122
122
let ( data, response) = try await URLSession . shared. data ( for: request)
@@ -128,7 +128,7 @@ public final class APIClient {
128
128
}
129
129
130
130
@available ( macOS 12 . 0 , iOS 15 . 0 , watchOS 8 . 0 , tvOS 15 . 0 , * )
131
- extension APIClient . HttpMethod : CustomStringConvertible {
131
+ extension APIClient . Method : CustomStringConvertible {
132
132
var description : String {
133
133
self . rawValue. uppercased ( )
134
134
}
0 commit comments