recime-bot-runtime
Version:
This runtime is intended to run inside a micro-service container with platform specific integration and module interpreter.
54 lines (53 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var request = require("request");
var Vars = /** @class */ (function () {
function Vars(sender, values) {
this.sender = sender;
this.values = values;
}
Vars.prototype.get = function (key) {
return this.values[key];
};
Vars.prototype.set = function (key, value) {
if (key && value) {
this.values[key] = value;
;
}
};
Vars.prototype.post = function (key, value) {
var _this = this;
return new Promise(function (resolve) {
var body = {
query: "mutation Set($input: SetInput!) {set(input: $input)}",
variables: {
input: {
botId: process.env.UID,
key: key + "-" + _this.sender,
value: value
}
}
};
request({
url: 'https://key-value-api.recime.io/v1/graphql',
method: 'POST',
json: true,
headers: {
'authorization': "token " + process.env.SYSTEM_RECIME_API_KEY
},
body: body
}, function (err, response, body) {
if (err) {
console.log(err.message);
}
_this.values[key] = value;
return resolve();
});
});
};
Vars.prototype.unset = function (key) {
delete this.values[key];
};
return Vars;
}());
exports.Vars = Vars;