UNPKG

@iletimerkezi/iletimerkezi-node

Version:
35 lines 921 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseResponse = void 0; class BaseResponse { constructor(data, statusCode) { this.data = data?.response || {}; this.statusCode = statusCode; this.customizeData(); } customizeData() { // Override this method in child classes if needed } ok() { return this.statusCode === 200; } getMessage() { return this.data?.status?.message || ''; } getStatusCode() { return this.statusCode; } getErrorCode() { return this.data?.status?.code || ''; } toJSON() { return { success: this.ok(), statusCode: this.getStatusCode(), message: this.getMessage(), errorCode: this.getErrorCode() }; } } exports.BaseResponse = BaseResponse; //# sourceMappingURL=BaseResponse.js.map