2026-01-13 15:41:59 +01:00
|
|
|
import { EventBus } from "../../shared/domain/EventBus.port";
|
|
|
|
|
import { SimEvents } from "../../shared/domain/SimEvents";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO:
|
|
|
|
|
* - Conexion con la BDD
|
|
|
|
|
* - Conexion con RabbitMQ
|
|
|
|
|
* - Pasar a clase cuando existan las conexiones
|
|
|
|
|
*/
|
|
|
|
|
export class SimUsecases {
|
|
|
|
|
private eventBus: EventBus
|
|
|
|
|
|
|
|
|
|
constructor(args: {
|
|
|
|
|
eventBus: EventBus
|
|
|
|
|
}
|
|
|
|
|
) {
|
|
|
|
|
this.eventBus = args.eventBus
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async activation(args: { iccid: string }) {
|
|
|
|
|
const activationEvent = <SimEvents.activation>{
|
|
|
|
|
key: "sim.activation",
|
|
|
|
|
payload: {
|
|
|
|
|
iccid: args.iccid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.eventBus.publish([activationEvent])
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 10:19:49 +01:00
|
|
|
async cancelation(args: { iccid: string }) {
|
|
|
|
|
const cancelationEvent = <SimEvents.cancelation>{
|
|
|
|
|
key: "sim.cancelation",
|
|
|
|
|
payload: {
|
|
|
|
|
iccid: args.iccid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.eventBus.publish([cancelationEvent])
|
2026-01-13 15:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 10:19:49 +01:00
|
|
|
async pause(args: { iccid: string }) {
|
|
|
|
|
const cancelationEvent = <SimEvents.pause>{
|
|
|
|
|
key: "sim.pause",
|
|
|
|
|
payload: {
|
|
|
|
|
iccid: args.iccid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.eventBus.publish([cancelationEvent])
|
2026-01-13 15:41:59 +01:00
|
|
|
}
|
2026-01-14 10:19:49 +01:00
|
|
|
async free(args: { iccid: string }) {
|
|
|
|
|
const cancelationEvent = <SimEvents.free>{
|
|
|
|
|
key: "sim.free",
|
|
|
|
|
payload: {
|
|
|
|
|
iccid: args.iccid
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.eventBus.publish([cancelationEvent])
|
2026-01-13 15:41:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|