UNPKG

3.42 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';
17/** @public */
18export declare type SurfaceCapability = 'actions.capability.AUDIO_OUTPUT' | 'actions.capability.SCREEN_OUTPUT' | 'actions.capability.MEDIA_RESPONSE_AUDIO' | 'actions.capability.WEB_BROWSER' | 'actions.capability.INTERACTIVE_CANVAS';
19export declare class Surface {
20 /** @public */
21 capabilities: Capabilities;
22 /** @hidden */
23 constructor(surface?: Api.GoogleActionsV2Surface);
24 /**
25 * Checks if surface has an attribute like a capability
26 *
27 * @example
28 * ```javascript
29 *
30 * app.intent('Default Welcome Intent', conv => {
31 * if (conv.surface.has('actions.capability.AUDIO_OUTPUT')) {
32 * conv.ask('You can hear me! How are you?')
33 * } else {
34 * conv.ask('You can read this! How are you?')
35 * }
36 * })
37 * ```
38 *
39 * @param attribute An attribute like SurfaceCapability
40 * @public
41 */
42 has(attribute: SurfaceCapability): boolean;
43}
44export declare class Capabilities {
45 /**
46 * List of surface capabilities of user device.
47 * @public
48 */
49 list: Api.GoogleActionsV2Capability[];
50 /** @hidden */
51 constructor(list?: Api.GoogleActionsV2Capability[]);
52 /**
53 * Returns true if user device has a given surface capability.
54 * @public
55 */
56 has(capability: SurfaceCapability): boolean;
57}
58export declare class AvailableSurfacesCapabilities {
59 /** @public */
60 surfaces: Surface[];
61 /** @hidden */
62 constructor(surfaces: Surface[]);
63 /**
64 * Returns true if user has an available surface which includes all given
65 * capabilities. Available surfaces capabilities may exist on surfaces other
66 * than that used for an ongoing conversation.
67 * @public
68 */
69 has(capability: SurfaceCapability): boolean;
70}
71export declare class AvailableSurfaces {
72 /** @public */
73 list: Surface[];
74 /** @public */
75 capabilities: AvailableSurfacesCapabilities;
76 /** @hidden */
77 constructor(list: Api.GoogleActionsV2Surface[]);
78 /**
79 * Checks if available surfaces has an attribute like a capability
80 *
81 * @example
82 * ```javascript
83 *
84 * app.intent('Default Welcome Intent', conv => {
85 * if (conv.available.surfaces.has('actions.capability.SCREEN_OUTPUT')) {
86 * conv.ask('You have a device that can view images! How are you?')
87 * } else {
88 * conv.ask('You do not have a device that can view images! How are you?')
89 * }
90 * })
91 * ```
92 *
93 * @param attribute An attribute like SurfaceCapability
94 * @public
95 */
96 has(attribute: SurfaceCapability): boolean;
97}
98export declare class Available {
99 /** @public */
100 surfaces: AvailableSurfaces;
101 /** @hidden */
102 constructor(surfaces?: Api.GoogleActionsV2Surface[]);
103}