Skip to content

Commit

Permalink
Rename request method to fetch & introduce send method without response
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Dec 10, 2024
1 parent 525abfd commit 71f869d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Sources/HandySwift/Types/RESTClient.swift
Original file line number Diff line number Diff line change
@@ -125,15 +125,26 @@ public final class RESTClient: Sendable {
self.errorBodyToMessage = errorBodyToMessage
}

public func requestObject<ResponseBodyType: Decodable>(
public func send(
method: HTTPMethod,
path: String,
body: Body? = nil,
extraHeaders: [String: String] = [:],
extraQueryItems: [URLQueryItem] = [],
errorContext: String? = nil
) async throws(RequestError) {
_ = try await self.fetchData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)
}

public func fetchObject<ResponseBodyType: Decodable>(
method: HTTPMethod,
path: String,
body: Body? = nil,
extraHeaders: [String: String] = [:],
extraQueryItems: [URLQueryItem] = [],
errorContext: String? = nil
) async throws(RequestError) -> ResponseBodyType {
let responseData = try await self.requestData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)
let responseData = try await self.fetchData(method: method, path: path, body: body, extraHeaders: extraHeaders, extraQueryItems: extraQueryItems)

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

@discardableResult
public func requestData(
public func fetchData(
method: HTTPMethod,
path: String,
body: Body? = nil,

0 comments on commit 71f869d

Please sign in to comment.