Todos los datos de Alai para agrupar
This commit is contained in:
@@ -6,8 +6,8 @@ ALAI_API_URL=https://wsaccess.alaisecure.com/bssrest
|
||||
ALAI_CERTIFICATES_DIR=./certificates/
|
||||
ALAI_CERTIFICATE_NAME=wsaccess_alaisecure_com_cert_client_new.p12
|
||||
ALAI_CERTIFICATE_PASSWORD=iHaaek+zyzWz6cH6rg==
|
||||
ALAI_USERNAME=infosavefamily
|
||||
ALAI_PASSWORD=infosavefamily
|
||||
ALAI_USERNAME=palomaibanez
|
||||
ALAI_PASSWORD=palomaibanez123
|
||||
ALAI_BRANDID=savefamily
|
||||
|
||||
ALAI_PACKAGE=Tarifa_250MB_100MIN_5SMS
|
||||
|
||||
@@ -149,7 +149,8 @@ export class SimAlaiController {
|
||||
// TODO: Automatizar la paginacion
|
||||
//const usecaseRes = this.uscases.selectMany({ iccid })
|
||||
} else {
|
||||
const usecaseRes = await this.uscases.selectOne(iccid)
|
||||
//const usecaseRes = await this.uscases.selectOne(iccid)
|
||||
const usecaseRes = await this.uscases.selectCompleteSim(iccid)
|
||||
if (usecaseRes.error != undefined) {
|
||||
res.status(500).json(usecaseRes)
|
||||
return;
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
* - Control de errores más preciso
|
||||
*
|
||||
*/
|
||||
import { AlaiAPI } from "#domain/AlaiAPI.js";
|
||||
import { AlaiRepository } from "#infrastructure/AlaiRepository.js";
|
||||
import { ConsumeMessage } from "amqplib";
|
||||
import { ErrorOrderDTO, FinishOrderDTO, UpdateOrderDTO } from "sim-shared/domain/Order.js";
|
||||
import { Result } from "sim-shared/domain/Result.js";
|
||||
import { HttpClient } from "sim-shared/infrastructure/HTTPClient.js";
|
||||
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
||||
import { isOmittedExpression } from "typescript";
|
||||
|
||||
export class SimAlaiUsecases {
|
||||
constructor(
|
||||
@@ -219,4 +221,42 @@ export class SimAlaiUsecases {
|
||||
const sim = await this.alaiRepository.getSimByICCID(iccid)
|
||||
return sim
|
||||
}
|
||||
|
||||
/**
|
||||
* Para sacar los datos de una liena hay que sacar sim -> subscripcion -> imei
|
||||
* son 3 llamadas distintas.
|
||||
*/
|
||||
public async selectCompleteSim(iccid: string): Promise<Result<string, {
|
||||
sim: AlaiAPI.Sim,
|
||||
subscription: AlaiAPI.Subscription,
|
||||
imei: AlaiAPI.GetImeiSubscriptionDTO
|
||||
}>> {
|
||||
const sim = await this.alaiRepository.getSimByICCID(iccid)
|
||||
|
||||
if (sim.error != undefined) {
|
||||
return sim
|
||||
}
|
||||
|
||||
const subscriptionId = sim.data!.subscription.id
|
||||
const subscription = await this.alaiRepository.getSubscriptionById(subscriptionId)
|
||||
|
||||
if (subscription.error != undefined) {
|
||||
return subscription
|
||||
}
|
||||
|
||||
const imei = await this.alaiRepository.getImeiFromSubscription(subscriptionId)
|
||||
if (imei.error != undefined) {
|
||||
return imei
|
||||
}
|
||||
|
||||
return {
|
||||
data: {
|
||||
sim: sim.data!,
|
||||
subscription: subscription.data!,
|
||||
imei: imei.data!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,14 +176,14 @@ export class AlaiRepository {
|
||||
|
||||
public async getSubscriptionById(subscriptionId: string) {
|
||||
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||
const promReq = this.httpClient.patch<AlaiAPI.Subscription | undefined>(endpoint)
|
||||
const promReq = this.httpClient.get<AlaiAPI.Subscription | undefined>(endpoint)
|
||||
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 promReq = this.httpClient.get<AlaiAPI.GetImeiSubscriptionDTO | undefined>(endpoint)
|
||||
const res = await this.manageRequest(promReq)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ export type CommonSim<T> = {
|
||||
activation_date?: Date | null,
|
||||
suspension_date?: Date | null,
|
||||
termination_date?: Date | null,
|
||||
imei: string,
|
||||
imei?: string,
|
||||
raw: T
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user