awn_finance_sdk 0.0.1+1 copy "awn_finance_sdk: ^0.0.1+1" to clipboard
awn_finance_sdk: ^0.0.1+1 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:
  awn_finance_sdk: ^1.0.2

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:awn_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}');
}

πŸ“– See API User Guide for complete API reference with all endpoints and examples.

πŸ“š Documentation #

  • API User Guide - Complete guide for using all API endpoints with examples
  • Firebase Plugin Setup - Setup instructions for Firebase configuration
  • Remote Config Setup - Configure Remote Config for base URL
  • Testing Guide - How to test the plugin

πŸ—„οΈ 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 #

Contributions are welcome! Please follow these steps:

  1. Create your feature branch
  2. Commit your changes with clear messages
  3. Ensure all tests pass
  4. Submit your changes for review

πŸ“ž Support #

For support, please contact the development team.

4
likes
130
points
0
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.

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 awn_finance_sdk

Packages that implement awn_finance_sdk