UNPKG

coloquent-test2

Version:

Library for retrieving model objects from a JSON-API, with a fluent syntax inspired by Laravel Eloquent.

61 lines 2.1 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var RetrievalResponse_1 = require("./RetrievalResponse"); var SingularResponse = /** @class */ (function (_super) { __extends(SingularResponse, _super); function SingularResponse(httpClientResponse, modelType, responseBody) { return _super.call(this, httpClientResponse, modelType, responseBody) || this; } SingularResponse.prototype.getData = function () { return this.data; }; SingularResponse.prototype.makeModelIndex = function (data) { var doc = null; if (Array.isArray(data)) { doc = data[0]; } else { doc = data; } if (doc) { this.indexAsModel(doc, this.modelType); } }; SingularResponse.prototype.indexRequestedDocs = function (data) { var doc = null; if (Array.isArray(data)) { doc = data[0]; } else { doc = data; } if (doc) { this.indexDoc(doc); } }; SingularResponse.prototype.makeDataArray = function (data) { var doc = null; if (Array.isArray(data)) { doc = data[0]; } else { doc = data; } if (doc) { this.data = this.modelIndex.get(doc.type).get(doc.id); } }; return SingularResponse; }(RetrievalResponse_1.RetrievalResponse)); exports.SingularResponse = SingularResponse; //# sourceMappingURL=SingularResponse.js.map