UNPKG

3.09 kBJavaScriptView Raw
1"use strict";
2/**
3 * Copyright 2018 Google Inc. All Rights Reserved.
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 */
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.UpdatePermission = void 0;
19const permission_1 = require("./permission");
20/**
21 * Prompts the user for permission to send proactive updates at any time.
22 *
23 * @example
24 * ```javascript
25 *
26 * // Actions SDK
27 * const app = actionssdk()
28 *
29 * app.intent('actions.intent.MAIN', conv => {
30 * conv.ask(new UpdatePermission({
31 * intent: 'show.image',
32 * arguments: [{
33 * name: 'image_to_show',
34 * textValue: 'image_type_1',
35 * }
36 * ))
37 * })
38 *
39 * app.intent('actions.intent.PERMISSION', conv => {
40 * const granted = conv.arguments.get('PERMISSION')
41 * if (granted) {
42 * conv.close(`Great, I'll send an update whenever I notice a change`)
43 * } else {
44 * // Response shows that user did not grant permission
45 * conv.close('Alright, just let me know whenever you need the weather!')
46 * }
47 * })
48 *
49 * app.intent('show.image', conv => {
50 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
51 * // do something with arg
52 * })
53 *
54 * // Dialogflow
55 * const app = dialogflow()
56 *
57 * app.intent('Default Welcome Intent', conv => {
58 * conv.ask(new UpdatePermission({
59 * intent: 'Show Image',
60 * arguments: [{
61 * name: 'image_to_show',
62 * textValue: 'image_type_1',
63 * }
64 * ))
65 * })
66 *
67 * // Create a Dialogflow intent with the `actions_intent_PERMISSION` event
68 * app.intent('Get Permission', conv => {
69 * const granted = conv.arguments.get('PERMISSION')
70 * if (granted) {
71 * conv.close(`Great, I'll send an update whenever I notice a change`)
72 * } else {
73 * // Response shows that user did not grant permission
74 * conv.close('Alright, just let me know whenever you need the weather!')
75 * }
76 * })
77 *
78 * app.intent('Show Image', conv => {
79 * const arg = conv.arguments.get('image_to_show') // will be 'image_type_1'
80 * // do something with arg
81 * })
82 * ```
83 *
84 * @public
85 */
86class UpdatePermission extends permission_1.Permission {
87 /**
88 * @param options UpdatePermission options
89 * @public
90 */
91 constructor(options) {
92 super({
93 permissions: 'UPDATE',
94 extra: {
95 updatePermissionValueSpec: {
96 arguments: options.arguments,
97 intent: options.intent,
98 },
99 },
100 });
101 }
102}
103exports.UpdatePermission = UpdatePermission;
104//# sourceMappingURL=update.js.map
\No newline at end of file