GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.deleteChannel = exports.updateChannel = exports.createChannel = exports.getChannel = exports.API_VERSION = void 0;
  4. const apiv2_1 = require("../apiv2");
  5. const api_1 = require("../api");
  6. const lodash_1 = require("lodash");
  7. const proto_1 = require("./proto");
  8. exports.API_VERSION = "v1";
  9. const client = new apiv2_1.Client({
  10. urlPrefix: api_1.eventarcOrigin,
  11. auth: true,
  12. apiVersion: exports.API_VERSION,
  13. });
  14. async function getChannel(name) {
  15. const res = await client.get(name);
  16. if (res.status === 404) {
  17. return undefined;
  18. }
  19. return res.body;
  20. }
  21. exports.getChannel = getChannel;
  22. async function createChannel(channel) {
  23. const pathParts = channel.name.split("/");
  24. const res = await client.post(pathParts.slice(0, -1).join("/"), channel, {
  25. queryParams: { channelId: (0, lodash_1.last)(pathParts) },
  26. });
  27. return res.body;
  28. }
  29. exports.createChannel = createChannel;
  30. async function updateChannel(channel) {
  31. const res = await client.put(channel.name, channel, {
  32. queryParams: {
  33. updateMask: (0, proto_1.fieldMasks)(channel).join(","),
  34. },
  35. });
  36. return res.body;
  37. }
  38. exports.updateChannel = updateChannel;
  39. async function deleteChannel(name) {
  40. await client.delete(name);
  41. }
  42. exports.deleteChannel = deleteChannel;