applite_ui 0.0.1
applite_ui: ^0.0.1 copied to clipboard
Dart client for Applite UI APIs.
Applite Dart SDK #
A lightweight Dart client for the Applite UI API built on top of dio.
Installation #
Add the package to your pubspec.yaml:
dependencies:
dart_sdk:
path: ../packages/dart_sdk
Usage #
Create a shared SDK instance and call the app customer endpoints. All methods
require the appId and apiKey fields alongside the payload properties for
the specific route.
import 'package:dart_sdk/applite_ui.dart';
Future<void> main() async {
final applite = AppliteUI(
config: const AppliteUIConfig(
baseUrl: 'https://api.applite.ai',
headers: {'x-environment': 'staging'},
),
);
try {
final response = await applite.app.customer.auth(
appId: 'your-app-id',
apiKey: 'your-api-key',
fullname: 'Jane Doe',
telephone: '+123456789',
);
print('Authenticated as: ${response.data.fullname}');
} on ApiException catch (error) {
print('Auth failed: ${error.message}');
}
}
Customer API #
List customers filtered by platform types:
final customers = await applite.app.customer.list(
appId: 'your-app-id',
apiKey: 'your-api-key',
plateformType: const ['STORE', 'TRANSPORT'],
);
print('Found ${customers.data.length} customers');
List a smaller shape of customers for quick lists:
final few = await applite.app.customer.listFew(
appId: 'your-app-id',
apiKey: 'your-api-key',
);
print('Fetched ${few.data.length} lite customers');
Authenticate or create a customer:
final auth = await applite.app.customer.auth(
appId: 'your-app-id',
apiKey: 'your-api-key',
fullname: 'Jane Doe',
telephone: '+123456789',
plateform: 'STORE',
);
print('Customer id: ${auth.data.id}');
Check if a customer exists for a platform:
try {
final check = await applite.app.customer.check(
appId: 'your-app-id',
apiKey: 'your-api-key',
telephone: '+123456789',
plateform: 'STORE',
);
final match = check.data;
if (match == null) {
print('Customer not found');
} else {
print('Customer exists: ${match.fullname}');
}
} on ApiException catch (error) {
// handle connectivity issues or 4xx/5xx responses from dio
print('Lookup failed: ${error.message}');
}
Fetch a customer with activity details:
final detail = await applite.app.customer.get(
appId: 'your-app-id',
apiKey: 'your-api-key',
id: 'customer-id',
);
if (detail.data != null) {
print('Customer ${detail.data!.fullname} has ${detail.data!.transactions.length} transactions');
}
Update the customer profile:
await applite.app.customer.update(
appId: 'your-app-id',
apiKey: 'your-api-key',
id: 'customer-id',
fullname: 'New Name',
photoUrl: 'https://cdn.example.com/avatar.jpg',
);
ApiException wraps DioException details when the underlying HTTP call fails
or when the API responds with an error payload.