Files
sf-sim/packages/sim-consumidor-nos/aplication/SimNOS.usecases.ts

60 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-04-16 17:46:32 +02:00
/**
* Documentación de referencia:
* https://pelion-help.iot-x.com/nos/en-US/Content/API/APIReference/API%20Reference.htm?tocpath=_____7
*
* TODO:
* - Control de errores más preciso
*
*/
import { NosHttpClient } from "infrastructure/NosHttpClient";
2026-04-17 15:49:53 +02:00
import { NosRepository } from "infrastructure/NosRepository";
2026-04-16 17:46:32 +02:00
export class SimNosUsecases {
constructor(
2026-04-17 14:06:41 +02:00
private httpClient: NosHttpClient,
private nosRepository: NosRepository
2026-04-16 17:46:32 +02:00
) {
}
2026-04-17 15:49:53 +02:00
public activate(args: { iccid: string }) {
return async () => {
try {
return await this.nosRepository.activateSim(args.iccid)
} catch (e) {
return {
error: "Error general de activación de sim" + String(e)
}
}
2026-04-16 17:46:32 +02:00
}
}
2026-04-17 15:49:53 +02:00
public suspend(args: { iccid: string }) {
return async () => {
try {
return await this.nosRepository.bar(args.iccid)
} catch (e) {
return {
error: "Error general de suspension de sim" + String(e)
}
}
}
2026-04-17 14:06:41 +02:00
}
2026-04-17 15:49:53 +02:00
public reactivate(args: { iccid: string }) {
return async () => {
try {
return await this.nosRepository.unbar(args.iccid)
} catch (e) {
return {
error: "Error general de reactivación de sim" + String(e)
}
}
}
}
2026-04-17 14:06:41 +02:00
2026-04-17 15:49:53 +02:00
public terminate(args: { iccid: string }) {
throw new Error("No hay termination para NOS")
2026-04-17 14:06:41 +02:00
}
2026-04-16 17:46:32 +02:00
}