Skip to content

RecipientFields

jano42 edited this page Jul 1, 2016 · 1 revision

Recipients

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,...)

freeMobileSms : Package.json

  "recipientFields" : {
    "userId": {
      "type": "string",
      "regex" : ""
    },
    "apiKey" : {
      "type" : "string",
      "regex" : ""
    }
  }
  

freeMobileSms : locale/en.json (and translations for other languages)

	"recipientFields": {
		"userId": {
			"name": "User Login",
			"description": "FreeMobile login",
			"regexErrorMessage": ""
		},
		"apiKey": {
			"name": "Api Key",
			"description": "Your personal identification key (generated by FreeMobile)",
			"regexErrorMessage": ""
		}
	}

What happends

The plugin must be instanciated once to make recipient fields visible.

Then editing a recipient will ask to enter (not mandatory) the fields.

Plugin : how to retreive data

From the pluginApi a simple method can obtain a recipient field value

      auto userId = api->getRecipientValue(recipientId, "userId");
      auto key = api->getRecipientValue(recipientId, "apiKey");

Recipient fields access

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.

Clone this wiki locally