@@ -548,6 +548,77 @@ std::string Messaging::createSms(const std::string &messageId,
548548 }
549549}
550550
551+ // Added method to update an existing SMS message
552+ std::string Messaging::updateSms (const std::string &messageId,
553+ const std::vector<std::string> &topics,
554+ const std::vector<std::string> &users,
555+ const std::vector<std::string> &targets,
556+ const std::string &content, bool draft,
557+ const std::string &scheduled_at) {
558+ if (messageId.empty ()) {
559+ throw AppwriteException (" Missing required parameter: 'messageId'" );
560+ }
561+
562+ if (content.empty ()) {
563+ throw AppwriteException (" Missing required parameter: 'content'" );
564+ }
565+
566+ std::string payload = " {" ;
567+
568+ payload += R"( "topics":[)" ;
569+ for (size_t i = 0 ; i < topics.size (); ++i) {
570+ payload += " \" " + Utils::escapeJsonString (topics[i]) + " \" " ;
571+ if (i != topics.size () - 1 )
572+ payload += " ," ;
573+ }
574+ payload += " ]" ;
575+
576+ payload += R"( ,"users":[)" ;
577+ for (size_t i = 0 ; i < users.size (); ++i) {
578+ payload += " \" " + Utils::escapeJsonString (users[i]) + " \" " ;
579+ if (i != users.size () - 1 )
580+ payload += " ," ;
581+ }
582+ payload += " ]" ;
583+
584+ payload += R"( ,"targets":[)" ;
585+ for (size_t i = 0 ; i < targets.size (); ++i) {
586+ payload += " \" " + Utils::escapeJsonString (targets[i]) + " \" " ;
587+ if (i != targets.size () - 1 )
588+ payload += " ," ;
589+ }
590+ payload += " ]" ;
591+
592+ payload += R"( ,"content":")" + Utils::escapeJsonString (content) + R"( ")" ;
593+
594+ payload += std::string (R"( ,"draft":)" ) + (draft ? " true" : " false" );
595+
596+ if (!scheduled_at.empty ()) {
597+ payload += R"( ,"scheduledAt":")" +
598+ Utils::escapeJsonString (scheduled_at) + " \" " ;
599+ }
600+
601+ payload += " }" ;
602+
603+ std::string url = Config::API_BASE_URL + " /messaging/messages/sms/" +
604+ Utils::urlEncode (messageId);
605+
606+ std::vector<std::string> headers = Config::getHeaders (projectId);
607+ headers.push_back (" X-Appwrite-Key: " + apiKey);
608+ headers.push_back (" Content-Type: application/json" );
609+
610+ std::string response;
611+ int statusCode = Utils::patchRequest (url, payload, headers, response);
612+
613+ if (statusCode == HttpStatus::OK) {
614+ return response;
615+ } else {
616+ throw AppwriteException (" Error updating sms message. Status code: " +
617+ std::to_string (statusCode) +
618+ " \n\n Response: " + response);
619+ }
620+ }
621+
551622// Added method to create a new email message.
552623std::string Messaging::createEmail (
553624 const std::string &messageId, const std::string &subject,
0 commit comments