diff --git a/firebase-functions/CHANGELOG.md b/firebase-functions/CHANGELOG.md index eb6c565a42b..26c83870573 100644 --- a/firebase-functions/CHANGELOG.md +++ b/firebase-functions/CHANGELOG.md @@ -1,4 +1,7 @@ # Unreleased +* [fixed] Fixed HttpsCallableResult.data resolution in Kotlin + +# 21.1.0 * [changed] Migrated to Kotlin # 21.0.0 diff --git a/firebase-functions/api.txt b/firebase-functions/api.txt index 8b663f00cbb..323ba72e22f 100644 --- a/firebase-functions/api.txt +++ b/firebase-functions/api.txt @@ -110,6 +110,7 @@ package com.google.firebase.functions { public final class HttpsCallableResult { method @Nullable public Object getData(); + field @Nullable public final Object data; } public final class Serializer { diff --git a/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt b/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt index 87ca19f8348..dae8690718d 100644 --- a/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt +++ b/firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt @@ -64,7 +64,7 @@ class CallTests { ) var function = functions.getHttpsCallable("dataTest") - val actual = Tasks.await(function.call(input)).getData() + val actual = Tasks.await(function.call(input)).data assertThat(actual).isInstanceOf(Map::class.java) @Suppress("UNCHECKED_CAST") val map = actual as Map @@ -77,7 +77,7 @@ class CallTests { fun testNullDataCall() { val functions = Firebase.functions(app) var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call(null)).getData() + val actual = Tasks.await(function.call(null)).data assertThat(actual).isNull() } @@ -86,7 +86,7 @@ class CallTests { fun testEmptyDataCall() { val functions = Firebase.functions(app) var function = functions.getHttpsCallable("nullTest") - val actual = Tasks.await(function.call()).getData() + val actual = Tasks.await(function.call()).data assertThat(actual).isNull() } diff --git a/firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.kt b/firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.kt index ddda0ea57bb..19fec093d2d 100644 --- a/firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.kt +++ b/firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.kt @@ -16,13 +16,21 @@ package com.google.firebase.functions /** The result of calling a HttpsCallableReference function. */ public class HttpsCallableResult internal constructor( // The actual result data, as generic types decoded from JSON. -private val data: Any?) { + /** + * The data that was returned from the Callable HTTPS trigger. + * + * The data is in the form of native Java objects. For example, if your trigger returned an array, + * this object would be a `List`. If your trigger returned a JavaScript object with keys + * and values, this object would be a `Map`. + */ + @JvmField public val data: Any? +) { /** * Returns the data that was returned from the Callable HTTPS trigger. * * The data is in the form of native Java objects. For example, if your trigger returned an array, - * this object would be a List. If your trigger returned a JavaScript object with keys and - * values, this object would be a Map. + * this object would be a `List`. If your trigger returned a JavaScript object with keys + * and values, this object would be a `Map`. */ public fun getData(): Any? { return data