@@ -468,6 +468,41 @@ std::string Messaging::createMessage(const std::string& messageId,
468468 }
469469}
470470
471+ std::string Messaging::updateEmail (
472+ const std::string& messageId,
473+ const std::string& subject,
474+ const std::string& content
475+ ) {
476+ if (messageId.empty ()) {
477+ throw AppwriteException (" Missing required parameter: 'messageId'" );
478+ }
479+ if (subject.empty ()) {
480+ throw AppwriteException (" Missing required parameter: 'subject'" );
481+ }
482+ if (content.empty ()) {
483+ throw AppwriteException (" Missing required parameter: 'content'" );
484+ }
485+
486+ std::string url = Config::API_BASE_URL + " /messaging/messages/email/" + Utils::urlEncode (messageId);
487+
488+ std::string payload = R"( {"subject":")" + Utils::escapeJsonString (subject) +
489+ R"( ","content":")" + Utils::escapeJsonString (content) + R"( "})" ;
490+
491+ std::vector<std::string> headers = Config::getHeaders (projectId);
492+ headers.push_back (" X-Appwrite-Key: " + apiKey);
493+ headers.push_back (" Content-Type: application/json" );
494+
495+ std::string response;
496+ int statusCode = Utils::patchRequest (url, payload, headers, response);
497+
498+ if (statusCode == HttpStatus::OK ) {
499+ return response;
500+ } else {
501+ throw AppwriteException (" Error updating message. Status code: " + std::to_string (statusCode) +
502+ " \n\n Response: " + response);
503+ }
504+ }
505+
471506std::string Messaging::updatePush (const std::string &messageId,
472507 const std::string &title,
473508 const std::string &body,
0 commit comments