@eclipse-ditto/ditto-javascript-client-dom
Version:
DOM implementation of Eclipse Ditto JavaScript API to be used in browsers.
59 lines • 2.45 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 { DefaultHttpMessagesHandle } from './handles/messages-http';
import { DefaultSearchHandle } from './handles/search';
import { DefaultPoliciesHandle } from './handles/policies';
import { AbstractDittoClient } from './ditto-client';
import { DefaultThingsHandle } from './handles/things';
import { DefaultFeaturesHandle } from './handles/features';
class DefaultHandles {
constructor() {
this.thingsHandle = DefaultThingsHandle.getInstance;
this.featuresHandle = DefaultFeaturesHandle.getInstance;
this.messagesHandle = DefaultHttpMessagesHandle.getInstance;
this.policiesHandle = DefaultPoliciesHandle.getInstance;
this.searchHandle = DefaultSearchHandle.getInstance;
}
}
export class DefaultDittoHttpClient extends 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);
}
}
//# sourceMappingURL=ditto-client-http.js.map