Skip to content

Commit 04bfe55

Browse files
authored
Adjust Functions getters to be Kotlin source compatible (#6530)
1 parent 1b24b82 commit 04bfe55

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

firebase-functions/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Unreleased
2+
* [fixed] Fixed HttpsCallableResult.data resolution in Kotlin
3+
4+
# 21.1.0
25
* [changed] Migrated to Kotlin
36

47
# 21.0.0

firebase-functions/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ package com.google.firebase.functions {
110110

111111
public final class HttpsCallableResult {
112112
method @Nullable public Object getData();
113+
field @Nullable public final Object data;
113114
}
114115

115116
public final class Serializer {

firebase-functions/src/androidTest/java/com/google/firebase/functions/ktx/CallTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CallTests {
6464
)
6565

6666
var function = functions.getHttpsCallable("dataTest")
67-
val actual = Tasks.await(function.call(input)).getData()
67+
val actual = Tasks.await(function.call(input)).data
6868

6969
assertThat(actual).isInstanceOf(Map::class.java)
7070
@Suppress("UNCHECKED_CAST") val map = actual as Map<String, *>
@@ -77,7 +77,7 @@ class CallTests {
7777
fun testNullDataCall() {
7878
val functions = Firebase.functions(app)
7979
var function = functions.getHttpsCallable("nullTest")
80-
val actual = Tasks.await(function.call(null)).getData()
80+
val actual = Tasks.await(function.call(null)).data
8181

8282
assertThat(actual).isNull()
8383
}
@@ -86,7 +86,7 @@ class CallTests {
8686
fun testEmptyDataCall() {
8787
val functions = Firebase.functions(app)
8888
var function = functions.getHttpsCallable("nullTest")
89-
val actual = Tasks.await(function.call()).getData()
89+
val actual = Tasks.await(function.call()).data
9090

9191
assertThat(actual).isNull()
9292
}

firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ package com.google.firebase.functions
1616
/** The result of calling a HttpsCallableReference function. */
1717
public class HttpsCallableResult
1818
internal constructor( // The actual result data, as generic types decoded from JSON.
19-
private val data: Any?) {
19+
/**
20+
* The data that was returned from the Callable HTTPS trigger.
21+
*
22+
* The data is in the form of native Java objects. For example, if your trigger returned an array,
23+
* this object would be a `List<Object>`. If your trigger returned a JavaScript object with keys
24+
* and values, this object would be a `Map<String, Object>`.
25+
*/
26+
@JvmField public val data: Any?
27+
) {
2028
/**
2129
* Returns the data that was returned from the Callable HTTPS trigger.
2230
*
2331
* The data is in the form of native Java objects. For example, if your trigger returned an array,
24-
* this object would be a List<Object>. If your trigger returned a JavaScript object with keys and
25-
* values, this object would be a Map<String, Object>.
32+
* this object would be a `List<Object>`. If your trigger returned a JavaScript object with keys
33+
* and values, this object would be a `Map<String, Object>`.
2634
*/
2735
public fun getData(): Any? {
2836
return data

0 commit comments

Comments
 (0)