UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

98 lines 5.01 kB
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { catchError, map } from "rxjs"; import { ApiResponseData } from "../../../models/api-response-data"; import { Endpoint } from "../../endpoint"; import { GroupResponse } from "../../../models/admin/group-response"; import { GroupsResponse } from "../../../models/admin/groups-response"; import { MembersResponse } from "../../../models/admin/members-response"; /** * An endpoint for working with Knora groups. * @deprecated Use open API docs instead * @category Endpoint Admin */ var GroupsEndpointAdmin = /** @class */ (function (_super) { __extends(GroupsEndpointAdmin, _super); function GroupsEndpointAdmin() { return _super !== null && _super.apply(this, arguments) || this; } /** * Returns a list of all groups. */ GroupsEndpointAdmin.prototype.getGroups = function () { var _this = this; return this.httpGet("").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a group. * * @param group The group to be created. */ GroupsEndpointAdmin.prototype.createGroup = function (group) { var _this = this; return this.httpPost("", this.jsonConvert.serializeObject(group)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a group by IRI. * * @param iri The IRI of the group. */ GroupsEndpointAdmin.prototype.getGroupByIri = function (iri) { var _this = this; return this.httpGet("/" + encodeURIComponent(iri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a group. * * @param iri The IRI of the group to be updated. * @param groupInfo The group information to be updated. */ GroupsEndpointAdmin.prototype.updateGroup = function (iri, groupInfo) { var _this = this; return this.httpPut("/" + encodeURIComponent(iri), this.jsonConvert.serializeObject(groupInfo)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates the status of a group. * * @param iri The IRI of the group to be updated. * @param status The new status of the group. */ GroupsEndpointAdmin.prototype.updateGroupStatus = function (iri, status) { var _this = this; return this.httpPut("/" + encodeURIComponent(iri) + "/status", { status: status }).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a group. This method does not actually delete a group, but sets the status to false. * * @param iri The IRI of the group. */ GroupsEndpointAdmin.prototype.deleteGroup = function (iri) { var _this = this; return this.httpDelete("/" + encodeURIComponent(iri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets the members of a group. * * @param iri The IRI of the group. */ GroupsEndpointAdmin.prototype.getGroupMembers = function (iri) { var _this = this; return this.httpGet("/" + encodeURIComponent(iri) + "/members").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, MembersResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; return GroupsEndpointAdmin; }(Endpoint)); export { GroupsEndpointAdmin }; //# sourceMappingURL=groups-endpoint-admin.js.map