Vondera SDK
A Flutter SDK for interacting with the Vondera REST APIs. This package provides a clean, type-safe interface for all Vondera public API endpoints.
Features
- ✅ Complete API coverage for all Vondera endpoints
- ✅ Type-safe models with null-safety support
- ✅ Clean, scalable architecture
- ✅ Comprehensive error handling
- ✅ Pagination support
- ✅ Singleton pattern for easy access
- ✅ Well-documented code
Installation
Add vondera_sdk to your pubspec.yaml:
dependencies:
vondera_sdk:
path: . # or use git/version if published
Then run:
flutter pub get
Getting Started
1. Initialize the SDK
import 'package:vondera_sdk/vondera_sdk.dart';
final vondera = VonderaSDK(
baseUrl: 'https://us-central1-brands-61c3d.cloudfunctions.net/app-api/api/public',
apiKey: 'YOUR_API_KEY',
userId: 'USER_ID', // Optional: for cart tracking
);
2. Get Your API Key
To obtain your Vondera API key:
- Create an account at Vondera Dashboard
- Complete your store info
- Head to Store options → Other Settings
- Find your API Key at Settings
3. Usage Examples
Store Operations
// Get store information
final store = await vondera.stores.getStore();
print('Store: ${store.name}');
Product Operations
// Get all products with pagination
final products = await vondera.products.getProducts(
page: 1,
limit: 20,
);
print('Total products: ${products.items.length}');
print('Current page: ${products.currentPage}');
// Get a specific product
final product = await vondera.products.getProduct('product-id');
// Get featured products
final featured = await vondera.products.getFeaturedProducts(limit: 10);
// Search products
final searchResults = await vondera.products.getProducts(
search: 'laptop',
page: 1,
limit: 10,
);
Category Operations
// Get all categories
final categories = await vondera.categories.getCategories();
// Get category by ID
final category = await vondera.categories.getCategory('category-id');
// Get subcategories
final subCategories = await vondera.categories.getSubCategories('category-id');
// Forget password await vondera.customers.forgetPassword(email: 'user@example.com');
// Delete customer account await vondera.customers.deleteCustomer();
#### Wishlist Operations
```dart
// Add product to wishlist
await vondera.customers.addToWishlist(productId: 'product-id');
// Get wishlist
final wishlist = await vondera.customers.getWishlist(
page: 1,
limit: 10,
);
// Remove from wishlist
await vondera.customers.removeFromWishlist(productId: 'product-id');
Cart Operations
// Add item to cart
await vondera.cart.addToCart(
productId: 'product-id',
quantity: 2,
variantId: 'variant-id', // Optional
options: {'Color': 'Red'}, // Optional
);
// Get cart items
final cartItems = await vondera.cart.getCart();
// Get cart with product details
final cartProducts = await vondera.cart.getCartWithProducts();
// Update cart item quantity
await vondera.cart.updateCartItem(
productId: 'product-id',
quantity: 3,
);
// Remove item from cart
await vondera.cart.removeFromCart(productId: 'product-id');
// Clear cart
await vondera.cart.clearCart();
Order Operations
// Create order
final order = await vondera.orders.createOrder(
shippingAddress: '123 Main St, City, Country',
billingAddress: '123 Main St, City, Country', // Optional
paymentMethod: 'credit_card', // Optional
);
// Get order by ID
final orderDetails = await vondera.orders.getOrder('order-id');
// Get customer orders
final orders = await vondera.orders.getOrders(
page: 1,
limit: 10,
status: 'pending', // Optional filter
);
// Cancel order
await vondera.orders.cancelOrder('order-id');
// Update order status
final updatedOrder = await vondera.orders.updateOrderStatus(
orderId: 'order-id',
status: 'shipped',
);
Custom Pages
// Get all custom pages
final pages = await vondera.customPages.getCustomPages();
// Get custom page by ID
final page = await vondera.customPages.getCustomPage('page-id');
// Get custom page by slug
final aboutPage = await vondera.customPages.getCustomPageBySlug('about');
Exception Types
ApiException- Base exception for all API errorsNetworkException- Network connectivity issuesValidationException- Request validation errors (400)UnauthorizedException- Authentication errors (401)UnknownApiException- Other API errors
API Logging
The SDK includes a built-in API logger for debugging and monitoring API calls. You can enable it during SDK initialization:
final vondera = VonderaSDK(
baseUrl: 'https://us-central1-brands-61c3d.cloudfunctions.net/app-api/api/public',
apiKey: 'YOUR_API_KEY',
logger: ApiLogger.enabled(), // Enable all logging
);
Logger Configuration
You can customize the logger behavior:
// Enable logging with custom settings
final logger = ApiLogger(
enabled: true,
shouldLogRequest: true,
shouldLogResponse: true,
shouldLogHeaders: false, // Don't log headers (default)
shouldLogBody: true,
shouldLogErrors: true,
);
final vondera = VonderaSDK(
baseUrl: '...',
apiKey: '...',
logger: logger,
);
// Or use predefined configurations
final vondera = VonderaSDK(
baseUrl: '...',
apiKey: '...',
logger: ApiLogger.enabled(), // All logging enabled
// logger: ApiLogger.disabled(), // All logging disabled (default)
);
The logger will output formatted logs to the console showing:
- Request method, URL, headers (masked), and body
- Response status, duration, headers, and body
- Error details with status codes and response bodies
Note: Sensitive headers (API keys, tokens, passwords) are automatically masked in logs.
User ID for Cart Tracking
The SDK supports user ID tracking for cart persistence. You can set it during initialization or update it later:
// Set during initialization
final vondera = VonderaSDK(
baseUrl: 'https://us-central1-brands-61c3d.cloudfunctions.net/app-api/api/public',
apiKey: 'YOUR_API_KEY',
userId: 'unique-user-id', // For cart tracking
);
// Or update later
vondera.setUserId('new-user-id');
Note: If the customer is signed up, use the customer ID. Otherwise, use a unique ID that doesn't change when the user closes the session.
API Base URL
The default base URL for Vondera API is:
https://us-central1-brands-61c3d.cloudfunctions.net/app-api/api/public
Support
For API documentation, visit: https://api.vondera.app
Libraries
- vondera_sdk
- Vondera SDK - Flutter package for interacting with Vondera REST APIs