messageToJson static method

String? messageToJson(
  1. String uid,
  2. String type,
  3. String content,
  4. ThreadProtobuf thread,
)

Implementation

static String? messageToJson(String uid, String type, String content, ThreadProtobuf thread) {
   Map<String, Object> messageExtra = {
				"orgUid": SpUtil.getString(BytedeskConstants.VISITOR_ORGUID)!
		};
  Map<String, Object> jsonContent = {
    "uid": uid,
				"type": type,
				"content": content,
				"status": BytedeskConstants.MESSAGE_STATUS_SENDING,
				"createdAt": BytedeskUtils.formatedDateNow(),
				"client": BytedeskConstants.HTTP_CLIENT,
				"extra": json.encode(messageExtra),
				"user": {
					"uid": SpUtil.getString(BytedeskConstants.VISITOR_UID)!,
					"nickname": SpUtil.getString(BytedeskConstants.VISITOR_NICKNAME)!,
					"avatar": SpUtil.getString(BytedeskConstants.VISITOR_AVATAR)!
				},
				"thread": {
					"uid": thread.uid,
					"topic": thread.topic,
					"type": thread.type,
					"status": thread.status,
					"user": thread.user
				}
  };
  return json.encode(jsonContent);
}