-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathindex.js
76 lines (71 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const { initializeApp } = require('firebase-admin/app');
const { getRemoteConfig } = require('firebase-admin/remote-config');
initializeApp();
// [START validate_template]
function validateTemplate(template) {
getRemoteConfig().validateTemplate(template)
.then((validatedTemplate) => {
// The template is valid and safe to use.
console.log('Template was valid and safe to use');
})
.catch((err) => {
console.error('Template is invalid and cannot be published');
console.error(err);
});
}
// [END validate_template]
// [START add_new_condition]
function addNewCondition(template) {
template.conditions.push({
name: 'android_en',
expression: 'device.os == \'android\' && device.country in [\'us\', \'uk\']',
tagColor: 'BLUE',
});
}
// [END add_new_condition]
// [START set_modify_parameter]
function setOrModifyParameter(template) {
// Set header_text parameter.
template.parameters['header_text'] = {
defaultValue: {
value: 'A Gryffindor must be brave, talented and helpful.'
},
conditionalValues: {
android_en: {
value: 'A Droid must be brave, talented and helpful.'
},
},
};
}
// [END set_modify_parameter]
// [START set_modify_parameter_group]
function setOrModifyParameterGroup(template) {
// Set new_menu parameter group
template.parameterGroups['new_menu'] = {
description: 'Description of the group.',
parameters: {
pumpkin_spice_season: {
defaultValue: {
value: 'A Gryffindor must love a pumpkin spice latte.'
},
conditionalValues: {
android_en: {
value: 'A Droid must love a pumpkin spice latte.'
},
},
description: 'Description of the parameter.',
},
},
};
}
// [END set_modify_parameter_group]
// [START add_parameter_to_group]
function addParameterToGroup(template) {
template.parameterGroups['new_menu'].parameters['spring_season'] = {
defaultValue: {
useInAppDefault: true
},
description: 'spring season menu visibility.',
};
}
// [END add_parameter_to_group]