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.readReadWriteRights = function () {
    var model = {};
    model.header = this.readUnsigned(1);
    model.groupId = this.readUnsigned((model.header === undefined ? 0 : model.header) == 0x61 ? 2 : 1);
    this.forwardBits(6);
    model.write = this.readBoolean(1);
    model.read = this.readBoolean(1);
    return model;
};
// TapStreamWriter.prototype.write(model: ReadWriteRights) : TapStreamWriter{
//     return this.writeReadWriteRights(model)
// }
TapStreamWriter.prototype.writeReadWriteRights = function (model) {
    this.writeUnsigned(model.header !== undefined
        ? model.header
        : model.groupId > 255
            ? 0x61
            : 0x41, 1);
    this.writeUnsigned(model.groupId, (model.header === undefined ? 0 : model.header) == 0x61 ? 2 : 1);
    this.forwardBits(6);
    this.writeBoolean(model.write, 1);
    this.writeBoolean(model.read, 1);
    return this;
};

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

/**
 *   Generated file. Do not edit
 */
var readWriteRights = new ReadWriteRightsConverter();

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

/**
 *   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 = {
    putAcl: {
        method: TapRequestFrame.MethodType.PUT,
        pathAlias: "/bundle/{bundleId}/acl",
        path: "/1028/{bundleId}/0",
        bodyEncoder: allConverters.readWriteRights
    },
    getValues: {
        method: TapRequestFrame.MethodType.GET,
        pathAlias: "/bundle/{bundleId}/values",
        path: "/1028/{bundleId}/1"
    },
    getDataLogPeriod: {
        method: TapRequestFrame.MethodType.GET,
        pathAlias: "/bundle/{bundleId}/data-log-period",
        path: "/1028/{bundleId}/2",
        responseBodyDecoder: allConverters.uint32
    },
    putDataLogPeriod: {
        method: TapRequestFrame.MethodType.PUT,
        pathAlias: "/bundle/{bundleId}/data-log-period",
        path: "/1028/{bundleId}/2",
        bodyEncoder: allConverters.uint32
    },
    create: {
        method: TapRequestFrame.MethodType.POST,
        pathAlias: "/bundle/{bundleId}/create",
        path: "/1028/{bundleId}/65535"
    },
    getName: {
        method: TapRequestFrame.MethodType.GET,
        pathAlias: "/bundle/{bundleId}/name",
        path: "/1028/{bundleId}/4",
        responseBodyDecoder: allConverters.ascii
    },
    putName: {
        method: TapRequestFrame.MethodType.PUT,
        pathAlias: "/bundle/{bundleId}/name",
        path: "/1028/{bundleId}/4",
        bodyEncoder: allConverters.ascii
    }
};

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 BundleService = /** @class */ (function (_super) {
    __extends(BundleService, _super);
    function BundleService() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.resources = SERVICE_CALLS;
        return _this;
    }
    /**
     * Write acls
     *
     * LWM2M path: /1028/{bundleId}/0
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param rights input
     * @return
     */
    BundleService.prototype.putAcl = function (
    /*
     * Group id
     */
    bundleId, 
    /*
     * Rights
     */
    rights) {
        return this.serviceCallRunner.execute(this.putAclCall(bundleId, rights));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/0
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param rights input
     * @return call options
     */
    BundleService.prototype.putAclCall = function (
    /*
     * Group id
     */
    bundleId, 
    /*
     * Rights
     */
    rights) {
        var callOptions = __assign$1({}, this.resources.putAcl);
        callOptions.body = rights;
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Get bundle values
     *
     * LWM2M path: /1028/{bundleId}/1
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return
     */
    BundleService.prototype.getValues = function (
    /*
     * Bundle id
     */
    bundleId) {
        return this.serviceCallRunner.execute(this.getValuesCall(bundleId));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/1
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return call options
     */
    BundleService.prototype.getValuesCall = function (
    /*
     * Bundle id
     */
    bundleId) {
        var callOptions = __assign$1({}, this.resources.getValues);
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Get data log acquisition period
     *
     * LWM2M path: /1028/{bundleId}/2
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return
     */
    BundleService.prototype.getDataLogPeriod = function (
    /*
     * 0 : no Data log for this bundle (-1) : Log this bundle whenever one of its variables changesOther values : number of minutes between each log (… if there is a change in value?)
     */
    bundleId) {
        return this.serviceCallRunner.execute(this.getDataLogPeriodCall(bundleId));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/2
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return call options
     */
    BundleService.prototype.getDataLogPeriodCall = function (
    /*
     * 0 : no Data log for this bundle (-1) : Log this bundle whenever one of its variables changesOther values : number of minutes between each log (… if there is a change in value?)
     */
    bundleId) {
        var callOptions = __assign$1({}, this.resources.getDataLogPeriod);
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Write data-log acquisition period
     *
     * LWM2M path: /1028/{bundleId}/2
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param value input
     * @return
     */
    BundleService.prototype.putDataLogPeriod = function (
    /*
     * Bundle id
     */
    bundleId, 
    /*
     *
     */
    value) {
        return this.serviceCallRunner.execute(this.putDataLogPeriodCall(bundleId, value));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/2
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param value input
     * @return call options
     */
    BundleService.prototype.putDataLogPeriodCall = function (
    /*
     * Bundle id
     */
    bundleId, 
    /*
     *
     */
    value) {
        var callOptions = __assign$1({}, this.resources.putDataLogPeriod);
        callOptions.body = value;
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Create a new bundle
     *
     * LWM2M path: /1028/{bundleId}/65535
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return
     */
    BundleService.prototype.create = function (
    /*
     * Bundle id
     */
    bundleId) {
        return this.serviceCallRunner.execute(this.createCall(bundleId));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/65535
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return call options
     */
    BundleService.prototype.createCall = function (
    /*
     * Bundle id
     */
    bundleId) {
        var callOptions = __assign$1({}, this.resources.create);
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Read bundle name
     *
     * LWM2M path: /1028/{bundleId}/4
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return
     */
    BundleService.prototype.getName = function (
    /*
     * Bundle id
     */
    bundleId) {
        return this.serviceCallRunner.execute(this.getNameCall(bundleId));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/4
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @return call options
     */
    BundleService.prototype.getNameCall = function (
    /*
     * Bundle id
     */
    bundleId) {
        var callOptions = __assign$1({}, this.resources.getName);
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    /**
     * Write bundle name
     *
     * LWM2M path: /1028/{bundleId}/4
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param name input
     * @return
     */
    BundleService.prototype.putName = function (
    /*
     * Bundle id
     */
    bundleId, 
    /*
     * Name
     */
    name) {
        return this.serviceCallRunner.execute(this.putNameCall(bundleId, name));
    };
    /**
     *
     *
     * LWM2M path: /1028/{bundleId}/4
     *
     * @tapVersion(">=")
     * @param bundleId input
     * @param name input
     * @return call options
     */
    BundleService.prototype.putNameCall = function (
    /*
     * Bundle id
     */
    bundleId, 
    /*
     * Name
     */
    name) {
        var callOptions = __assign$1({}, this.resources.putName);
        callOptions.body = name;
        callOptions.pathParameters = {
            bundleId: bundleId
        };
        return callOptions;
    };
    return BundleService;
}(AbstractService));

var _TAP_SERVICE_EXTENSION_BUNDLE_ = extendServiceContainer("bundle", BundleService);

// import './lib/custom/extension';

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

export { SERVICE_CALLS as BUNDLE_SERVICE_CALLS, BundleService, ReadWriteRightsConverter, _TAP_SERVICE_EXTENSION_BUNDLE_, serviceConverters as bundleConverters };
//# sourceMappingURL=iotize-tap-service-impl-bundle.js.map
