invertase/dart_firebase_apis
🔥 Dart용으로 생성된 Firebase API. 또한 개인 및 비공개 API도 포함됩니다.
- Stars
- 30
- Forks
- 9
- 최근 푸시(UTC)
- 2023. 8. 28.
- 프로젝트 상태
- 보관됨
기술 주제
사용 중인 의존성
의존성 목록 1 개
- melos개발 의존성
—
원본 README
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
README 펼치기 / 접기
Firebase API Client Libraries for Dart
Chat on DiscordThis is based on the googleapis.dart repository but instead aimed at supporting Firebase related APIs only. Additionally, this adds support for several unlisted (but discoverable) Firebase APIs that are not listed on the official discovery API that googleapis.dart uses (and is currently limited to) as well as several private APIs (APIs that require an API key to view discovery information).
See ./generated/firebaseapis/README.md for information on all the currently supported APIs.
Usage Example
// Import the APIs you want to use
import 'package:firebaseapis/firebaseremoteconfig/v1.dart' as remote_config;
import 'package:firebaseapis/firebaserules/v1.dart' as firebase_rules;
// Import Auth client
import 'package:googleapis_auth/auth_io.dart' as auth;
// Get an Auth Client
final authClient = await auth.clientViaApplicationDefaultCredentials(scopes: [
remote_config.FirebaseRemoteConfigApi.cloudPlatformScope,
]);
// Call some APIs
final rc = remote_config.FirebaseRemoteConfigApi(authClient);
final config =
await rc.projects.getRemoteConfig('projects/<your-project-id>');
print(config.parameters);
print(config.parameters?.values.first.defaultValue);
print(config.parameters?.values.first.description);
print(config.parameters?.values.first.valueType);
final fr = firebase_rules.FirebaseRulesApi(authClient);
final rules =
await fr.projects.rulesets.list('projects/<your-project-id>');
print(rules.rulesets?.first.name);
print(rules.rulesets?.first.source?.files?.first.content);
Custom Request Headers
Custom request headers can be set by adding to requestHeaders:
import 'package:firebaseapis/src/user_agent.dart';
Future<void> main() async {
requestHeaders.addAll({
'cool-header': 'cool-value',
});
print(requestHeaders);
}
Contributing
This project uses Melos to manage the project and dependencies.
To install Melos, run the following command from your SSH client:
dart pub global activate melos
Next, at the root of your locally cloned repository bootstrap the projects dependencies:
melos bootstrap
The bootstrap command locally links all dependencies within the project without having to
provide manual dependency_overrides. This allows all
plugins, examples and tests to build from the local clone project.
You do not need to run
flutter pub getonce bootstrap has been completed.
Adding a new API
To add a new API and generate library code for it is fairly straightforward;
- Add the API to the
apislist in./config.yaml - Run
melos run config:downloadto update the downloaded discovery document JSON files that are in./discovery.- Note: several APIs require an API key to be able to read the discovery information. Set a
API_KEYenvironment variable before running the command to be able to download the discovery documents for these private APIs, e.g.API_KEY=<your-key-here> melos run config:download.
- Note: several APIs require an API key to be able to read the discovery information. Set a
- Run
melos run config:generateto generate new Dart library code for the API, which outputs to./generated/firebaseapis.
https://static.invertase.io/assets/invertase/invertase-rounded-avatar.png
Maintained by Invertase.