import 'dart:convert';

import 'package:get/get.dart';
import 'package:ride/constant/links.dart';
import 'package:ride/controller/functions/crud.dart';

class PromosController extends GetxController {
  List<dynamic> promoList = [];
  bool isloading = true;

  @override
  void onInit() {
    getPromoBytody();
    super.onInit();
  }

  Future getPromoBytody() async {
    var res = await CRUD().get(link: AppLink.getPromoBytody, payload: {});
    if (res.toString() == 'failure') {
      Get.snackbar('failure', 'message');
      isloading = false;
      update();
    } else {
      var jsonDecoded = jsonDecode(res);

      promoList = jsonDecoded['message'];
      print(promoList);
      isloading = false;
      update();
    }
  }
}
