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

A comprehensive SDK for integrating with the AIxGen platform in Flutter/Dart applications.

AIxGen Core SDK #

The AIxGen Core SDK provides a comprehensive set of tools for integrating with the AIxGen platform in Flutter/Dart applications.

Features #

  • Authentication and user management
  • Financial product management
  • Multi-factor authentication
  • Metrics and analytics
  • Support ticketing system
  • Fraud detection and prevention

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  aixgen_core: ^1.0.0

Then run:

flutter pub get

Initialization #

Initialize the SDK with your developer API key:

import 'package:aixgen_core/aixgen_core.dart';

void main() async {
  final sdk = AIxGenCore();
  
  final initialized = await sdk.initialize(
    apiKey: 'your_developer_api_key',
    baseUrl: 'https://api.example.com',
    environment: SdkEnvironment.sandbox, // or SdkEnvironment.production
  );
  
  if (initialized) {
    print('SDK initialized successfully');
  } else {
    print('Failed to initialize SDK');
  }
}

Authentication #

Login #

final loginResponse = await sdk.auth.login('user@example.com', 'password123');

if (loginResponse['success']) {
  print('Login successful');
  // Token is automatically stored in the SDK
} else {
  print('Login failed: ${loginResponse['message']}');
}

MFA Verification #

If MFA is enabled, verify the code:

final mfaResponse = await sdk.auth.verifyMfaCode(userId, '123456');

if (mfaResponse['success']) {
  print('MFA verification successful');
} else {
  print('MFA verification failed: ${mfaResponse['message']}');
}

Logout #

await sdk.auth.logout(userId);

User Management #

Get Current User #

final user = await sdk.user.getCurrentUser();
if (user != null) {
  print('Current user: ${user.email}');
}

Update User Profile #

final updateResponse = await sdk.user.updateProfile(userId, {
  'firstName': 'John',
  'lastName': 'Doe',
});

if (updateResponse['success']) {
  print('Profile updated successfully');
}

Multi-Factor Authentication #

Check MFA Status #

final mfaStatus = await sdk.mfa.getMfaStatus(userId);
print('MFA enabled: ${mfaStatus['enabled']}');
print('Preferred method: ${mfaStatus['preferredMethod']}');

Set Up MFA #

final mfaSetup = await sdk.mfa.initiateMfaSetup(
  userId,
  MfaMethod.authenticatorApp,
);

print('Secret key: ${mfaSetup['secretKey']}');
print('QR code URL: ${mfaSetup['qrCodeUrl']}');
print('Recovery codes: ${mfaSetup['recoveryCodes']}');

Verify and Enable MFA #

final verifyResponse = await sdk.mfa.verifyAndEnableMfa(userId, '123456');

if (verifyResponse['success']) {
  print('MFA enabled successfully');
}

Disable MFA #

final disableResponse = await sdk.mfa.disableMfa(userId);

if (disableResponse['success']) {
  print('MFA disabled successfully');
}

Financial Products #

Get All Products #

final products = await sdk.products.getAllProducts();
if (products != null) {
  for (final product in products) {
    print('Product: ${product.name}');
  }
}

Get Product by ID #

final product = await sdk.products.getProductById(productId);
if (product != null) {
  print('Product details: ${product.name} - ${product.description}');
}

Update Product #

product.description = 'Updated description';
final updateResponse = await sdk.products.updateProduct(product.id, product);

if (updateResponse['success']) {
  print('Product updated successfully');
}

Update Product Features #

final featuresResponse = await sdk.products.updateProductFeatures(
  productId,
  ['api_access', 'data_export', 'advanced_analytics'],
);

if (featuresResponse['success']) {
  print('Product features updated successfully');
}

Metrics #

Get API Requests #

final apiRequests = await sdk.metrics.getApiRequests('monthly');
print('API requests this month: $apiRequests');

Get Total Transactions #

final totalTransactions = await sdk.metrics.getTotalTransactions('monthly');
print('Total transactions this month: $totalTransactions');

Get Revenue Generated #

final revenue = await sdk.metrics.getRevenueGenerated('monthly');
print('Revenue generated this month: $revenue');

Get Failed Transactions #

final failedTransactions = await sdk.metrics.getFailedTransactions('monthly');
print('Failed transactions this month: $failedTransactions');

Support #

Create a Ticket #

final ticket = await sdk.support.createTicket(
  userId,
  'API Integration Issue',
  'Having trouble integrating with the payment API.',
  TicketType.technical,
);

if (ticket != null) {
  print('Ticket created with ID: ${ticket.id}');
}

Get Ticket History #

final ticketHistory = await sdk.support.getTicketHistory(userId);
print('Found ${ticketHistory.length} tickets in history');

Fraud Detection #

Get All Operations #

final operations = await sdk.fraud.getAllOperations();
if (operations != null) {
  print('Found ${operations.length} operations for fraud analysis');
}

Execute Command #

final commandResponse = await sdk.fraud.executeCommand('analyze_transactions');
if (commandResponse != null && commandResponse['success']) {
  print('Command executed successfully');
}

Error Handling #

The SDK uses a consistent error handling approach. All methods return either:

  1. The requested object(s)
  2. A map with success and message keys
  3. null in case of unexpected failures

Always check the return values and implement proper error handling in your application.

Environment Switching #

You can switch between sandbox and production environments:

await sdk.changeEnvironment(SdkEnvironment.production);

Logging #

The SDK uses the logger package for internal logging. You can configure your own logger for more detailed information.

License #

This SDK is licensed under the MIT License.

0
likes
0
points
179
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive SDK for integrating with the AIxGen platform in Flutter/Dart applications.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, http, intl, logger

More

Packages that depend on aixgen_core