import 'package:taafee_mobile/core/network/http.dart';
import 'package:taafee_mobile/features/account/data_layer/model/change_password.dart';
import 'package:taafee_mobile/features/account/data_layer/model/edit_account.dart';
import 'package:taafee_mobile/features/account/data_layer/model/feedback.dart';
import 'package:taafee_mobile/features/card/data_layer/model/card_model.dart';

import '../../../../core/apis/apis.dart';

class AccountService {
  Future<void> editProfile(EditAccountModel editAccountModel) async {
    Request request = Request(
      EndPoint.editAccount,
      RequestMethod.post,
      isFormData: true,
      body: await editAccountModel.toJson(),
      authorized: true,
    );
    await request.sendRequest();
  }

  Future<void> changePassword(ChangePasswordModel changePasswordModel) async {
    Request request = Request(
      EndPoint.changePassword,
      RequestMethod.post,
      authorized: true,
      isFormData: true,
      body: changePasswordModel.toJson(),
    );
    await request.sendRequest();
  }

  ///-----------------user cards---------------///
  Future<List<CardModel>> getUserCards() async {
    Request request =
        Request(EndPoint.editAccount, RequestMethod.get, authorized: true);
    Map<String, dynamic> response = await request.sendRequest();
    return CardModel.fromJsonList(response);
  }

  /// --------------- feedback ---------------///
  Future sendFeedback(FeedbackMessage feedbackMessage) async {
    Request request = Request(
      EndPoint.feedback,
      RequestMethod.post,
      authorized: true,
      isFormData: true,
      body: feedbackMessage.toJson(),
    );
    await request.sendRequest();
  }
}
