Morni RSA Plugin

A Flutter plugin for integrating Road Side Assistance (RSA) services into your Flutter applications. This plugin provides a seamless interface to manage service requests, user information, and active services.

Features

  • User Management
    • Fetch user information and profile details
  • Service Management
    • List all active RSA services
    • Create new service requests
    • Cancel existing service requests
  • Multi-language Support
    • Supports both Arabic (ar) and English (en)
  • Error Handling
    • Comprehensive error handling and reporting
    • Type-safe API responses

Getting Started

Installation

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

dependencies:
  morni_rsa: ^0.0.1

Platform Configuration

Android

Ensure you have the correct NDK version in your app's build.gradle.kts:

android {
    ndkVersion = "27.0.12077973"
    // ... other configurations
}

iOS

No additional configuration required.

Initialization

Before using the plugin, initialize it with your API credentials:

import 'package:morni_rsa/service/initialization.dart';
import 'package:morni_rsa/model/language.dart';

void main() {
  MorniService.init(
    "YOUR_API_BASE_URL",
    "YOUR_API_TOKEN",
    Language.en, // or Language.ar for Arabic
  );
  
  runApp(const MyApp());
}

Usage

Fetch User Information

final apiService = ApiService();
final response = await apiService.getUser();

if (response.success && response.data != null) {
  final user = response.data!;
  print('User ID: ${user.morniUserId}');
  print('Name: ${user.firstName} ${user.lastName}');
}

Get Active Services

final apiService = ApiService();
final response = await apiService.getActiveServices();

if (response.success && response.data != null) {
  final services = response.data!;
  for (final service in services) {
    print('Service: ${service.name}');
    print('Description: ${service.description}');
  }
}

Create a Service Request

final request = ServiceRequest(
  userId: userId,
  serviceId: serviceId,
  addOnId: addOnId,
  pickUpLat: latitude,
  pickUpLng: longitude,
  pickUpTime: DateTime.now(),
  dropOffLocation: 'Location Name',
  note: 'Additional notes',
);

final response = await apiService.createServiceRequest(request);
if (response.success) {
  print('Service request created successfully');
}

Cancel a Service Request

final response = await apiService.cancelServiceRequest(
  requestId,
  'Cancellation reason',
);

if (response.success) {
  print('Service request cancelled successfully');
}

Example

Check out the example directory for a complete sample application demonstrating all features.

API Reference

Models

  • User: Represents user information
  • Service: Represents an RSA service
  • ServiceRequest: Represents a service request
  • ApiResponse<T>: Generic wrapper for API responses

Services

  • ApiService: Main service class for making API calls
  • MorniService: Configuration and initialization service

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the LICENSE file in the root directory of this project.

Issues and Feedback

Please file issues, bugs, or feature requests in our issue tracker.