ソースを参照

Revert parameterless API version

Paul Beusterien 4 年 前
コミット
cdab605bcf

+ 4 - 4
FirebaseFunctionsSwift/Sources/Codable/Callable+Codable.swift

@@ -73,7 +73,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
   ///
   /// - Parameter data: Parameters to pass to the trigger.
   /// - Parameter completion: The block to call when the HTTPS request has completed.
-  public func call(_ data: Request? = nil,
+  public func call(_ data: Request,
                    completion: @escaping (Result<Response, Error>)
                      -> Void) {
     do {
@@ -119,7 +119,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
   /// - Parameters:
   ///   - data: Parameters to pass to the trigger.
   ///   - completion: The block to call when the HTTPS request has completed.
-  public func callAsFunction(_ data: Request? = nil,
+  public func callAsFunction(_ data: Request,
                              completion: @escaping (Result<Response, Error>)
                                -> Void) {
     call(data, completion: completion)
@@ -146,7 +146,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
     ///
     /// - Returns: The decoded `Response` value
     @available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
-    public func call(_ data: Request? = nil,
+    public func call(_ data: Request,
                      encoder: FirebaseDataEncoder = FirebaseDataEncoder(),
                      decoder: FirebaseDataDecoder =
                        FirebaseDataDecoder()) async throws -> Response {
@@ -175,7 +175,7 @@ public struct Callable<Request: Encodable, Response: Decodable> {
     ///   - data: Parameters to pass to the trigger.
     /// - Returns: The decoded `Response` value
     @available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
-    public func callAsFunction(_ data: Request? = nil) async throws -> Response {
+    public func callAsFunction(_ data: Request) async throws -> Response {
       return try await call(data)
     }
   #endif

+ 0 - 37
FirebaseFunctionsSwift/Tests/IntegrationTests.swift

@@ -290,43 +290,6 @@ class IntegrationTests: XCTestCase {
     }
   #endif
 
-  // No parameters to call should be the same as passing nil.
-  // If no parameters are required, then the non-typed API
-  // is more appropriate since it specifically avoids defining
-  // type.
-  func testParameterless() {
-    let expectation = expectation(description: #function)
-    let function = functions.httpsCallable(
-      "nullTest",
-      requestAs: Int?.self,
-      responseAs: Int?.self
-    )
-    function.call { result in
-      do {
-        let data = try result.get()
-        XCTAssertEqual(data, nil)
-      } catch {
-        XCTAssert(false, "Failed to unwrap the function result: \(error)")
-      }
-      expectation.fulfill()
-    }
-    waitForExpectations(timeout: 5)
-  }
-
-  #if compiler(>=5.5) && canImport(_Concurrency)
-    @available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
-    func testParameterlessAsync() async throws {
-      let function = functions.httpsCallable(
-        "nullTest",
-        requestAs: Int?.self,
-        responseAs: Int?.self
-      )
-
-      let data = try await function.call()
-      XCTAssertEqual(data, nil)
-    }
-  #endif
-
   func testMissingResult() {
     let expectation = expectation(description: #function)
     let function = functions.httpsCallable(