UNPKG

@eclipse-ditto/ditto-javascript-client-node

Version:

Node.js(r) implementation of Eclipse Ditto JavaScript API.

99 lines 2.84 kB
"use strict"; /*! * Copyright (c) 2019 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchThingsResponse = exports.BasicErrorResponse = exports.PutResponse = void 0; const model_1 = require("./model"); const things_model_1 = require("./things.model"); class PutResponse { constructor(_value, _status, _headers) { this._value = _value; this._status = _status; this._headers = _headers; } wasCreated() { return this.body !== undefined && this.body !== null; } wasUpdated() { return !this.wasCreated(); } get body() { return this._value; } get status() { return this._status; } get headers() { return this._headers; } } exports.PutResponse = PutResponse; class BasicErrorResponse { constructor(_value, _status, _headers) { this._value = _value; this._status = _status; this._headers = _headers; } get body() { return this._value; } get status() { return this._status; } get headers() { return this._headers; } } exports.BasicErrorResponse = BasicErrorResponse; /** * Representation of a response ot a search request */ class SearchThingsResponse extends model_1.EntityModel { constructor(_items, _nextPageOffset, _cursor) { super(); this._items = _items; this._nextPageOffset = _nextPageOffset; this._cursor = _cursor; } /** * Parses a SearchThingsResponse. * * @param o - The object to parse. * @returns The SearchThingsResponse */ static fromObject(o) { if (o === undefined) { return o; } // @ts-ignore return new SearchThingsResponse(o['items'].map((t) => things_model_1.Thing.fromObject(t)), o['nextPageOffset'], o['cursor']); } toObject() { return model_1.EntityModel.buildObject(new Map([ ['items', this._items.map((t) => t.toObject())], ['nextPageOffset', this.nextPageOffset], ['cursor', this.cursor] ])); } get items() { return this._items; } get nextPageOffset() { return this._nextPageOffset !== undefined ? this._nextPageOffset : 0; } get cursor() { return this._cursor !== undefined ? this._cursor : ''; } } exports.SearchThingsResponse = SearchThingsResponse; //# sourceMappingURL=response.js.map