flasho_merchant_sdk 1.0.0 copy "flasho_merchant_sdk: ^1.0.0" to clipboard
flasho_merchant_sdk: ^1.0.0 copied to clipboard

Official Dart/Flutter SDK for the Flasho Merchant API. Book on-demand and scheduled deliveries, get price quotes, and track orders.

example/lib/main.dart

import 'package:flasho_merchant_sdk/flasho_merchant_sdk.dart';

void main() async {
  // ── Create client ──────────────────────────────────────────────────────────
  final flasho = FlashoClient(apiKey: 'flsh_YOUR_KEY');

  // ── Bootstrap ──────────────────────────────────────────────────────────────
  final data = await flasho.account.bootstrap();
  print('Account: ${data.account.sellerName}');
  print('Balance: ${data.walletBalance} KWD');
  print('Branches: ${data.branches.length}');

  // ── Price quote ────────────────────────────────────────────────────────────
  final quote = await flasho.pricing.calculate(
    CalculatePriceRequest(
      fromLatitude: 29.3764,
      fromLongitude: 47.9785,
      toLatitude: 29.3117,
      toLongitude: 48.0034,
    ),
  );
  print('Delivery fee: ${quote.price} ${quote.currency}');
  print('Distance: ${quote.distance} ${quote.distanceUnit}');
  print('ETA: ${quote.estimatedDuration} minutes');

  // ── Create on-demand delivery ──────────────────────────────────────────────
  final delivery = await flasho.deliveries.create(
    CreateDeliveryRequest(
      customerName: 'Ahmed Ali',
      customerNumber: '99887766',
      pickupLatitude: 29.3764,
      pickupLongitude: 47.9785,
      deliveryLatitude: 29.3117,
      deliveryLongitude: 48.0034,
      deliveryAddress: ['Kuwait', 'Salmiya', 'Block 3', 'Street 1', 'House 12'],
      specialNotes: 'Leave at reception',
    ),
  );
  print('Created: ${delivery.orderNumber} — ${delivery.status.name}');

  // ── Poll until terminal state ──────────────────────────────────────────────
  // (commented out so the example doesn't block forever without a real order)
  //
  // final final = await flasho.deliveries.poll(
  //   delivery.id,
  //   interval: const Duration(seconds: 5),
  //   onUpdate: (d) => print('→ ${d.status.name}'),
  // );
  // print('Final: ${final.status.name}');

  // ── Scheduled delivery ─────────────────────────────────────────────────────
  final settings = await flasho.account.getScheduledDeliverySettings();
  print('Scheduled available: ${settings.available}');
  print('Surcharge: ${settings.surchargeKwd} KWD');

  if (settings.available) {
    final scheduled = await flasho.deliveries.create(
      CreateDeliveryRequest(
        customerName: 'Ahmed Ali',
        customerNumber: '99887766',
        pickupLatitude: 29.3764,
        pickupLongitude: 47.9785,
        deliveryLatitude: 29.3117,
        deliveryLongitude: 48.0034,
        isScheduled: true,
        scheduledDeliveryAt:
            DateTime.now().toUtc().add(const Duration(hours: 2)),
      ),
    );
    print('Scheduled: ${scheduled.orderNumber}');
  }
}
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Official Dart/Flutter SDK for the Flasho Merchant API. Book on-demand and scheduled deliveries, get price quotes, and track orders.

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

http

More

Packages that depend on flasho_merchant_sdk