RPC methods¶
The notification module provides the following RPC methods:
sendMail¶
Struct sendMail(Struct email)
This method returns a Struct with the following properties:
| Property | Type | Description |
|---|---|---|
id |
String |
The UUID of the queued message. |
success |
Boolean |
true when the message was queued successfully. |
The parameter Struct has the following properties:
| Property | Type | Optional | Description |
|---|---|---|---|
to |
String or Array |
no | The e-mail address or several where the e-mail will be sent. |
toName |
String |
yes | The name for the e-mail, if to is a String, otherwise ignored. |
from |
String |
yes | The e-mail address of the sender. |
fromName |
String |
yes | The name for the sender. |
cc |
String or Array |
yes | An e-mail address or several, for 'carbon copy'. |
ccName |
String |
yes | The name for the cc e-mail, if cc is a String, otherwise ignored. |
bcc |
String or Array |
yes | An e-mail address or several, for 'blind carbon copy'. |
bccName |
String |
yes | The name for the bcc e-mail, if bcc is a String, otherwise ignored. |
subject |
String |
no | The subject for the e-mail. |
message |
String |
no | The e-mail contents. |
moduleId |
String |
yes | An optional module identifier for tracking purposes. |
moduleMetadata |
Struct |
yes | Optional metadata from the calling module, stored with the message. |
businessPartnerId |
String |
yes | The business partner UUID, stored with the message for filtering. |
locationId |
String |
yes | The full location ID string (e.g. pf:eu.p.au.sid). |
portfolioId |
String |
yes | The portfolio ID component of the location. |
economicUnitId |
String |
yes | The economic unit ID component of the location. |
propertyId |
String |
yes | The property ID component of the location. |
administrationUnitId |
String |
yes | The administration unit ID component of the location. |
subId |
String |
yes | The sub ID component of the location. |
to, cc and bcc can be Arrays, in which case they contain Struct values (at least one in to case), having the properties:
| Property | Type | Optional | Description |
|---|---|---|---|
emailAddress |
String |
no | The e-mail address. |
name |
String |
yes | The name of the recipient. |
Note the difference in property name, depending if it's for a to, cc or bcc property.
Examples:¶
{
"id": 12,
"method":"sendMail",
"params":[{
"to":"email@domain.org",
"toName":"John Doe",
"cc":"other_email@domain.org",
"ccName":"John Doe 2",
"bcc":"other_email2@domain.org",
"bccName":"John Doe 3",
"from":"whatever@email.com",
"fromName":"Nemo",
"subject":"The subject",
"message":"Message text"
}]
}
Every parameter is optional except to, subject and message. The from and fromName, if not set, are taken from the configuration file (if set, otherwise they are left empty).
The above example allows only one recipient for to, cc and bcc. One can specify more than one recipient using arrays:
{
"id": 12,
"method":"sendMail",
"params":[{
"to":[{
"emailAddress":"email@domain.org",
"name":"John Doe"
}],
"cc":[{
"emailAddress":"other_email@domain.org",
"name":"John Doe 2"
}],
"bcc":[{
"emailAddress":"other_email2@domain.org",
"name":"John Doe 3"
}],
"from":"whatever@email.com",
"fromName":"Nemo",
"subject":"The subject",
"message":"Message text"
}]
}
The above example contains only one recipient in the arrays, but one can specify more than one if needed.
sendSms¶
Struct sendSms(Struct sms)
This method returns a Struct with the following properties:
| Property | Type | Description |
|---|---|---|
id |
String |
The UUID of the queued message. |
success |
Boolean |
true when the message was queued successfully. |
The parameter Struct has the following properties:
| Property | Type | Optional | Description |
|---|---|---|---|
to |
String |
no | The recipient number (or address book entry: group, contact). |
from |
String |
yes | The sender number or name. |
message |
String |
no | The text to send. |
moduleId |
String |
yes | An optional module identifier for tracking purposes. |
moduleMetadata |
Struct |
yes | Optional metadata from the calling module, stored with the message. |
businessPartnerId |
String |
yes | The business partner UUID, stored with the message for filtering. |
locationId |
String |
yes | The full location ID string (e.g. pf:eu.p.au.sid). |
portfolioId |
String |
yes | The portfolio ID component of the location. |
economicUnitId |
String |
yes | The economic unit ID component of the location. |
propertyId |
String |
yes | The property ID component of the location. |
administrationUnitId |
String |
yes | The administration unit ID component of the location. |
subId |
String |
yes | The sub ID component of the location. |
The message text cannot be bigger than 1520 chars. Attachments will add some overhead due of the links added, so those must be taken into account.
To have a single message sent, it must not be over 160 chars.
to can contain more than one number (or address book entry), just separate them with commas.
from can be either a number or some name. Can contain either 11 alphanumeric chars or 16 numeric chars. If not specified, it will be specified from the configuration file (if specified there).
Just a message:
{
"id": 12,
"method":"sendSms",
"params":[{
"to":"+404832490343",
"from":"John Doe",
"message":"Message text"
}]
}
from is optional but probably it should be specified either in the call or in the configuration file.
getNotificationLog¶
Struct getNotificationLog(Struct filter)
Returns a list of sent and failed notification messages.
The parameter Struct has the following properties:
| Property | Type | Optional | Description |
|---|---|---|---|
moduleId |
String |
yes | Filter by the module that sent the notification. |
limit |
Integer |
yes | Maximum number of results (default 100, max 1000). |
offset |
Integer |
yes | Pagination offset (epoch seconds of the last entry's createdAt). |
filter |
Struct |
yes | Filter by moduleMetadata fields (key-value equality match). |
search |
String |
yes | Search string (matched against recipient, subject, message, metadata). |
businessPartnerId |
String |
yes | Filter by business partner UUID. |
locationIdFilterType |
String |
yes | parent (default) or exact. Controls how location filtering works. |
locationId |
String |
yes | The full location ID string. Used for exact matching. |
portfolioId |
String |
yes | Filter by portfolio ID. Used for parent matching. |
economicUnitId |
String |
yes | Filter by economic unit ID. Used for parent matching. |
propertyId |
String |
yes | Filter by property ID. Used for parent matching. |
administrationUnitId |
String |
yes | Filter by administration unit ID. Used for parent matching. |
subId |
String |
yes | Filter by sub ID. Used for parent matching. |
The response Struct has the following properties:
| Property | Type | Description |
|---|---|---|
notifications |
Array |
Array of notification Structs (see below). |
responseMetadata |
Struct |
Contains nextKey for pagination (if more results exist). |
Each notification Struct contains:
| Property | Type | Description |
|---|---|---|
id |
String |
The notification UUID. |
type |
String |
The notification type (email or sms). |
createdAt |
String |
The creation timestamp. |
recipient |
String |
The recipient address. |
subject |
String |
The subject (for e-mails). |
status |
String |
The delivery status. |
moduleMetadata |
Struct |
Optional metadata from the calling module. |
getNotificationDetails¶
Struct getNotificationDetails(Struct query)
Returns detailed information about a specific notification message.
The parameter Struct has the following properties:
| Property | Type | Optional | Description |
|---|---|---|---|
messageId |
String |
no | The UUID of the message to retrieve. |
The response Struct has the following properties:
| Property | Type | Description |
|---|---|---|
id |
String |
The notification UUID. |
type |
String |
The notification type (email or sms). |
createdAt |
String |
The creation timestamp. |
recipient |
String |
The recipient address. |
subject |
String |
The subject (for e-mails). |
message |
String |
The full message content. |
status |
String |
The delivery status. |
moduleMetadata |
Struct |
Optional metadata from the calling module. |