Subscripciones de ALAI
This commit is contained in:
@@ -5,11 +5,15 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: {{baseAlai}}/preactivate
|
url: {{baseAlai}}/preactivate?iccid=8934909001400027654
|
||||||
body: none
|
body: none
|
||||||
auth: inherit
|
auth: inherit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
iccid: 8934909001400027654
|
||||||
|
}
|
||||||
|
|
||||||
settings {
|
settings {
|
||||||
encodeUrl: true
|
encodeUrl: true
|
||||||
timeout: 0
|
timeout: 0
|
||||||
|
|||||||
@@ -51,6 +51,79 @@ export namespace AlaiAPI {
|
|||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type UpdateSubscriptionDTO = {
|
||||||
|
location: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Subscription = {
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
domain: string,
|
||||||
|
status: string,
|
||||||
|
networkStatus: string,
|
||||||
|
type: string,
|
||||||
|
portabilityStatus: string,
|
||||||
|
billingType: string,
|
||||||
|
creationDate: string, // ISODATE
|
||||||
|
firstActivationDate: string, // ISODATE
|
||||||
|
terminationDate: string, // ISODATE
|
||||||
|
balance: number,
|
||||||
|
balanceExpirationDate: string, // ISODATE
|
||||||
|
lastTrafficDate: string, // ISODATE
|
||||||
|
externalName: string,
|
||||||
|
language: string,
|
||||||
|
ntwID: string,
|
||||||
|
publicIdentity: string,
|
||||||
|
externalID: string,
|
||||||
|
priceplan: {
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
pricePlanName: string
|
||||||
|
},
|
||||||
|
salesData: {
|
||||||
|
salesChannel: string,
|
||||||
|
salesPerson: string,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
country: string,
|
||||||
|
state: string,
|
||||||
|
county: string,
|
||||||
|
city: string,
|
||||||
|
street: string,
|
||||||
|
postalCode: string,
|
||||||
|
number: string,
|
||||||
|
description: string,
|
||||||
|
neighborhood: string,
|
||||||
|
typeSettlement: string,
|
||||||
|
normalized: boolean,
|
||||||
|
externalID: string,
|
||||||
|
externalType: string,
|
||||||
|
spainSpecial: {
|
||||||
|
externalRefList:
|
||||||
|
{
|
||||||
|
refId: string,
|
||||||
|
refType: string
|
||||||
|
}[],
|
||||||
|
streetType: number,
|
||||||
|
ineCityCode: string,
|
||||||
|
ineSingularEntityCode: string,
|
||||||
|
floor: string,
|
||||||
|
door: string,
|
||||||
|
apartmentNumber: string,
|
||||||
|
staircaseNumber: string,
|
||||||
|
streetNrLast: string,
|
||||||
|
streetNrLastSuffix: string,
|
||||||
|
subUnitNumber: string,
|
||||||
|
buildingName: string,
|
||||||
|
homeID: string
|
||||||
|
},
|
||||||
|
iranSpecial: unknown,
|
||||||
|
mexicoSpecial: unknown,
|
||||||
|
brazilSpecial: unknown,
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export type CreateOrderResponseDTO = {
|
export type CreateOrderResponseDTO = {
|
||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
|
|||||||
@@ -106,10 +106,68 @@ export class AlaiRepository {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IMPORTANTE:
|
||||||
|
* - En el campo subscription viene el id para los cambios de estado, no se hacen
|
||||||
|
* sobre la sim, sino sobre la subscription
|
||||||
|
*/
|
||||||
public async getSimByICCID(iccid: string) {
|
public async getSimByICCID(iccid: string) {
|
||||||
const endpoint = `/v1/sim/${iccid}`
|
const endpoint = `/v1/sim/${iccid}`
|
||||||
const promReq = this.httpClient.get<AlaiAPI.Sim | undefined>(endpoint, undefined)
|
const promReq = this.httpClient.get<AlaiAPI.Sim | undefined>(endpoint, undefined)
|
||||||
const res = await this.manageRequest(promReq)
|
const res = await this.manageRequest(promReq)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async pauseSubscription(subscriptionId: string) {
|
||||||
|
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||||
|
// En teoria ahora se usa ["action", "BLOCK"] pero no he probado
|
||||||
|
const params = new URLSearchParams([
|
||||||
|
["action", "CHANGE_STATUS"]
|
||||||
|
])
|
||||||
|
const data = {
|
||||||
|
status: "BLOCKEDCORE"
|
||||||
|
}
|
||||||
|
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, data)
|
||||||
|
const res = await this.manageRequest(promReq)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
public async unPauseSubscription(subscriptionId: string) {
|
||||||
|
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||||
|
// En teoria ahora se usa ["action", "UNBLOCK"] pero no he probado
|
||||||
|
const params = new URLSearchParams([
|
||||||
|
["action", "CHANGE_STATUS"]
|
||||||
|
])
|
||||||
|
const data = {
|
||||||
|
status: "ACTIVE"
|
||||||
|
}
|
||||||
|
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, data)
|
||||||
|
const res = await this.manageRequest(promReq)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
public async terminateSubscription(subscriptionId: string) {
|
||||||
|
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||||
|
// Esta llamada si es de acuerdo a la docu
|
||||||
|
const params = new URLSearchParams([
|
||||||
|
["action", "TERMINATE"]
|
||||||
|
])
|
||||||
|
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, undefined)
|
||||||
|
const res = await this.manageRequest(promReq)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
public async changeExternalId(subscriptionId: string, externalId: string) {
|
||||||
|
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||||
|
// Esta llamada si es de acuerdo a la docu
|
||||||
|
const params = new URLSearchParams([
|
||||||
|
["action", "MODIFY"]
|
||||||
|
])
|
||||||
|
const data = {
|
||||||
|
externalID: externalId
|
||||||
|
}
|
||||||
|
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, data)
|
||||||
|
const res = await this.manageRequest(promReq)
|
||||||
|
return res
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user