import 'dart:convert';

import 'package:app_petty_cash/model/company_model.dart';
import 'package:app_petty_cash/model/list_type_model.dart';

import '../app/constant.dart';
import '../model/history_transaksi_model.dart';
import '../model/list_category_model.dart';
import 'base_repository.dart';

class CompanyRepository extends BaseRepository {
  CompanyRepository({required super.dio});

  // list company
  Future<List<CompanyModel>> getListCompany({required String userID}) async {
    // https: //devone.aplikasi.web.id/one-api-pettycash/pettycash/Usercompany/list_company?M_UserID=2
    final service =
        "${Constant.baseUrlDevone}Usercompany/list_company?M_UserID=${userID}";
    final resp = await get(
      service: service,
    );

    print("url list type : $service");

    final result = List<CompanyModel>.empty(growable: true);
    resp['data'].forEach((e) {
      final model = CompanyModel.fromJson(e);
      result.add(model);
    });
    return result;
  }
}
