38 lines
928 B
TypeScript
38 lines
928 B
TypeScript
import { EventBus } from "#shared/domain/EventBus.port";
|
|
import { ConsumeMessage } from "amqplib";
|
|
|
|
export class SimActivationController {
|
|
private eventBus: EventBus;
|
|
private activationUseCases: any;
|
|
|
|
constructor(
|
|
eventBus: EventBus
|
|
) {
|
|
this.eventBus = eventBus
|
|
|
|
// No se si hay un sistema mejor
|
|
// convertor en const () => {} para conservar el contexto??
|
|
this.activateSim = this.activateSim.bind(this)
|
|
}
|
|
|
|
public activateSim(msg: ConsumeMessage | null) {
|
|
if (!this.validateActivationMsg(msg)) {
|
|
throw new Error("Error consumiendo el mensaje no es valido")
|
|
}
|
|
console.log("mensaje procesado", String(msg?.content))
|
|
|
|
// Caso de uso de activaciones
|
|
//
|
|
this.eventBus.ack(msg!)
|
|
}
|
|
|
|
/**
|
|
* TODO:
|
|
* - Loguear motivos de la no validacion
|
|
*/
|
|
private validateActivationMsg(msg: ConsumeMessage | null) {
|
|
if (msg == undefined) return false;
|
|
return true;
|
|
}
|
|
}
|