/
cloud_functions.dart
49 lines (38 loc) 路 1.44 KB
/
cloud_functions.dart
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
45
46
47
48
49
// Copyright 2019, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of cloud_functions;
class CloudFunctionsException implements Exception {
CloudFunctionsException._(this.code, this.message, this.details);
final String code;
final String message;
final dynamic details;
}
/// The entry point for accessing a CloudFunctions.
///
/// You can get an instance by calling [CloudFunctions.instance].
class CloudFunctions {
CloudFunctions({FirebaseApp app, String region})
: _app = app ?? Firebase.app(),
_region = region;
static CloudFunctions _instance = CloudFunctions();
static CloudFunctions get instance => _instance;
final FirebaseApp _app;
final String _region;
String _origin;
/// Gets an instance of a Callable HTTPS trigger in Cloud Functions.
///
/// Can then be executed by calling `call()` on it.
///
/// @param functionName The name of the callable function.
HttpsCallable getHttpsCallable({@required String functionName}) {
return HttpsCallable._(this, functionName);
}
/// Changes this instance to point to a Cloud Functions emulator running locally.
///
/// @param origin The origin of the local emulator, such as "//10.0.2.2:5005".
CloudFunctions useFunctionsEmulator({@required String origin}) {
_origin = origin;
return this;
}
}