UNPKG

2.66 kBTypeScriptView Raw
1/**
2 * Copyright 2018 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as Api from '../../api/v2';
17import { SimpleResponse } from './simple';
18import { BasicCard, Table } from './card';
19import { BrowseCarousel } from './browse';
20import { MediaResponse } from './media';
21import { OrderUpdate } from './order';
22import { LinkOutSuggestion } from './linkout';
23import { Suggestions } from './suggestion';
24import { HtmlResponse } from './html';
25/** @public */
26export declare type RichResponseItem = string | SimpleResponse | BasicCard | Table | BrowseCarousel | MediaResponse | OrderUpdate | LinkOutSuggestion | HtmlResponse | Api.GoogleActionsV2RichResponseItem;
27/** @public */
28export interface RichResponseOptions {
29 /**
30 * Ordered list of either SimpleResponse objects or BasicCard objects.
31 * First item must be SimpleResponse. There can be at most one card.
32 * @public
33 */
34 items?: RichResponseItem[];
35 /**
36 * Ordered list of text suggestions to display. Optional.
37 * @public
38 */
39 suggestions?: string[] | Suggestions;
40 /**
41 * Link Out Suggestion chip for this rich response. Optional.
42 * @public
43 */
44 link?: Api.GoogleActionsV2UiElementsLinkOutSuggestion;
45}
46/**
47 * Class for initializing and constructing Rich Responses with chainable interface.
48 * @public
49 */
50export interface RichResponse extends Api.GoogleActionsV2RichResponse {
51}
52export declare class RichResponse implements Api.GoogleActionsV2RichResponse {
53 /**
54 * @param options RichResponse options
55 * @public
56 */
57 constructor(options: RichResponseOptions);
58 /**
59 * @param items RichResponse items
60 * @public
61 */
62 constructor(items: RichResponseItem[]);
63 /**
64 * @param items RichResponse items
65 * @public
66 */
67 constructor(...items: RichResponseItem[]);
68 /**
69 * Add a RichResponse item
70 * @public
71 */
72 add(...items: RichResponseItem[]): this;
73 /**
74 * Adds a single suggestion or list of suggestions to list of items.
75 * @public
76 */
77 addSuggestion(...suggestions: (string | Suggestions)[]): this;
78}