import { inject, Injectable } from '@angular/core';
import { CrmSearchService } from '../services';
import {
  AddCardInput,
  FetchCustomerCardsInput,
  LockCardInput,
  UnlockCardInput,
} from '../schemas';
import { AccountDetailsDTO } from '@generated/swagger/crm-api';

@Injectable({ providedIn: 'root' })
export class CustomerCardsFacade {
  #crmSearchService = inject(CrmSearchService);

  async get(params: FetchCustomerCardsInput, abortSignal?: AbortSignal) {
    return await this.#crmSearchService.fetchCustomerCards(
      { ...params },
      abortSignal,
    );
  }

  async addCard(params: AddCardInput): Promise<AccountDetailsDTO | undefined> {
    return this.#crmSearchService.addCard(params);
  }

  async lockCard(params: LockCardInput): Promise<boolean | undefined> {
    return this.#crmSearchService.lockCard(params);
  }

  async unlockCard(params: UnlockCardInput): Promise<boolean | undefined> {
    return this.#crmSearchService.unlockCard(params);
  }
}
