@eclipse-ditto/ditto-javascript-client-dom
Version:
DOM implementation of Eclipse Ditto JavaScript API to be used in browsers.
93 lines • 2.52 kB
JavaScript
/*!
* 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
*/
import { EntityModel } from './model';
import { Thing } from './things.model';
export 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;
}
}
export 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;
}
}
/**
* Representation of a response ot a search request
*/
export class SearchThingsResponse extends 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) => Thing.fromObject(t)), o['nextPageOffset'], o['cursor']);
}
toObject() {
return 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 : '';
}
}
//# sourceMappingURL=response.js.map