UNPKG

3.4 kBTypeScriptView Raw
1/**
2 * Cloud functions to handle billing events from Firebase Alerts.
3 * @packageDocumentation
4 */
5import { CloudEvent, CloudFunction } from "../../core";
6import { FirebaseAlertData } from "./alerts";
7import * as options from "../../options";
8/**
9 * The internal payload object for billing plan updates.
10 * Payload is wrapped inside a `FirebaseAlertData` object.
11 */
12export interface PlanUpdatePayload {
13 ["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanUpdatePayload";
14 /** A Firebase billing plan. */
15 billingPlan: string;
16 /** The email address of the person that triggered billing plan change */
17 principalEmail: string;
18 /** The type of the notification, e.g. upgrade, downgrade */
19 notificationType: string;
20}
21/**
22 * The internal payload object for billing plan automated updates.
23 * Payload is wrapped inside a `FirebaseAlertData` object.
24 */
25export interface PlanAutomatedUpdatePayload {
26 ["@type"]: "type.googleapis.com/google.events.firebase.firebasealerts.v1.BillingPlanAutomatedUpdatePayload";
27 /** A Firebase billing plan. */
28 billingPlan: string;
29 /** The type of the notification, e.g. upgrade, downgrade */
30 notificationType: string;
31}
32/**
33 * A custom CloudEvent for billing Firebase Alerts (with custom extension attributes).
34 * @typeParam T - the data type for billing alerts that is wrapped in a `FirebaseAlertData` object.
35 */
36export interface BillingEvent<T> extends CloudEvent<FirebaseAlertData<T>> {
37 /** The type of the alerts that got triggered. */
38 alertType: string;
39}
40/**
41 * Declares a function that can handle a billing plan update event.
42 * @param handler - Event handler which is run every time a billing plan is updated.
43 * @returns A function that you can export and deploy.
44 */
45export declare function onPlanUpdatePublished(handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
46/**
47 * Declares a function that can handle a billing plan update event.
48 * @param opts - Options that can be set on the function.
49 * @param handler - Event handler which is run every time a billing plan is updated.
50 * @returns A function that you can export and deploy.
51 */
52export declare function onPlanUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanUpdatePayload>>;
53/**
54 * Declares a function that can handle an automated billing plan update event.
55 * @param handler - Event handler which is run every time an automated billing plan update occurs.
56 * @returns A function that you can export and deploy.
57 */
58export declare function onPlanAutomatedUpdatePublished(handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;
59/**
60 * Declares a function that can handle an automated billing plan update event.
61 * @param opts - Options that can be set on the function.
62 * @param handler - Event handler which is run every time an automated billing plan update occurs.
63 * @returns A function that you can export and deploy.
64 */
65export declare function onPlanAutomatedUpdatePublished(opts: options.EventHandlerOptions, handler: (event: BillingEvent<PlanAutomatedUpdatePayload>) => any | Promise<any>): CloudFunction<BillingEvent<PlanAutomatedUpdatePayload>>;