I don't have the code for parsing and downloading attachments from the notification payload. But you can modify this code snippet to work with the notification payload.
public void read_message_store_sms() throws RestException, IOException{
ListMessagesParameters parameters = new ListMessagesParameters();
parameters.messageType = new String[] {"SMS"};
parameters.dateFrom = "2023-05-01T00:00:00.222Z";
var response = restClient.restapi().account().extension().messageStore().list(parameters);
for (GetMessageInfoResponse record : response.records)
{
if (record.attachments != null)
{
for (var attachment : record.attachments)
{
var fileName = "./src/test/resources/" + record.attachments[0].id + "_mms";
if (attachment.type.equals("MmsAttachment"))
{
if (attachment.contentType.equals("image/png"))
fileName += ".png";
else if (attachment.contentType.equals("image/jpeg"))
fileName += ".jpg";
else
fileName += ".xxx";
var res = restClient.restapi().account().extension().messageStore(record.id.toString()).content(attachment.id.toString()).get();
Path path = Paths.get(fileName);
Files.write(path, res);
}
}
}
}
}
All you need is to parse the payload, check the "attachments" then use the code above to download it.
Note: This code uses the RingCentral Java SDK.