Imei from subscription, SIM común
This commit is contained in:
32
docs/sim-alai/Change External ID.yml
Normal file
32
docs/sim-alai/Change External ID.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
info:
|
||||
name: Change External ID
|
||||
type: http
|
||||
seq: 7
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{baseurl}}/v1/subscription/{{subscription}}?action=MODIFY"
|
||||
params:
|
||||
- name: action
|
||||
value: MODIFY
|
||||
type: query
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"externalID":""
|
||||
}
|
||||
auth:
|
||||
type: bearer
|
||||
token: "{{alai_token}}"
|
||||
|
||||
runtime:
|
||||
variables:
|
||||
- name: subscription
|
||||
value: ""
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
22
docs/sim-alai/IMEI of subscription.yml
Normal file
22
docs/sim-alai/IMEI of subscription.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
info:
|
||||
name: IMEI of subscription
|
||||
type: http
|
||||
seq: 5
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{baseurl}}/v1/subscription/{{subscription}}/imei"
|
||||
auth:
|
||||
type: bearer
|
||||
token: "{{alai_token}}"
|
||||
|
||||
runtime:
|
||||
variables:
|
||||
- name: subscription
|
||||
value: SID1848557_TS1766417781101_0
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
@@ -22,7 +22,7 @@ runtime:
|
||||
code: |-
|
||||
const data = res.getBody();
|
||||
|
||||
if (data.staus != 200) {
|
||||
if (data.status != 200) {
|
||||
console.error("Error de login: ", data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ http:
|
||||
url: "{{baseurl}}/v1/sim/{{iccid}}"
|
||||
auth:
|
||||
type: bearer
|
||||
token: ""
|
||||
token: "{{alai_token}}"
|
||||
|
||||
runtime:
|
||||
variables:
|
||||
|
||||
22
docs/sim-alai/Subscription.yml
Normal file
22
docs/sim-alai/Subscription.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
info:
|
||||
name: Subscription
|
||||
type: http
|
||||
seq: 4
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{baseurl}}/v1/subscription/{{subscription}}"
|
||||
auth:
|
||||
type: bearer
|
||||
token: "{{alai_token}}"
|
||||
|
||||
runtime:
|
||||
variables:
|
||||
- name: subscription
|
||||
value: SID1776275_TS1759238704226_0
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
@@ -11,3 +11,5 @@ variables:
|
||||
name: certPasswd
|
||||
- name: brandId
|
||||
value: savefamily
|
||||
- name: alai_token
|
||||
value: eyJhbGciOiJIUzM4NCJ9.eyJiciI6InNhdmVmYW1pbHkiLCJpcCI6Ijg4LjE1LjE1Ny4xNjciLCJzdWIiOiJwYWxvbWFpYmFuZXoiLCJzIjoiRVdTMTY0YWJhYWRlNjA3ZDAyIiwicG9zIjoic2F2ZWZhbWlseUNhYyIsImlkV3NVc2VyIjoiODYiLCJpc012bmEiOmZhbHNlLCJkb21haW4iOiJBbGFpfHNhdmVmYW1pbHkiLCJpYXQiOjE3NzgxNTEzMzYsImV4cCI6MTc3ODE2MjEzNn0.zCFBJJsa0Krc7n5vUFF00z9Tq7m0dRlCGzs2Od67jaLCCn-mnIyyU424PkazacRW
|
||||
|
||||
@@ -16,6 +16,7 @@ export class AlaiTokenManager implements JWTProvider<{}> {
|
||||
if (res.error != undefined) {
|
||||
console.error("Error obteniendo el token de ALAI", res.error)
|
||||
} else {
|
||||
console.log("Obtenido token de ALAI: ", res)
|
||||
this.authToken = new JWTToken(res.data.accessToken)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export class SimAlaiController {
|
||||
res.status(500).json(usecaseRes)
|
||||
return;
|
||||
} else {
|
||||
res.send(usecaseRes.data)
|
||||
res.send(usecaseRes)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { StringMappingType } from "typescript"
|
||||
|
||||
export namespace AlaiAPI {
|
||||
|
||||
export type LoginResponseDTO = {
|
||||
@@ -61,10 +63,10 @@ export namespace AlaiAPI {
|
||||
id: string,
|
||||
name: string,
|
||||
domain: string,
|
||||
status: string,
|
||||
networkStatus: string,
|
||||
type: string,
|
||||
portabilityStatus: string,
|
||||
status: Status,
|
||||
networkStatus: NetworkStatus,
|
||||
type: "RETAIL" | string,
|
||||
portabilityStatus: "NO_PORTABILITY" | string,
|
||||
billingType: string,
|
||||
creationDate: string, // ISODATE
|
||||
firstActivationDate: string, // ISODATE
|
||||
@@ -77,6 +79,13 @@ export namespace AlaiAPI {
|
||||
ntwID: string,
|
||||
publicIdentity: string,
|
||||
externalID: string,
|
||||
lastMsisdnID: string,
|
||||
msisdn: {
|
||||
id: string,
|
||||
name: string,
|
||||
links: Link[]
|
||||
},
|
||||
lastIccID: string,
|
||||
priceplan: {
|
||||
id: string,
|
||||
name: string,
|
||||
@@ -123,6 +132,16 @@ export namespace AlaiAPI {
|
||||
mexicoSpecial: unknown,
|
||||
brazilSpecial: unknown,
|
||||
},
|
||||
msisdnList: {
|
||||
id: string,
|
||||
name: string,
|
||||
links: Link[]
|
||||
}[],
|
||||
terminalList: {
|
||||
id: string,
|
||||
name: string,
|
||||
links: Link[]
|
||||
}[]
|
||||
|
||||
}
|
||||
|
||||
@@ -179,6 +198,24 @@ export namespace AlaiAPI {
|
||||
links: Link[]
|
||||
}
|
||||
|
||||
export type NetworkStatus =
|
||||
"ACTIVE" |
|
||||
"BLOCKED" |
|
||||
"DEACTIVATE" |
|
||||
"FRAUD" |
|
||||
"PRE_ACTIVE"
|
||||
|
||||
export type Status =
|
||||
"ABORTED" |
|
||||
"ACTIVE" |
|
||||
"BLOCKEDCORE" |
|
||||
"BLOCKEDFRAUD" |
|
||||
"CANCELLED" |
|
||||
"CONFIGURING" |
|
||||
"DELETED" |
|
||||
"PRE_ACTIVE" |
|
||||
"TERMINATED"
|
||||
|
||||
export type Sim = {
|
||||
id: string,
|
||||
name: string,
|
||||
@@ -227,5 +264,31 @@ export namespace AlaiAPI {
|
||||
},
|
||||
links: Link[]
|
||||
}
|
||||
|
||||
export type GetImeiSubscriptionDTO = {
|
||||
links: Link[],
|
||||
content: {
|
||||
id: string,
|
||||
sim: {
|
||||
id: string,
|
||||
links: Link[]
|
||||
},
|
||||
imsi: string,
|
||||
lastChange: string, //ISODATE
|
||||
lastUpdate: string, //ISODATE
|
||||
model: string,
|
||||
subscription: {
|
||||
id: string,
|
||||
links: Link[]
|
||||
},
|
||||
links: Link[]
|
||||
}[],
|
||||
page: {
|
||||
size: number,
|
||||
totalElements: number,
|
||||
totalPages: number,
|
||||
number: number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
packages/sim-consumidor-alai/domain/transformers.ts
Normal file
42
packages/sim-consumidor-alai/domain/transformers.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Result } from "sim-shared/domain/Result.js";
|
||||
import { AlaiAPI } from "./AlaiAPI.js";
|
||||
import { CommonSim } from "sim-shared/domain/CommonSim.js";
|
||||
|
||||
const alaiStates = new Map<AlaiAPI.Status, CommonSim<any>["billing_status"]>([
|
||||
["ABORTED", "SUSPENDED"],
|
||||
["ACTIVE", "ACTIVE"],
|
||||
["BLOCKEDCORE", "SUSPENDED"],
|
||||
["BLOCKEDFRAUD", "SUSPENDED"],
|
||||
["CANCELLED", "TERMINATED"],
|
||||
["CONFIGURING", "SUSPENDED"],
|
||||
["DELETED", "TERMINATED"],
|
||||
["PRE_ACTIVE", "PREACTIVATED"],
|
||||
["TERMINATED", "TERMINATED"]
|
||||
])
|
||||
|
||||
const alaiNetworkStates = new Map<AlaiAPI.NetworkStatus, CommonSim<any>["network_status"]>([
|
||||
["ACTIVE", "ACTIVE"],
|
||||
["PRE_ACTIVE", "PREACTIVATED"],
|
||||
["BLOCKED", "SUSPENDED"],
|
||||
["DEACTIVATE", "TERMINATED"],
|
||||
["FRAUD", "TERMINATED"]
|
||||
])
|
||||
|
||||
export function alaiSimToCommonSim(alaiSim: AlaiAPI.Sim, alaiSubscription: AlaiAPI.Subscription): Result<string, CommonSim<AlaiAPI.Sim>> {
|
||||
|
||||
const status = alaiStates.get(alaiSubscription.status) ?? "UNKNOWN"
|
||||
const networkStatus = alaiNetworkStates.get(alaiSubscription.networkStatus) ?? "UNKNOWN"
|
||||
|
||||
const commonSim: CommonSim<AlaiAPI.Sim> = {
|
||||
company: "ALAI",
|
||||
iccid: alaiSim.id,
|
||||
msisdn: alaiSubscription.lastMsisdnID,
|
||||
billing_status: status,
|
||||
network_status: networkStatus,
|
||||
raw: alaiSim
|
||||
}
|
||||
|
||||
return {
|
||||
data: commonSim
|
||||
}
|
||||
}
|
||||
@@ -180,4 +180,11 @@ export class AlaiRepository {
|
||||
const res = await this.manageRequest(promReq)
|
||||
return res
|
||||
}
|
||||
|
||||
public async getImeiFromSubscription(subscriptionId: string) {
|
||||
const endpoint = `/v1/subscription/${subscriptionId}/imei`
|
||||
const promReq = this.httpClient.patch<AlaiAPI.GetImeiSubscriptionDTO | undefined>(endpoint)
|
||||
const res = await this.manageRequest(promReq)
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export type CommonSim = {
|
||||
export type CommonSim<T> = {
|
||||
company: "NOS" | "OBJ" | "ALAI",
|
||||
iccid: string,
|
||||
msisdn: string,
|
||||
tariff: string, // Depende de la compañia
|
||||
billing_state: "AVAILABLE" | "PREACTIVATED" | "ACTIVATED" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
network_state: "AVAILABLE" | "PREACTIVATED" | "ACTIVATED" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
billing_status: "PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
network_status: "AVAILABLE" | "PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
preactivation_date?: Date | null,
|
||||
activation_date?: Date | null,
|
||||
suspension_date?: Date | null,
|
||||
termination_date?: Date | null,
|
||||
imei: string,
|
||||
raw: any
|
||||
raw: T
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user