Misma info de sim para el /select
This commit is contained in:
@@ -5,16 +5,16 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: https://api-getway.objenious.com/ws/lines?pageSize=1000&simStatus=ACTIVATED
|
url: https://api-getway.objenious.com/ws/lines?identifier.identifierType=ICCID&identifier.identifiers=8933201125065160455
|
||||||
body: formUrlEncoded
|
body: formUrlEncoded
|
||||||
auth: bearer
|
auth: bearer
|
||||||
}
|
}
|
||||||
|
|
||||||
params:query {
|
params:query {
|
||||||
pageSize: 1000
|
identifier.identifierType: ICCID
|
||||||
simStatus: ACTIVATED
|
identifier.identifiers: 8933201125065160455
|
||||||
~identifier.identifierType: ICCID
|
~pageSize: 1000
|
||||||
~identifier.identifiers: 8933201125065160455
|
~simStatus: ACTIVATED
|
||||||
}
|
}
|
||||||
|
|
||||||
auth:bearer {
|
auth:bearer {
|
||||||
|
|||||||
41
docs/sim-objenious/Line by iccid.bru
Normal file
41
docs/sim-objenious/Line by iccid.bru
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
meta {
|
||||||
|
name: Line by iccid
|
||||||
|
type: http
|
||||||
|
seq: 22
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://api-getway.objenious.com/ws/lines?pageSize=1000&simStatus=ACTIVATED
|
||||||
|
body: formUrlEncoded
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
pageSize: 1000
|
||||||
|
simStatus: ACTIVATED
|
||||||
|
~identifier.identifierType: ICCID
|
||||||
|
~identifier.identifiers: 8933201125065160455
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{ws-access-token-partenaire}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"identifier": {
|
||||||
|
"identifiers": ["8933201124059175967"],
|
||||||
|
"identifierType": "ICCID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:form-urlencoded {
|
||||||
|
~identifier.identifierType: "ICCID"
|
||||||
|
~identifier.identifiers: ["8933201124059175967"]
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import { ActionData } from "#domain/DTOs/objeniousapi.js";
|
|||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { PaginationArgs, QueryPaginationArgs } from "sim-shared/domain/PaginationArgs.js";
|
import { PaginationArgs, QueryPaginationArgs } from "sim-shared/domain/PaginationArgs.js";
|
||||||
import { paginationValidator } from "./httpValidators.js";
|
import { paginationValidator } from "./httpValidators.js";
|
||||||
|
import { error } from "node:console";
|
||||||
|
import { objeniousSimToCommon } from "#domain/transformers.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* La clase usa generadores de funciones para mantener el contexto
|
* La clase usa generadores de funciones para mantener el contexto
|
||||||
@@ -236,7 +238,7 @@ export class SimController {
|
|||||||
|
|
||||||
const validationRes = paginationValidator.validate(paginationArgs)
|
const validationRes = paginationValidator.validate(paginationArgs)
|
||||||
if (validationRes.error != undefined) {
|
if (validationRes.error != undefined) {
|
||||||
res.status(402).json(validationRes)
|
res.status(422).json(validationRes)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +254,28 @@ export class SimController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Una única linea para /select
|
||||||
|
*/
|
||||||
|
public queryLine() {
|
||||||
|
return async (req: Request, res: Response) => {
|
||||||
|
const queryParams = req.query
|
||||||
|
const queryArgs = {
|
||||||
|
iccid: queryParams.iccid as string // La validacion de iccid se ha tenido que hacer en el gateway
|
||||||
|
}
|
||||||
|
|
||||||
|
const line = await this.useCases.getLineByIccid(queryArgs.iccid)
|
||||||
|
if (line.error != undefined) {
|
||||||
|
res.status(line.error.code).json(line)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const commonLine = objeniousSimToCommon(line.data)
|
||||||
|
|
||||||
|
res.status(200).json({ data: commonLine })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO:
|
* TODO:
|
||||||
* - Loguear motivos de la no validacion
|
* - Loguear motivos de la no validacion
|
||||||
|
|||||||
@@ -488,4 +488,32 @@ export class SimUseCases {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async getLineByIccid(iccid: string):
|
||||||
|
Promise<Result<{ msg: string, code: number }, ObjeniousLine>> {
|
||||||
|
const line = await this.objeniousRepository.getLineByIccid(iccid)
|
||||||
|
|
||||||
|
if (line.error != undefined) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
msg: "Error general buscando la sim",
|
||||||
|
code: 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.data.length == 0) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
msg: "Sim no encontrada",
|
||||||
|
code: 204
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: line.data[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
46
packages/sim-consumidor-objenious/domain/transformers.ts
Normal file
46
packages/sim-consumidor-objenious/domain/transformers.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { CommonSim } from "sim-shared/domain/CommonSim.js";
|
||||||
|
import { ObjeniousLine } from "sim-shared/domain/objeniousLine.js";
|
||||||
|
|
||||||
|
type ObjeniousBillingStates = ObjeniousLine["status"]["billingStatus"]
|
||||||
|
type ObjeniousNetworkStates = ObjeniousLine["status"]["networkStatus"]
|
||||||
|
|
||||||
|
//"PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||||
|
const objeiousStates = new Map<ObjeniousBillingStates, CommonSim<any>["billing_status"]>([
|
||||||
|
["ACTIVATED", "ACTIVE"],
|
||||||
|
["CANCELED", "TERMINATED"],
|
||||||
|
["SUSPENDED", "SUSPENDED"],
|
||||||
|
["TEST", "PREACTIVATED"]
|
||||||
|
])
|
||||||
|
|
||||||
|
const objeiousNetworkStates = new Map<ObjeniousNetworkStates, CommonSim<any>["network_status"]>([
|
||||||
|
["ACTIVATED", "ACTIVE"],
|
||||||
|
["CANCELED", "TERMINATED"],
|
||||||
|
["SUSPENDED", "SUSPENDED"],
|
||||||
|
["BARRED", "SUSPENDED"]
|
||||||
|
])
|
||||||
|
|
||||||
|
export function objeniousSimToCommon(objSim: ObjeniousLine): CommonSim<ObjeniousLine> {
|
||||||
|
const status = objeiousStates.get(objSim.status.billingStatus) ?? "UNKNOWN"
|
||||||
|
const networkStatus = objeiousNetworkStates.get(objSim.status.networkStatus) ?? "UNKNOWN"
|
||||||
|
|
||||||
|
const preDate = objSim.status.preactivationDate
|
||||||
|
const actDate = objSim.status.activationDate
|
||||||
|
|
||||||
|
const preactivate = (preDate) ? new Date(preDate) : null
|
||||||
|
const activate = (actDate) ? new Date(actDate) : null
|
||||||
|
|
||||||
|
const common: CommonSim<ObjeniousLine> = {
|
||||||
|
company: "OBJ",
|
||||||
|
tariff: objSim.offer.code,
|
||||||
|
iccid: objSim.identifier.iccid,
|
||||||
|
msisdn: objSim.identifier.msisdn,
|
||||||
|
billing_status: status,
|
||||||
|
network_status: networkStatus,
|
||||||
|
raw: objSim,
|
||||||
|
imei: objSim.identifier.imei,
|
||||||
|
preactivation_date: preactivate,
|
||||||
|
activation_date: activate
|
||||||
|
}
|
||||||
|
|
||||||
|
return common
|
||||||
|
}
|
||||||
@@ -97,6 +97,7 @@ async function startWorker() {
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
app.get("/lines", simController.queryLines())
|
app.get("/lines", simController.queryLines())
|
||||||
|
app.get("/select", simController.queryLine())
|
||||||
|
|
||||||
|
|
||||||
assert.ok(port, "Puerto del servicio no definido")
|
assert.ok(port, "Puerto del servicio no definido")
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export type ObjeniousLine = {
|
|||||||
activationDate: string | null, //"2026-03-17T11:04:11.408+00:00",
|
activationDate: string | null, //"2026-03-17T11:04:11.408+00:00",
|
||||||
commercialStatus: string, //"test",
|
commercialStatus: string, //"test",
|
||||||
commercialStatusDate: string, //"2026-03-17T11:41:01.493+00:00",
|
commercialStatusDate: string, //"2026-03-17T11:41:01.493+00:00",
|
||||||
networkStatus: string, // "ACTIVATED",
|
networkStatus: "ACTIVATED" | "SUSPENDED" | "CANCELED" | "BARRED", // "ACTIVATED",
|
||||||
billingStatus: "ACTIVATED" | "SUSPENDED" | "CANCELED" | "TEST",
|
billingStatus: "ACTIVATED" | "SUSPENDED" | "CANCELED" | "TEST",
|
||||||
billingStatusChangeDate: string | null, // "2026-03-17T11:01:00.276+00:00",
|
billingStatusChangeDate: string | null, // "2026-03-17T11:01:00.276+00:00",
|
||||||
billingActivationDate: string | null //,
|
billingActivationDate: string | null //,
|
||||||
|
|||||||
@@ -14,6 +14,33 @@ export class ObjeniousOperationsRepository implements IOperationsRepository {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getLineByIccid(iccid: string): Promise<Result<string, ObjeniousLine[]>> {
|
||||||
|
const path = "/lines"
|
||||||
|
const params = new URLSearchParams([
|
||||||
|
["identifier.identifierType", "ICCID"],
|
||||||
|
["identifier.identifiers", iccid]
|
||||||
|
])
|
||||||
|
|
||||||
|
const req = this.http.client.get<ObjeniousLineResponse>(path, {
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = await tryCatch(req)
|
||||||
|
|
||||||
|
if (res.error != undefined) {
|
||||||
|
return {
|
||||||
|
error: res.error?.message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const lines = res.data.data.content
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: lines
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consulta el estado de una o mas lineas directamente a la API de Objenious
|
* Consulta el estado de una o mas lineas directamente a la API de Objenious
|
||||||
* TODO: No hay paginacion como en getLinesByStatusAPI
|
* TODO: No hay paginacion como en getLinesByStatusAPI
|
||||||
|
|||||||
Reference in New Issue
Block a user