onvaca_connect 0.2.0
onvaca_connect: ^0.2.0 copied to clipboard
Dart SDK for the OnVaca Connect Platform — a unified interface for multiple property management system providers.
example/example.dart
// ignore_for_file: avoid_print, unused_local_variable
/// Basic usage example showing the most common SDK operations.
///
/// See also:
/// - `setup_example.dart` — PMS connection setup and teardown
/// - `booking_flow_example.dart` — Full booking lifecycle
/// - `pagination_example.dart` — Pagination and filtering
/// - `async_operations_example.dart` — Async jobs and polling
/// - `error_handling_example.dart` — Exhaustive error handling
library;
import 'package:onvaca_connect/onvaca_connect.dart';
Future<void> main() async {
final connect = OnvacaConnect(
apiKey: 'your-api-key',
baseUrl: 'https://connect.onvaca.com',
);
try {
// Check connected providers
final connections = await connect.connections();
print('Providers: ${connections.map((c) => c.label).join(', ')}');
// List properties
final properties = await connect.properties.list();
print('Found ${properties.total} properties');
for (final property in properties.data) {
print(' - ${property.rawData['name']} (${property.pmsEntityId})');
}
// Get a booking quote
final quote = await connect.bookings.quote({
'property': '100',
'daterange': {'start': '2026-06-01', 'end': '2026-06-07'},
'adults': 2,
});
print('Quote total: ${quote.data}');
// Create the booking
final booking = await connect.bookings.create({
'property': '100',
'daterange': {'start': '2026-06-01', 'end': '2026-06-07'},
'adults': 2,
'source_name': 'MyApp',
});
print('Booking created: ${booking.providerRef}');
} on OnvacaConnectException catch (e) {
print('Error (${e.statusCode}): ${e.message}');
} finally {
connect.close();
}
}