@eclipse-ditto/ditto-javascript-client-node
Version:
Node.js(r) implementation of Eclipse Ditto JavaScript API.
63 lines • 2.63 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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultDittoHttpClient = void 0;
const messages_http_1 = require("./handles/messages-http");
const search_1 = require("./handles/search");
const policies_1 = require("./handles/policies");
const ditto_client_1 = require("./ditto-client");
const things_1 = require("./handles/things");
const features_1 = require("./handles/features");
class DefaultHandles {
constructor() {
this.thingsHandle = things_1.DefaultThingsHandle.getInstance;
this.featuresHandle = features_1.DefaultFeaturesHandle.getInstance;
this.messagesHandle = messages_http_1.DefaultHttpMessagesHandle.getInstance;
this.policiesHandle = policies_1.DefaultPoliciesHandle.getInstance;
this.searchHandle = search_1.DefaultSearchHandle.getInstance;
}
}
class DefaultDittoHttpClient extends ditto_client_1.AbstractDittoClient {
constructor(builder, handles) {
super(builder, handles);
}
/**
* Returns an instance of DittoClient based on the context provided.
*
* @param builder - The request sender builder to build on.
* @param customHandles - Custom handles to use instead of the default ones.
* @return the DittoClient instance.
*/
static getInstance(builder, customHandles) {
const handles = Object.assign(new DefaultHandles(), customHandles);
return new DefaultDittoHttpClient(builder, handles);
}
getFeaturesHandle(thingId, customBuildContext) {
return this.handles.featuresHandle(this.builder, thingId, customBuildContext);
}
getThingsHandle(customBuildContext) {
return this.handles.thingsHandle(this.builder, customBuildContext);
}
getMessagesHandle(customBuildContext) {
return this.handles.messagesHandle(this.builder, customBuildContext);
}
getPoliciesHandle(customBuildContext) {
return this.handles.policiesHandle(this.builder, customBuildContext);
}
getSearchHandle(customBuildContext) {
return this.handles.searchHandle(this.builder, customBuildContext);
}
}
exports.DefaultDittoHttpClient = DefaultDittoHttpClient;
//# sourceMappingURL=ditto-client-http.js.map