Usecases
This commit is contained in:
@@ -6,6 +6,7 @@ import { AxiosError } from "axios";
|
||||
export type PauseCancelTask = {
|
||||
id: number;
|
||||
iccid: string;
|
||||
operation_type: "suspend" | "terminate",
|
||||
last_checked?: Date | null;
|
||||
activation_date?: Date | null;
|
||||
next_check?: Date | null;
|
||||
@@ -13,15 +14,18 @@ export type PauseCancelTask = {
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
export type CreatePauseCancelTaskDTO = Pick<PauseCancelTask, "iccid" | "activation_date" | "next_check">
|
||||
export type CreatePauseCancelTaskDTO = Pick<PauseCancelTask, "iccid" | "activation_date" | "next_check" | "operation_type">
|
||||
export type UpdatePauseCancelTaskDTO = Pick<PauseCancelTask, "id" | "next_check">
|
||||
export type FinishPauseCancelTaskDTO = Pick<PauseCancelTask, "id" | "error">
|
||||
|
||||
/**
|
||||
* Repositorio para compensar los problemas de cacelcaiones/pausas de objenious a
|
||||
* la hora aplicarlo sobre una linea con el billing a test.
|
||||
*/
|
||||
export class PauseCancelTaskRepository {
|
||||
constructor(
|
||||
private readonly pgClient: PgClient
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,12 +55,12 @@ export class PauseCancelTaskRepository {
|
||||
public async addTask(task: CreatePauseCancelTaskDTO): Promise<Result<string, PauseCancelTask>> {
|
||||
|
||||
const sql = `
|
||||
INSERT INTO pause_cancel_tasks (iccid, activation_date, next_check, last_checked)
|
||||
VALUES ($1, $2, $3, now())
|
||||
INSERT INTO pause_cancel_tasks (iccid, activation_date, next_check, last_checked, operation_type)
|
||||
VALUES ($1, $2, $3, now(), $4)
|
||||
RETURNING *;
|
||||
`;
|
||||
try {
|
||||
const values = [task.iccid, task.activation_date, task.next_check];
|
||||
const values = [task.iccid, task.activation_date, task.next_check, task.operation_type];
|
||||
const res: QueryResult<PauseCancelTask> = await this.pgClient.query(sql, values);
|
||||
return {
|
||||
data: res.rows[0]
|
||||
@@ -66,7 +70,6 @@ export class PauseCancelTaskRepository {
|
||||
error: (e as AxiosError).message
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user