From eaf69ca5bf1ca3c760591a8fa5321250fc1eadca Mon Sep 17 00:00:00 2001 From: Orhan Gorkem Sevim Date: Fri, 8 Sep 2023 19:09:16 +0300 Subject: [PATCH 1/2] add query to arguments --- Sources/Functions/FunctionsClient.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/Functions/FunctionsClient.swift b/Sources/Functions/FunctionsClient.swift index ca692b5..9dbd3b3 100644 --- a/Sources/Functions/FunctionsClient.swift +++ b/Sources/Functions/FunctionsClient.swift @@ -31,11 +31,13 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, + query: [(String, String?)]?, invokeOptions: FunctionInvokeOptions = .init(), decode: (Data, HTTPURLResponse) throws -> Response ) async throws -> Response { let (data, response) = try await rawInvoke( functionName: functionName, + query: query, invokeOptions: invokeOptions ) return try decode(data, response) @@ -46,11 +48,13 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, + query: [(String, String?)]?, invokeOptions: FunctionInvokeOptions = .init(), decoder: JSONDecoder = JSONDecoder() ) async throws -> T { try await invoke( functionName: functionName, + query: query, invokeOptions: invokeOptions, decode: { data, _ in try decoder.decode(T.self, from: data) } ) @@ -61,10 +65,12 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, + query: [(String, String?)]?, invokeOptions: FunctionInvokeOptions = .init() ) async throws { try await invoke( functionName: functionName, + query: query, invokeOptions: invokeOptions, decode: { _, _ in () } ) @@ -72,11 +78,13 @@ public final class FunctionsClient { private func rawInvoke( functionName: String, + query: [(String, String?)]?, invokeOptions: FunctionInvokeOptions ) async throws -> (Data, HTTPURLResponse) { let request = Request( path: functionName, method: invokeOptions.method.map({ HTTPMethod(rawValue: $0.rawValue) }) ?? .post, + query: query, body: invokeOptions.body, headers: invokeOptions.headers.merging(headers) { first, _ in first } ) From eb1fff405279da8f271c9b6bf39a528699c746e1 Mon Sep 17 00:00:00 2001 From: Orhan Gorkem Sevim Date: Fri, 8 Sep 2023 19:23:54 +0300 Subject: [PATCH 2/2] add default value to query --- Sources/Functions/FunctionsClient.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Functions/FunctionsClient.swift b/Sources/Functions/FunctionsClient.swift index 9dbd3b3..13f41d5 100644 --- a/Sources/Functions/FunctionsClient.swift +++ b/Sources/Functions/FunctionsClient.swift @@ -31,7 +31,7 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, - query: [(String, String?)]?, + query: [(String, String?)]? = nil, invokeOptions: FunctionInvokeOptions = .init(), decode: (Data, HTTPURLResponse) throws -> Response ) async throws -> Response { @@ -48,7 +48,7 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, - query: [(String, String?)]?, + query: [(String, String?)]? = nil, invokeOptions: FunctionInvokeOptions = .init(), decoder: JSONDecoder = JSONDecoder() ) async throws -> T { @@ -65,7 +65,7 @@ public final class FunctionsClient { /// - functionName: the name of the function to invoke. public func invoke( functionName: String, - query: [(String, String?)]?, + query: [(String, String?)]? = nil, invokeOptions: FunctionInvokeOptions = .init() ) async throws { try await invoke( @@ -78,7 +78,7 @@ public final class FunctionsClient { private func rawInvoke( functionName: String, - query: [(String, String?)]?, + query: [(String, String?)]? = nil, invokeOptions: FunctionInvokeOptions ) async throws -> (Data, HTTPURLResponse) { let request = Request(