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 () {
    var 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
 */
var LocalTimeConverter = /** @class */ (function () {
    function LocalTimeConverter() {
    }
    LocalTimeConverter.prototype.encode = function (model, stream) {
        if (stream === void 0) { stream = new TapStreamWriter(); }
        stream.writeLocalTime(model);
        return stream.toBytes;
    };
    LocalTimeConverter.prototype.decode = function (data) {
        var stream = data instanceof TapStreamReader ? data : TapStreamReader.create(data);
        return stream.readLocalTime();
    };
    return LocalTimeConverter;
}());

/**
 *   Generated file. Do not edit
 */
var localTime = new LocalTimeConverter();

var serviceConverters = /*#__PURE__*/Object.freeze({
    __proto__: null,
    localTime: localTime
});

/**
 *   Generated file. Do not edit
 */
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var allConverters = __assign(__assign({}, converters), serviceConverters);
var 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
    }
};

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign$1 = (this && this.__assign) || function () {
    __assign$1 = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign$1.apply(this, arguments);
};
var TimeService = /** @class */ (function (_super) {
    __extends(TimeService, _super);
    function TimeService() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.resources = SERVICE_CALLS;
        return _this;
    }
    /**
     * Get NTP server name
     *
     * LWM2M path: /1024//77
     *
     * @tapVersion(">=1.107")
     * @return
     */
    TimeService.prototype.getNtpServer = function () {
        return this.serviceCallRunner.execute(this.getNtpServerCall());
    };
    /**
     *
     *
     * LWM2M path: /1024//77
     *
     * @tapVersion(">=1.107")
     * @return call options
     */
    TimeService.prototype.getNtpServerCall = function () {
        var callOptions = __assign$1({}, this.resources.getNtpServer);
        return callOptions;
    };
    /**
     * Put NTP server name
     *
     * LWM2M path: /1024//77
     *
     * @tapVersion(">=1.107")
     * @param serverName input
     * @return
     */
    TimeService.prototype.putNtpServer = function (
    /*
     *
     */
    serverName) {
        return this.serviceCallRunner.execute(this.putNtpServerCall(serverName));
    };
    /**
     *
     *
     * LWM2M path: /1024//77
     *
     * @tapVersion(">=1.107")
     * @param serverName input
     * @return call options
     */
    TimeService.prototype.putNtpServerCall = function (
    /*
     *
     */
    serverName) {
        var callOptions = __assign$1({}, this.resources.putNtpServer);
        callOptions.body = serverName;
        return callOptions;
    };
    /**
     * Get Tap time zone
     *
     * LWM2M path: /1024//78
     *
     * @tapVersion(">=1.107")
     * @return
     */
    TimeService.prototype.getTimeZone = function () {
        return this.serviceCallRunner.execute(this.getTimeZoneCall());
    };
    /**
     *
     *
     * LWM2M path: /1024//78
     *
     * @tapVersion(">=1.107")
     * @return call options
     */
    TimeService.prototype.getTimeZoneCall = function () {
        var callOptions = __assign$1({}, this.resources.getTimeZone);
        return callOptions;
    };
    /**
     * Put Tap time zone
     *
     * LWM2M path: /1024//78
     *
     * @tapVersion(">=1.107")
     * @param serverName input
     * @return
     */
    TimeService.prototype.putTimeZone = function (
    /*
     *
     */
    serverName) {
        return this.serviceCallRunner.execute(this.putTimeZoneCall(serverName));
    };
    /**
     *
     *
     * LWM2M path: /1024//78
     *
     * @tapVersion(">=1.107")
     * @param serverName input
     * @return call options
     */
    TimeService.prototype.putTimeZoneCall = function (
    /*
     *
     */
    serverName) {
        var callOptions = __assign$1({}, this.resources.putTimeZone);
        callOptions.body = serverName;
        return callOptions;
    };
    /**
     * Get Tap local time
     *
     * LWM2M path: /1024//79
     *
     * @tapVersion(">=1.107")
     * @return
     */
    TimeService.prototype.getLocalTime = function () {
        return this.serviceCallRunner.execute(this.getLocalTimeCall());
    };
    /**
     *
     *
     * LWM2M path: /1024//79
     *
     * @tapVersion(">=1.107")
     * @return call options
     */
    TimeService.prototype.getLocalTimeCall = function () {
        var callOptions = __assign$1({}, this.resources.getLocalTime);
        return callOptions;
    };
    return TimeService;
}(AbstractService));

var _TAP_SERVICE_EXTENSION_TIME_ = extendServiceContainer("time", TimeService);

/**
 * Generated bundle index. Do not edit.
 */

export { LocalTimeConverter, SERVICE_CALLS as TIME_SERVICE_CALLS, TimeService, _TAP_SERVICE_EXTENSION_TIME_, serviceConverters as timeConverters };
//# sourceMappingURL=iotize-tap-service-impl-time.js.map
