installations.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * Copyright 2021 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.Installations = void 0;
  20. const error_1 = require("../utils/error");
  21. const installations_request_handler_1 = require("./installations-request-handler");
  22. const validator = require("../utils/validator");
  23. /**
  24. * The `Installations` service for the current app.
  25. */
  26. class Installations {
  27. /**
  28. * @param app - The app for this Installations service.
  29. * @constructor
  30. * @internal
  31. */
  32. constructor(app) {
  33. if (!validator.isNonNullObject(app) || !('options' in app)) {
  34. throw new error_1.FirebaseInstallationsError(error_1.InstallationsClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.installations() must be a valid Firebase app instance.');
  35. }
  36. this.app_ = app;
  37. this.requestHandler = new installations_request_handler_1.FirebaseInstallationsRequestHandler(app);
  38. }
  39. /**
  40. * Deletes the specified installation ID and the associated data from Firebase.
  41. *
  42. * @param fid - The Firebase installation ID to be deleted.
  43. *
  44. * @returns A promise fulfilled when the installation ID is deleted.
  45. */
  46. deleteInstallation(fid) {
  47. return this.requestHandler.deleteInstallation(fid);
  48. }
  49. /**
  50. * Returns the app associated with this Installations instance.
  51. *
  52. * @returns The app associated with this Installations instance.
  53. */
  54. get app() {
  55. return this.app_;
  56. }
  57. }
  58. exports.Installations = Installations;