Skip to content

Adjust Functions getters to be Kotlin source compatible #6530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions firebase-functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Unreleased
* [fixed] Fixed HttpsCallableResult.data resolution in Kotlin

# 21.1.0
* [changed] Migrated to Kotlin

# 21.0.0
Expand Down
1 change: 1 addition & 0 deletions firebase-functions/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, *>
Expand All @@ -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()
}
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>`. If your trigger returned a JavaScript object with keys
* and values, this object would be a `Map<String, Object>`.
*/
@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<Object>. If your trigger returned a JavaScript object with keys and
* values, this object would be a Map<String, Object>.
* this object would be a `List<Object>`. If your trigger returned a JavaScript object with keys
* and values, this object would be a `Map<String, Object>`.
*/
public fun getData(): Any? {
return data
Expand Down