import { Event } from '@sanar/payments-sdk'; import { HttpRequestService } from './http.request.service'; require('dotenv/config'); export class WalletsService { private static instance: WalletsService; private httpService: HttpRequestService; constructor() { this.httpService = new HttpRequestService( process.env.WALLETS_URL, ); } static getInstance() : WalletsService { if (!this.instance) { this.instance = new WalletsService(); } return this.instance; } async findCustomer(email: string) : Promise { const result = await this.httpService.get('/customers', { params: { where: { user: { email, }, }, }, }); if (!(result.data.customers?.length > 0)) { throw new Error('Customer not found'); } return result.data.customers[0]; } }