import { Code } from "@/constants/enum/general/code.enum"; export class RestfulResponse { code?: number; msg?: string; data?: T; meta?: any; constructor( options: { code?: number; msg?: string; data?: T; meta?: any; } = {} ) { this.code = options.code; this.msg = options.msg || ""; this.data = options.data; this.meta = options.meta; } static success(data?: any, msg = Code.SUCCESS.name) { return new RestfulResponse({ code: Code.SUCCESS.code, msg: msg, data: data }); } static failure(msg = Code.FAIL.name) { return new RestfulResponse({ code: Code.FAIL.code, msg: msg }); } }