forked from shepeliev/firebase-kotlin-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.kt
44 lines (33 loc) · 1.77 KB
/
functions.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
*/
package dev.gitlive.firebase.functions
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerializationStrategy
expect class FirebaseFunctions {
fun httpsCallable(name: String, timeout: Long? = null): HttpsCallableReference
fun useEmulator(host: String, port: Int)
@Deprecated("Use useEmulator(java.lang.String,int) to connect to the emulator.", level = DeprecationLevel.ERROR)
fun useFunctionsEmulator(origin: String)
}
expect class HttpsCallableReference {
suspend operator inline fun <reified T> invoke(data: T, encodeDefaults: Boolean = true): HttpsCallableResult
suspend operator fun <T> invoke(strategy: SerializationStrategy<T>, data: T, encodeDefaults: Boolean = true): HttpsCallableResult
suspend operator fun invoke(): HttpsCallableResult
}
expect class HttpsCallableResult {
inline fun <reified T> data(): T
fun <T> data(strategy: DeserializationStrategy<T>): T
}
/** Returns the [FirebaseFunctions] instance of the default [FirebaseApp]. */
expect val Firebase.functions: FirebaseFunctions
/** Returns the [FirebaseFunctions] instance of a given [region]. */
expect fun Firebase.functions(region: String): FirebaseFunctions
/** Returns the [FirebaseFunctions] instance of a given [FirebaseApp]. */
expect fun Firebase.functions(app: FirebaseApp): FirebaseFunctions
/** Returns the [FirebaseFunctions] instance of a given [FirebaseApp] and [region]. */
expect fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions
expect class FirebaseFunctionsException: FirebaseException