Skip to content

Commit 71f869d

Browse files
committed
Rename request method to fetch & introduce send method without response
1 parent 525abfd commit 71f869d

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Sources/HandySwift/Types/RESTClient.swift

+14-4
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,26 @@ public final class RESTClient: Sendable {
125125
self.errorBodyToMessage = errorBodyToMessage
126126
}
127127

128-
public func requestObject<ResponseBodyType: Decodable>(
128+
public func send(
129+
method: HTTPMethod,
130+
path: String,
131+
body: Body? = nil,
132+
extraHeaders: [String: String] = [:],
133+
extraQueryItems: [URLQueryItem] = [],
134+
errorContext: String? = nil
135+
) async throws(RequestError) {
136+
_ = try await self.fetchData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)
137+
}
138+
139+
public func fetchObject<ResponseBodyType: Decodable>(
129140
method: HTTPMethod,
130141
path: String,
131142
body: Body? = nil,
132143
extraHeaders: [String: String] = [:],
133144
extraQueryItems: [URLQueryItem] = [],
134145
errorContext: String? = nil
135146
) async throws(RequestError) -> ResponseBodyType {
136-
let responseData = try await self.requestData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)
147+
let responseData = try await self.fetchData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)
137148

138149
do {
139150
return try self.jsonDecoder.decode(ResponseBodyType.self, from: responseData)
@@ -142,8 +153,7 @@ public final class RESTClient: Sendable {
142153
}
143154
}
144155

145-
@discardableResult
146-
public func requestData(
156+
public func fetchData(
147157
method: HTTPMethod,
148158
path: String,
149159
body: Body? = nil,

0 commit comments

Comments
 (0)