@iotize/tap
Version:
IoTize Device client for Javascript
277 lines (266 loc) • 7.1 kB
JavaScript
import { AbstractService, extendServiceContainer } from '@iotize/tap';
import { TapRequestFrame } from '@iotize/tap/client/api';
import { TapStreamReader, TapStreamWriter } from '@iotize/tap/client/impl';
import { converters } from '@iotize/tap/service/core';
/**
* Generated file. Do not edit
*/
TapStreamReader.prototype.readLocalTime = function () {
const model = {};
model.seconds = this.readUnsigned(4);
model.minutes = this.readUnsigned(4);
model.hours = this.readUnsigned(4);
model.dayOfMonth = this.readUnsigned(4);
model.month = this.readUnsigned(4);
model.year = this.readUnsigned(4);
model.dayOfWeek = this.readUnsigned(4);
model.dayOfYear = this.readUnsigned(4);
model.isdst = this.readUnsigned(4);
return model;
};
// TapStreamWriter.prototype.write(model: LocalTime) : TapStreamWriter{
// return this.writeLocalTime(model)
// }
TapStreamWriter.prototype.writeLocalTime = function (model) {
this.writeUnsigned(model.seconds, 4);
this.writeUnsigned(model.minutes, 4);
this.writeUnsigned(model.hours, 4);
this.writeUnsigned(model.dayOfMonth, 4);
this.writeUnsigned(model.month, 4);
this.writeUnsigned(model.year, 4);
this.writeUnsigned(model.dayOfWeek, 4);
this.writeUnsigned(model.dayOfYear, 4);
this.writeUnsigned(model.isdst, 4);
return this;
};
/**
* Generated file. Do not edit
*/
class LocalTimeConverter {
encode(model, stream = new TapStreamWriter()) {
stream.writeLocalTime(model);
return stream.toBytes;
}
decode(data) {
const stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
return stream.readLocalTime();
}
}
/**
* Generated file. Do not edit
*/
const localTime = new LocalTimeConverter();
var serviceConverters = /*#__PURE__*/Object.freeze({
__proto__: null,
localTime: localTime
});
/**
* Generated file. Do not edit
*/
const allConverters = Object.assign(Object.assign({}, converters), serviceConverters);
const SERVICE_CALLS = {
getNtpServer: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/time/ntp-server',
path: '/1024//77',
responseBodyDecoder: allConverters.ascii,
},
putNtpServer: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/time/ntp-server',
path: '/1024//77',
bodyEncoder: allConverters.ascii,
},
getTimeZone: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/time/time-zone',
path: '/1024//78',
responseBodyDecoder: allConverters.ascii,
},
putTimeZone: {
method: TapRequestFrame.MethodType.PUT,
pathAlias: '/time/time-zone',
path: '/1024//78',
bodyEncoder: allConverters.ascii,
},
getLocalTime: {
method: TapRequestFrame.MethodType.GET,
pathAlias: '/time/local-time',
path: '/1024//79',
responseBodyDecoder: allConverters.localTime,
},
};
class TimeService extends AbstractService {
constructor() {
super(...arguments);
this.resources = SERVICE_CALLS;
}
/**
* Get NTP server name
*
* LWM2M path: /1024//77
*
* @tapVersion(">=1.107")
* @return
*/
getNtpServer() {
return this.serviceCallRunner.execute(this.getNtpServerCall());
}
/**
*
*
* LWM2M path: /1024//77
*
* @tapVersion(">=1.107")
* @return call options
*/
getNtpServerCall() {
const callOptions = Object.assign({}, this.resources.getNtpServer);
return callOptions;
}
/**
* Put NTP server name
*
* LWM2M path: /1024//77
*
* @tapVersion(">=1.107")
* @param serverName input
* @return
*/
putNtpServer(
/*
*
*/
serverName) {
return this.serviceCallRunner.execute(this.putNtpServerCall(serverName));
}
/**
*
*
* LWM2M path: /1024//77
*
* @tapVersion(">=1.107")
* @param serverName input
* @return call options
*/
putNtpServerCall(
/*
*
*/
serverName) {
const callOptions = Object.assign({}, this.resources.putNtpServer);
callOptions.body = serverName;
return callOptions;
}
/**
* Get Tap time zone
*
* LWM2M path: /1024//78
*
* @tapVersion(">=1.107")
* @return
*/
getTimeZone() {
return this.serviceCallRunner.execute(this.getTimeZoneCall());
}
/**
*
*
* LWM2M path: /1024//78
*
* @tapVersion(">=1.107")
* @return call options
*/
getTimeZoneCall() {
const callOptions = Object.assign({}, this.resources.getTimeZone);
return callOptions;
}
/**
* Put Tap time zone
*
* LWM2M path: /1024//78
*
* @tapVersion(">=1.107")
* @param serverName input
* @return
*/
putTimeZone(
/*
*
*/
serverName) {
return this.serviceCallRunner.execute(this.putTimeZoneCall(serverName));
}
/**
*
*
* LWM2M path: /1024//78
*
* @tapVersion(">=1.107")
* @param serverName input
* @return call options
*/
putTimeZoneCall(
/*
*
*/
serverName) {
const callOptions = Object.assign({}, this.resources.putTimeZone);
callOptions.body = serverName;
return callOptions;
}
/**
* Get Tap local time
*
* LWM2M path: /1024//79
*
* @tapVersion(">=1.107")
* @return
*/
getLocalTime() {
return this.serviceCallRunner.execute(this.getLocalTimeCall());
}
/**
*
*
* LWM2M path: /1024//79
*
* @tapVersion(">=1.107")
* @return call options
*/
getLocalTimeCall() {
const callOptions = Object.assign({}, this.resources.getLocalTime);
return callOptions;
}
}
const _TAP_SERVICE_EXTENSION_TIME_ = extendServiceContainer('time', TimeService);
/**
* Generated file. Do not edit
*/
const ResourceMetaData = {
'/time/ntp-server': {
put: {
minApiVersion: 1.107,
configModeRequired: false,
schema: {
type: 'string',
maxLength: 100,
},
},
},
'/time/time-zone': {
put: {
minApiVersion: 1.107,
configModeRequired: false,
schema: {
type: 'string',
maxLength: 64,
},
},
},
};
/**
* Generated bundle index. Do not edit.
*/
export { LocalTimeConverter, SERVICE_CALLS as TIME_SERVICE_CALLS, ResourceMetaData as TimeResourceMetaData, TimeService, _TAP_SERVICE_EXTENSION_TIME_, serviceConverters as timeConverters };
//# sourceMappingURL=iotize-tap-service-impl-time.js.map