Skip to content

Commit 8b5149b

Browse files
committed
add function in all calls
1 parent 3fff713 commit 8b5149b

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Sources/SwiftAPIClient/APIClientCaller.swift

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ public extension APIClient {
148148
_ caller: APIClientCaller<Response, Value, AsyncThrowingValue<Result>>,
149149
as serializer: Serializer<Response, Value>,
150150
fileID: String = #fileID,
151-
line: UInt = #line
151+
line: UInt = #line,
152+
function: String = #function
152153
) async throws -> Result {
153-
try await call(caller, as: serializer, fileID: fileID, line: line)()
154+
try await call(caller, as: serializer, fileID: fileID, line: line, function: function)()
154155
}
155156

156157
/// Asynchronously performs a network call using the provided caller and serializer.
@@ -165,33 +166,34 @@ public extension APIClient {
165166
func call<Value, Result>(
166167
_ caller: APIClientCaller<Value, Value, AsyncThrowingValue<Result>>,
167168
fileID: String = #fileID,
168-
line: UInt = #line
169+
line: UInt = #line,
170+
function: String = #function
169171
) async throws -> Result {
170-
try await call(caller, as: .identity, fileID: fileID, line: line)()
172+
try await call(caller, as: .identity, fileID: fileID, line: line, function: function)()
171173
}
172174

173175
/// Asynchronously performs a network call using the http caller and decodable serializer.
174176
/// - Returns: The result of the network call.
175-
func call<Result: Decodable>(fileID: String = #fileID, line: UInt = #line) async throws -> Result {
176-
try await call(.http, as: .decodable, fileID: fileID, line: line)
177+
func call<Result: Decodable>(fileID: String = #fileID, line: UInt = #line, function: String = #function) async throws -> Result {
178+
try await call(.http, as: .decodable, fileID: fileID, line: line, function: function)
177179
}
178180

179181
/// Asynchronously performs a network call using the http caller and decodable serializer.
180182
/// - Returns: The result of the network call.
181-
func callAsFunction<Result: Decodable>(fileID: String = #fileID, line: UInt = #line) async throws -> Result {
182-
try await call(fileID: fileID, line: line)
183+
func callAsFunction<Result: Decodable>(fileID: String = #fileID, line: UInt = #line, function: String = #function) async throws -> Result {
184+
try await call(fileID: fileID, line: line, function: function)
183185
}
184186

185187
/// Asynchronously performs a network call using the http caller and void serializer.
186188
/// - Returns: The result of the network call.
187-
func call(fileID: String = #fileID, line: UInt = #line) async throws {
188-
try await call(.http, as: .void, fileID: fileID, line: line)
189+
func call(fileID: String = #fileID, line: UInt = #line, function: String = #function) async throws {
190+
try await call(.http, as: .void, fileID: fileID, line: line, function: function)
189191
}
190192

191193
/// Asynchronously performs a network call using the http caller and void serializer.
192194
/// - Returns: The result of the network call.
193-
func callAsFunction(fileID: String = #fileID, line: UInt = #line) async throws {
194-
try await call(fileID: fileID, line: line)
195+
func callAsFunction(fileID: String = #fileID, line: UInt = #line, function: String = #function) async throws {
196+
try await call(fileID: fileID, line: line, function: function)
195197
}
196198

197199
/// Performs a network call using the provided caller and serializer.
@@ -206,9 +208,10 @@ public extension APIClient {
206208
func call<Value, Result>(
207209
_ caller: APIClientCaller<Value, Value, Result>,
208210
fileID: String = #fileID,
209-
line: UInt = #line
211+
line: UInt = #line,
212+
function: String = #function
210213
) throws -> Result {
211-
try call(caller, as: .identity, fileID: fileID, line: line)
214+
try call(caller, as: .identity, fileID: fileID, line: line, function: function)
212215
}
213216

214217
/// Performs a network call using the provided caller and serializer.

0 commit comments

Comments
 (0)