getMessage static method
Implementation
static Future<bool> getMessage(
TPChannel tpChannel,
String messageId,
Function(TPMessage) successCallback,
{
String translationLanguage = "",
Function(int? errorCode, String? errorMessage)? errorCallback
}) async
{
if (!_isInitialized(errorCallback: errorCallback)) { return false; }
if (!_checkAuthInfo(errorCallback: errorCallback)) { return false; }
String url = "/channels/${tpChannel.getChannelId()}/messages/$messageId";
// Appends query string
if(translationLanguage.isNotEmpty){
String queryString = _buildQueryString({"translationTargetLanguage" : translationLanguage});
url += queryString;
}
try {
Map<String, dynamic> response = await HttpUtil.get(url);
successCallback(TPMessage(response["message"]));
return true;
} on TPException catch(e) {
Logger.log("$e");
if(errorCallback != null) { errorCallback(e.getCode(), e.getMessage()); }
} catch(e){
Logger.log("$e");
if(errorCallback != null) { errorCallback(-1, e.toString()); }
}
return false;
}