import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/core/model/pharmacies/LacumAccountInformation.dart';
import 'package:hmg_patient_app/core/model/pharmacies/ListUserAgreement.dart';

import 'lacum-service.dart';

class LacumRegistrationService extends LacumService{

  ListUserAgreement? listUserAgreement;

  Future getLacumAccountInformationById(String patientIdentificationNo) async {
    hasError = false;
    super.error = "";

    Map<String, dynamic> body = Map();
    body['IdentificationNo'] = patientIdentificationNo;

    try {
      await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION,
          onSuccess: (response, statusCode) async {
            lacumInformation = LacumAccountInformation.fromJson(response);
          }, onFailure: (String error, int statusCode) {
            hasError = true;
            super.error = error;
          }, body: body);
    } catch (error) {
      throw error;
    }
  }

  Future getUserTermsAndConditionsForEPharmcy() async {
    hasError = false;
    super.error = "";

    Map<String, dynamic> body = Map();

    try {
      await baseAppClient.post(LAKUM_GET_USER_TERMS_AND_CONDITIONS,
          onSuccess: (response, statusCode) async {
            listUserAgreement = ListUserAgreement.fromJson(response['ListUserAgreement'][0]);
          }, onFailure: (String error, int statusCode) {
            hasError = true;
            super.error = error;
          }, body: body);
    } catch (error) {
      throw error;
    }
  }

}