Create Message¶
Create common messages and alert messages on the Application Portal.
Prerequisites¶
The associated application has been purchased by the organization.
If this message is an alert about an asset, the asset or the parent node of the asset must have a tag value with “auth_unit: true”.
Request Format¶
POST https://{apigw-address}/app-portal-service/v2.1/message/produce
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
messages |
Mandatory |
MessageProduceDTO Struct |
The message details. |
MessageProduceDTO Struct¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
messageId |
Mandatory |
String |
The message ID. |
type |
Optional |
Integer |
The message type.
|
orgId |
Mandatory |
String |
The organization ID which the asset belongs to. How to get orgId >> |
accessKey |
Mandatory |
String |
The service account of the application. The application authenticates with |
body |
Optional |
I18nString |
Specify the message in its respective locale’s language. You must specify at least the |
color |
Optional |
Integer |
The color to indicate the message severity. |
ring |
Optional |
Integer |
The ringtone for the message. |
tags |
Optional |
Map |
Specify the tags in its respective locale’s language. Note: only the first 3 tags will be displayed. You must specify at least the |
produceTime |
Mandatory |
String |
The time the message is produced. Format: “yyyy-MM-dd HH:mm:ss” |
state |
Optional |
Integer |
The state of the message.
|
zoneOffset |
Mandatory |
String |
The timezone, such as “+08:00”. |
linkedAppId |
Optional |
String |
The application ID associated with the alert message. ( |
linkedMenuCode |
Optional |
String |
The menu identifier within the application that is associated with the message. ( |
linkedStates |
Optional |
String |
URL state associated with the message. ( |
feature |
Optional |
I18nString |
Specify the description by the customer in its respective locale’s language. You must specify at least the |
assetId |
Optional |
String |
The ID of the asset associated with the alert message. If the alert message is not related to an asset, there is no need to provide this. |
authUnitId |
Mandatory |
String |
The asset tagged as “auth_unit:true” in the asset tree of the EnOS platform. The value can either be “assetId” or the parent node of the “assetId”. It is the asset ID synchronized to the Application Portal to verify the permissions of an application.
|
callbackUrl |
Mandatory |
String |
The complete URL of the Application Portal callback (supporting URL Encode) after clicking the corresponding button of |
actionName |
Mandatory |
I18nString |
Specify the customized text on the button in the message window in its respective locale’s language. It is recommended to use two characters for Chinese and three characters for English, such as “确认” and “ACK”. If not provided, it will not be displayed. You must specify at least the |
Samples¶
Request Sample¶
url: https://{apigw-address}/app-portal-service/v2.1/message/produce
method: POST
requestBody:
{
"messages": [
{
"zoneOffset": "+08:00",
"linkedMenuCode": "menucode",
"linkedAppId": "accessKey",
"color": 1,
"ring": 1,
"messageId": "yunfan01",
"produceTime": "24/7/2019 11:22:01",
"body": {
"default": "This is a test3335",
"en_US": "This is a test3335",
"zh_CN": "这是个测试233335"
},
"type": 1,
"tags": [
{
"default": "Severe",
"en_US": "Severe",
"zh_CN": "严重"
},
{
"default": "Performance Alarm",
"en_US": "Performance Alarm",
"zh_CN": "性能告警"
},
{
"default": "Inverter",
"en_US": "Inverter",
"zh_CN": "逆变器"
}
],
"orgId": "yourOrgId",
"authUnitId": "7Uq6uP77",
"feature": {
"default": "This is a feature test3343",
"en_US": "This is a feature test3343",
"zh_CN": "这是个特征测试1"
},
"assetId": "7Uq6uP77",
"accessKey": "yourAccessKey",
"state": 0,
"linkedStates": "states",
"callbackUrl":"https://{app-service-address}/app-portal/test/v1/callback?appId=accessKey&messageId=messagett0q22w1299",
"actionName":
{
"en_US":"ACK",
"zh_CN":"确认"
}
}
]
}
Return Sample¶
{
"code": 200,
"message": "",
"data": null
}
Java SDK Sample¶
public class AppPortalSdkTest{
@Test
public void createMessageTest() {
MessageProduceRequest messageProduceRequest = new MessageProduceRequest();
List<MessageProduceDTO> messages = new ArrayList<MessageProduceDTO>();
MessageProduceDTO messageProduceDTO = new MessageProduceDTO();
messageProduceDTO.setMessageId("message_id");
messageProduceDTO.setAccessKey("your_access_key");
messageProduceDTO.setOrgId("your_org_id");
messageProduceDTO.setBody(new I18nString());
messageProduceDTO.setProduceTime(DateTimeUtil.getDateTime());
messageProduceDTO.setZoneOffset("+08:00");
messageProduceDTO.setLinkedAppId("your_access_key");
messageProduceDTO.setLinkedMenuCode("menu");
messageProduceDTO.setLinkedStates("");
messageProduceDTO.setAssetId("your_asset_id");
messageProduceDTO.setAuthUnitId("your_asset_id");
messageProduceDTO.setColor(1);
messageProduceDTO.setRing(0);
messageProduceDTO.setType(MessageType.ALARM.getValue());
messageProduceDTO.setCallbackUrl("/");
I18nString actionName=new I18nString();
actionName.put("zh_CN","确认");
actionName.put("en_US","ACK");
messageProduceDTO.setActionName(actionName);
messages.add(messageProduceDTO);
messageProduceRequest.setMessages(messages);
MessageProduceResponse messageProduceResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
.url("https://{apigw-address}").getResponse(messageProduceRequest, MessageProduceResponse.class);
System.out.println("request: " + JSONObject.toJSONString(messageProduceRequest));
System.out.println("response: " + JSONObject.toJSONString(messageProduceResponse));
}
}