79 lines
1.7 KiB
TypeScript
79 lines
1.7 KiB
TypeScript
/**
|
|
* 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";
|
|
import { NosRepository } from "infrastructure/NosRepository";
|
|
|
|
export class SimNosUsecases {
|
|
constructor(
|
|
private httpClient: NosHttpClient,
|
|
private nosRepository: NosRepository
|
|
) {
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public terminate(args: { iccid: string }) {
|
|
throw new Error("No hay termination para NOS")
|
|
}
|
|
|
|
public async selectOne(args: {
|
|
iccid: string
|
|
}) {
|
|
const res = await this.nosRepository.getLineInfo(args.iccid)
|
|
return res
|
|
}
|
|
|
|
public async selectPage(args: {
|
|
|
|
}) {
|
|
const res = await this.nosRepository.getLinePage(args)
|
|
return res
|
|
}
|
|
|
|
public selectMany(args: {
|
|
iccid: string[]
|
|
}) {
|
|
return {}
|
|
}
|
|
}
|