-
-
Notifications
You must be signed in to change notification settings - Fork 17
RecipientFields
Each plugin has the ability to add some particular fields to recipients.
To illustrate; the plugin "freeMobileSms" require a recipient to enter an userId and an apiKey.
In case a plugin needs some fields which depends on recipient and not on global configuration for accessing a third party software (push, sms, weather provider,...) it just have to declare fields in its package.json and locales.
Each field is a configuration item (can be integer, boolean aka checkbox, string with optional regex,...)
"recipientFields" : {
"userId": {
"type": "string",
"regex" : ""
},
"apiKey" : {
"type" : "string",
"regex" : ""
}
}
"recipientFields": {
"userId": {
"name": "User Login",
"description": "FreeMobile login",
"regexErrorMessage": ""
},
"apiKey": {
"name": "Api Key",
"description": "Your personal identification key (generated by FreeMobile)",
"regexErrorMessage": ""
}
}
The plugin must be instanciated once to make recipient fields visible.
Then editing a recipient will ask to enter (not mandatory) the fields.
From the pluginApi a simple method can obtain a recipient field value
auto userId = api->getRecipientValue(recipientId, "userId");
auto key = api->getRecipientValue(recipientId, "apiKey");
A plugin can access to:
- fields defined by system (first and last name)
- its fields (only them)
A plugin can not access a field defined by another plugin.
Yadoms -- The ultimate house automation solution