@iletimerkezi/iletimerkezi-node
Version:
İleti Merkezi Node.js SDK
35 lines • 921 B
JavaScript
;
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