1 | /*! firebase-admin v12.0.0 */
|
2 | /*!
|
3 | * Copyright 2019 Google Inc.
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | import { HttpClient, HttpResponse } from '../utils/api-request';
|
18 | /**
|
19 | * Represents a request that can be sent as part of an HTTP batch request.
|
20 | */
|
21 | export interface SubRequest {
|
22 | url: string;
|
23 | body: object;
|
24 | headers?: {
|
25 | [key: string]: any;
|
26 | };
|
27 | }
|
28 | /**
|
29 | * An HTTP client that can be used to make batch requests. This client is not tied to any service
|
30 | * (FCM or otherwise). Therefore it can be used to make batch requests to any service that allows
|
31 | * it. If this requirement ever arises we can move this implementation to the utils module
|
32 | * where it can be easily shared among other modules.
|
33 | */
|
34 | export declare class BatchRequestClient {
|
35 | private readonly httpClient;
|
36 | private readonly batchUrl;
|
37 | private readonly commonHeaders?;
|
38 | /**
|
39 | * @param {HttpClient} httpClient The client that will be used to make HTTP calls.
|
40 | * @param {string} batchUrl The URL that accepts batch requests.
|
41 | * @param {object=} commonHeaders Optional headers that will be included in all requests.
|
42 | *
|
43 | * @constructor
|
44 | */
|
45 | constructor(httpClient: HttpClient, batchUrl: string, commonHeaders?: object | undefined);
|
46 | /**
|
47 | * Sends the given array of sub requests as a single batch, and parses the results into an array
|
48 | * of HttpResponse objects.
|
49 | *
|
50 | * @param requests - An array of sub requests to send.
|
51 | * @returns A promise that resolves when the send operation is complete.
|
52 | */
|
53 | send(requests: SubRequest[]): Promise<HttpResponse[]>;
|
54 | private getMultipartPayload;
|
55 | }
|