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