(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@iotize/tap'), require('@iotize/tap/client/api'), require('@iotize/tap/service/core'), require('@iotize/tap/client/impl')) :
    typeof define === 'function' && define.amd ? define('@iotize/tap/service/impl/firmware', ['exports', '@iotize/tap', '@iotize/tap/client/api', '@iotize/tap/service/core', '@iotize/tap/client/impl'], factory) :
    (global = global || self, factory((global.iotize = global.iotize || {}, global.iotize.tap = global.iotize.tap || {}, global.iotize.tap.service = global.iotize.tap.service || {}, global.iotize.tap.service.impl = global.iotize.tap.service.impl || {}, global.iotize.tap.service.impl.firmware = {}), global.iotize.tap, global.iotize.tap.client.api, global.iotize.tap.service.core, global.iotize.tap.client.impl));
}(this, (function (exports, tap, api, core, impl) { 'use strict';

    /* tslint:disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */

    (function (FirmwareState) {
        FirmwareState[FirmwareState["NORMAL"] = 1] = "NORMAL";
        FirmwareState[FirmwareState["UPDATING"] = 2] = "UPDATING";
        FirmwareState[FirmwareState["UPDATED"] = 4] = "UPDATED";
    })(exports.FirmwareState || (exports.FirmwareState = {}));

    /**
     *   Generated file. Do not edit
     */
    impl.TapStreamReader.prototype.readCrcCheckBody = function () {
        var model = {};
        model.address = this.readUnsigned(4);
        model.size = this.readUnsigned(4);
        model.crc = this.readUnsigned(4);
        return model;
    };
    // TapStreamWriter.prototype.write(model: CrcCheckBody) : TapStreamWriter{
    //     return this.writeCrcCheckBody(model)
    // }
    impl.TapStreamWriter.prototype.writeCrcCheckBody = function (model) {
        this.writeUnsigned(model.address, 4);
        this.writeUnsigned(model.size, 4);
        this.writeUnsigned(model.crc, 4);
        return this;
    };

    /**
     *   Generated file. Do not edit
     */
    var CrcCheckBodyConverter = /** @class */ (function () {
        function CrcCheckBodyConverter() {
        }
        CrcCheckBodyConverter.prototype.encode = function (model, stream) {
            if (stream === void 0) { stream = new impl.TapStreamWriter(); }
            stream.writeCrcCheckBody(model);
            return stream.toBytes;
        };
        CrcCheckBodyConverter.prototype.decode = function (data) {
            var stream = data instanceof impl.TapStreamReader ? data : impl.TapStreamReader.create(data);
            return stream.readCrcCheckBody();
        };
        return CrcCheckBodyConverter;
    }());

    /**
     *   Generated file. Do not edit
     */
    var firmwareState = core.createEnumConverter(exports.FirmwareState, 1);
    var firmwareStateArray = core.createEnumArrayConverter(exports.FirmwareState, 1);
    var crcCheckBody = new CrcCheckBodyConverter();

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

    /**
     *   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({}, core.converters), serviceConverters);
    var SERVICE_CALLS = {
        postPackage: {
            method: api.TapRequestFrame.MethodType.POST,
            pathAlias: "/firmware/package",
            path: "/5//0"
        },
        postUpdate: {
            method: api.TapRequestFrame.MethodType.POST,
            pathAlias: "/firmware/update",
            path: "/5//2"
        },
        getState: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/firmware/state",
            path: "/5//3",
            responseBodyDecoder: allConverters.firmwareState
        },
        postCrcCheck: {
            method: api.TapRequestFrame.MethodType.POST,
            pathAlias: "/firmware/crc-check",
            path: "/5//6",
            bodyEncoder: allConverters.crcCheckBody
        }
    };

    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 FirmwareService = /** @class */ (function (_super) {
        __extends(FirmwareService, _super);
        function FirmwareService() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.resources = SERVICE_CALLS;
            return _this;
        }
        /**
         * Firmware package
         *
         * LWM2M path: /5//0
         *
         * @deprecated
         * @tapVersion(">=")
         * @return
         */
        FirmwareService.prototype.postPackage = function () {
            return this.serviceCallRunner.execute(this.postPackageCall());
        };
        /**
         *
         *
         * LWM2M path: /5//0
         *
         * @deprecated
         * @tapVersion(">=")
         * @return call options
         */
        FirmwareService.prototype.postPackageCall = function () {
            var callOptions = __assign$1({}, this.resources.postPackage);
            return callOptions;
        };
        /**
         * Update
         *
         * LWM2M path: /5//2
         *
         * @deprecated
         * @tapVersion(">=")
         * @return
         */
        FirmwareService.prototype.postUpdate = function () {
            return this.serviceCallRunner.execute(this.postUpdateCall());
        };
        /**
         *
         *
         * LWM2M path: /5//2
         *
         * @deprecated
         * @tapVersion(">=")
         * @return call options
         */
        FirmwareService.prototype.postUpdateCall = function () {
            var callOptions = __assign$1({}, this.resources.postUpdate);
            return callOptions;
        };
        /**
         * Get state
         *
         * LWM2M path: /5//3
         *
         * @deprecated
         * @tapVersion(">=")
         * @return
         */
        FirmwareService.prototype.getState = function () {
            return this.serviceCallRunner.execute(this.getStateCall());
        };
        /**
         *
         *
         * LWM2M path: /5//3
         *
         * @deprecated
         * @tapVersion(">=")
         * @return call options
         */
        FirmwareService.prototype.getStateCall = function () {
            var callOptions = __assign$1({}, this.resources.getState);
            return callOptions;
        };
        /**
         * Check CRC
         *
         * LWM2M path: /5//6
         *
         * @deprecated
         * @tapVersion(">=")
         * @param data input
         * @return
         */
        FirmwareService.prototype.postCrcCheck = function (
        /*
         *
         */
        data) {
            return this.serviceCallRunner.execute(this.postCrcCheckCall(data));
        };
        /**
         *
         *
         * LWM2M path: /5//6
         *
         * @deprecated
         * @tapVersion(">=")
         * @param data input
         * @return call options
         */
        FirmwareService.prototype.postCrcCheckCall = function (
        /*
         *
         */
        data) {
            var callOptions = __assign$1({}, this.resources.postCrcCheck);
            callOptions.body = data;
            return callOptions;
        };
        return FirmwareService;
    }(tap.AbstractService));

    var _TAP_SERVICE_EXTENSION_FIRMWARE_ = tap.extendServiceContainer("firmware", FirmwareService);

    exports.CrcCheckBodyConverter = CrcCheckBodyConverter;
    exports.FIRMWARE_SERVICE_CALLS = SERVICE_CALLS;
    exports.FirmwareService = FirmwareService;
    exports._TAP_SERVICE_EXTENSION_FIRMWARE_ = _TAP_SERVICE_EXTENSION_FIRMWARE_;
    exports.firmwareConverters = serviceConverters;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=iotize-tap-service-impl-firmware.umd.js.map
