messaging-api-request-internal.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2017 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. import { App } from '../app';
  19. import { SubRequest } from './batch-request-internal';
  20. import { SendResponse, BatchResponse } from './messaging-api';
  21. /**
  22. * Class that provides a mechanism to send requests to the Firebase Cloud Messaging backend.
  23. */
  24. export declare class FirebaseMessagingRequestHandler {
  25. private readonly httpClient;
  26. private readonly batchClient;
  27. /**
  28. * @param app - The app used to fetch access tokens to sign API requests.
  29. * @constructor
  30. */
  31. constructor(app: App);
  32. /**
  33. * Invokes the request handler with the provided request data.
  34. *
  35. * @param host - The host to which to send the request.
  36. * @param path - The path to which to send the request.
  37. * @param requestData - The request data.
  38. * @returns A promise that resolves with the response.
  39. */
  40. invokeRequestHandler(host: string, path: string, requestData: object): Promise<object>;
  41. /**
  42. * Invokes the request handler with the provided request data.
  43. *
  44. * @param host - The host to which to send the request.
  45. * @param path - The path to which to send the request.
  46. * @param requestData - The request data.
  47. * @returns A promise that resolves with the {@link SendResponse}.
  48. */
  49. invokeRequestHandlerForSendResponse(host: string, path: string, requestData: object): Promise<SendResponse>;
  50. /**
  51. * Sends the given array of sub requests as a single batch to FCM, and parses the result into
  52. * a BatchResponse object.
  53. *
  54. * @param requests - An array of sub requests to send.
  55. * @returns A promise that resolves when the send operation is complete.
  56. */
  57. sendBatchRequest(requests: SubRequest[]): Promise<BatchResponse>;
  58. private buildSendResponse;
  59. private buildSendResponseFromError;
  60. }