finance_sdk 1.0.2 copy "finance_sdk: ^1.0.2" to clipboard
finance_sdk: ^1.0.2 copied to clipboard

A Flutter plugin for Firebase-based dynamic API orchestration. Fetches API configurations from Firestore and Remote Config to handle HTTP requests dynamically.

Finance SDK #

A Flutter plugin that provides Firebase-driven dynamic API orchestration using Firestore and Remote Config.

πŸš€ Features #

  • Firebase Integration: Automatic initialization of Firestore and Remote Config
  • Dynamic API Configuration: Fetch API definitions from Firestore
  • Dynamic Enum Generation: Auto-generate enums from Firestore data
  • Caching Layer: Local caching with SharedPreferences for offline support
  • Comprehensive Logging: Built-in logging system for debugging
  • Error Handling: Robust error handling with structured responses

πŸ“¦ Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  finance_sdk: ^1.0.0

The plugin handles Firebase initialization internally, so you don't need to add firebase_core to your dependencies.

πŸ”§ Quick Start #

1. Configure Firebase for the Plugin #

See FIREBASE_PLUGIN_SETUP.md for detailed instructions.

Important: Firebase is initialized internally by the plugin. Your app does NOT need to call Firebase.initializeApp().

2. Initialize the SDK #

import 'package:finance_sdk/finance_sdk.dart';

final financeSdk = FinanceSdk();

// Initialize the SDK (this fetches data from Firebase)
await financeSdk.initialize();

3. Send API Requests #

// Send a request using an API key from Firestore
final response = await financeSdk.sendRequest(
  apiKey: 'GET_USER_DETAIL',
  requestBody: {
    'userId': '12345',
    'includeProfile': true,
  },
);

if (response.success) {
  print('Success: ${response.data}');
} else {
  print('Error: ${response.error}');
}

πŸ—„οΈ Firebase Setup #

The plugin requires Firebase to be configured in the plugin itself, not in your app.

Setup Guide: FIREBASE_PLUGIN_SETUP.md

Quick Setup Steps: #

  1. Create Firebase Project with Firestore and Remote Config enabled
  2. Add Android App with package: com.mytm.finance.sdk.finance_sdk
  3. Add iOS App with bundle ID: com.mytm.finance.sdk.finance_sdk
  4. Place configuration files:
    • google-services.json β†’ android/google-services.json
    • GoogleService-Info.plist β†’ ios/GoogleService-Info.plist
  5. Configure Firestore: Create api_definitions collection
  6. Configure Remote Config: Add baseUrl parameter

πŸ“± Example App #

The example app demonstrates all SDK features:

cd example
flutter run

πŸ”„ How It Works #

  1. Initialization: The SDK initializes Firebase services and fetches API definitions from Firestore

  2. Request Processing: When you call sendRequest():

    • SDK looks up the API definition by key
    • Retrieves the base URL from Remote Config
    • Constructs the final URL: $baseUrl/$service$endpoint
    • Merges request body with default parameters
    • Sends HTTP request with configured headers
    • Returns structured response
  3. Caching: All data is cached locally for offline support and faster access

πŸ’» API Reference #

FinanceSdk Class #

initialize()

Initializes the Firebase-based API handling system. Must be called before using other methods.

sendRequest({required String apiKey, required Map<String, dynamic> requestBody})

Sends an API request using Firebase configuration.

Parameters:

  • apiKey: The API key identifier from Firestore
  • requestBody: The request body data to send

Returns: Future<ApiResponse>

getAvailableApiKeys()

Returns all available API keys from Firestore.

Returns: Future<Map<String, String>>

getAvailableServices()

Returns all available services from Firestore.

Returns: Future<Map<String, String>>

refreshData()

Refreshes data from Firebase (API definitions and base URL).

Returns: Future<void>

ApiResponse Class #

Properties

  • success: bool - Whether the request was successful
  • data: dynamic - Response data (if successful)
  • error: String? - Error message (if failed)
  • statusCode: int? - HTTP status code

πŸ› οΈ Development #

Running Tests #

flutter test

Running Integration Tests #

cd example
flutter test integration_test/

πŸ”’ Security Considerations #

Firebase Configuration #

  • The plugin uses an embedded Firebase configuration to ensure all users access the same Firebase project
  • Firebase credentials are protected by ProGuard rules in Android release builds
  • Firebase Security Rules should be configured on the server side to protect your data

Best Practices #

  • Store sensitive API keys securely in Firestore with proper Security Rules
  • Use Firebase App Check for additional security
  • Implement proper authentication in your backend APIs
  • Never commit Firebase configuration files to public repositories
  • Use environment-specific Firebase projects for development and production

πŸ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing #

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ž Support #

For support, please open an issue in the GitHub repository or contact the development team.

0
likes
140
points
89
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for Firebase-based dynamic API orchestration. Fetches API configurations from Firestore and Remote Config to handle HTTP requests dynamically.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

cloud_firestore, firebase_core, firebase_performance, firebase_remote_config, flutter, http, plugin_platform_interface, shared_preferences

More

Packages that depend on finance_sdk

Packages that implement finance_sdk