UNPKG

2.43 kBTypeScriptView Raw
1/*! firebase-admin v12.0.0 */
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 */
18import { App } from '../app';
19import { SubRequest } from './batch-request-internal';
20import { SendResponse, BatchResponse } from './messaging-api';
21/**
22 * Class that provides a mechanism to send requests to the Firebase Cloud Messaging backend.
23 */
24export 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}