@octopusx/ndk
Version:
octopus x sdk to connect to the octopusx grids and services
147 lines (146 loc) • 7.3 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const requests_1 = require("../utils/requests");
class Domain {
constructor(options) {
this.options = options;
this.options.url = process.env.OCX_DOMAIN_BASE_URL || process.env.VUE_APP_OCX_DOMAIN_BASE_URL;
}
initData(payload) {
return {
"OCX Schema": this.options.version,
"OCXType": "Request",
"OCXComponent": "OCXDomain",
"OCXPayload": payload
};
}
setupDomain() {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `api/v1/setup`;
return requests_1.default(`POST`, url, requestOptions);
});
}
createDomainNode(data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domainnode/invites/initiate`;
return requests_1.default(`POST`, url, requestOptions);
});
}
acceptDomainNode(nodeId, data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domainnode/invites/accept/${nodeId}`;
return requests_1.default(`PATCH`, url, requestOptions);
});
}
getDomainNodes() {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domainnode/view`;
return requests_1.default(`GET`, url, requestOptions);
});
}
getSingleDomainNode(domainNodeId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domainnode/view/${domainNodeId}`;
return requests_1.default(`GET`, url, requestOptions);
});
}
updateDomainNode(domainNodeId, data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domainnode/update/${domainNodeId}`;
return requests_1.default(`PATCH`, url, requestOptions);
});
}
deleteDomainNode(domainNodeId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domainnode/delete/${domainNodeId}`;
return requests_1.default(`DELETE`, url, requestOptions);
});
}
createDomainInvite(data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domaininvite/register/invitee`;
return requests_1.default(`POST`, url, requestOptions);
});
}
getDomainInvitation() {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaininvite/view`;
return requests_1.default(`GET`, url, requestOptions);
});
}
getSingleDomainInvite(domainInviteId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaininvite/view/${domainInviteId}`;
return requests_1.default(`GET`, url, requestOptions);
});
}
updateDomainInviteNode(domainInviteId, data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domaininvite/invites/update/${domainInviteId}`;
return requests_1.default(`PATCH`, url, requestOptions);
});
}
deleteDomainInvite(domainInviteId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaininvite/invites/delete/${domainInviteId}`;
return requests_1.default(`DELETE`, url, requestOptions);
});
}
createDomainGroup(data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domaingroup/register`;
return requests_1.default(`POST`, url, requestOptions);
});
}
getDomainGroups() {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaingroup/view`;
return requests_1.default(`GET`, url, requestOptions);
});
}
getSingleDomainGroup(domainGroupId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaingroup/view/${domainGroupId}`;
return requests_1.default(`GET`, url, requestOptions);
});
}
updateDomainGroup(domainGroupId, data) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign(Object.assign({}, this.options), { data: this.initData(data) });
const url = `domain/${this.options.version}/domaingroup/update/${domainGroupId}`;
return requests_1.default(`PATCH`, url, requestOptions);
});
}
deleteDomainGroup(domainGroupId) {
return __awaiter(this, void 0, void 0, function* () {
const requestOptions = Object.assign({}, this.options);
const url = `domain/${this.options.version}/domaingroup/delete/${domainGroupId}`;
return requests_1.default(`DELETE`, url, requestOptions);
});
}
}
exports.default = Domain;