applite_ui 0.0.25 copy "applite_ui: ^0.0.25" to clipboard
applite_ui: ^0.0.25 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.

Store API #

The store module provides full CRUD operations for e-commerce entities:

// List products
final products = await applite.app.store.product.list(
  ListProductsParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
  ),
);

// Create a category
final category = await applite.app.store.category.create(
  CreateCategoryParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    name: 'Electronics',
    sellerId: 'seller-id',
  ),
);

Available store submodules:

  • store.badge - Product badges
  • store.category - Product categories
  • store.collection - Product collections
  • store.discount - Discount codes
  • store.option - Product options
  • store.order - Orders
  • store.product - Products
  • store.seller - Sellers
  • store.shipping - Shipping profiles
  • store.tag - Product tags
  • store.tax - Tax configurations

Multi-Service API #

The multi-service module enables appointment-based service management:

// List companies
final companies = await applite.app.multiService.company.list(
  ListCompaniesParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
  ),
);

// Create a service
final service = await applite.app.multiService.service.create(
  CreateServiceParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    companyId: 'company-id',
    name: 'Haircut',
    basePrice: 25.00,
  ),
);

// Create an appointment
final appointment = await applite.app.multiService.appointment.create(
  CreateAppointmentParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    companyId: 'company-id',
    serviceId: 'service-id',
    filledFields: {'notes': 'First time customer'},
    totalPrice: 25.00,
    date: '2024-01-15T10:00:00Z',
    commune: 'Downtown',
  ),
);

// Update appointment status
await applite.app.multiService.appointment.updateStatus(
  UpdateAppointmentStatusParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    id: 'appointment-id',
    status: AppointmentStatus.confirmed,
  ),
);

Available multi-service submodules:

  • multiService.company - Service provider companies
  • multiService.service - Services offered
  • multiService.agent - Service agents/employees
  • multiService.appointment - Customer appointments

App Info API #

// List apps
final apps = await applite.app.info.list(
  ListAppsParams(apiKey: 'your-api-key'),
);

// Get app by slug
final app = await applite.app.info.getBySlug(
  GetAppBySlugParams(
    apiKey: 'your-api-key',
    slug: 'my-app',
  ),
);

Statistics API #

// Track a statistic
await applite.app.stats.create(
  CreateStatisticParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    key: 'page_views',
    value: 1,
  ),
);

// Get statistic value
final views = await applite.app.stats.get(
  GetStatisticParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
    key: 'page_views',
  ),
);

Finance API #

// Get balance
final balance = await applite.app.finance.balance(
  BalanceParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
  ),
);

// List transactions
final transactions = await applite.app.finance.listTransactions(
  TransactionListParams(
    apiKey: 'your-api-key',
    appId: 'your-app-id',
  ),
);

Error Handling #

All API methods throw ApiException on failure:

try {
  await applite.app.customer.get(params);
} on ApiException catch (e) {
  print('Error: ${e.message}');
  print('Status code: ${e.statusCode}');
}
0
likes
135
points
921
downloads

Publisher

unverified uploader

Weekly Downloads

Dart client for Applite UI APIs.

Homepage
Repository (GitHub)
View/report issues

Topics

#applite #api #client #sdk #dart

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dio, hive_ce, json_annotation

More

Packages that depend on applite_ui