@@ -530,6 +530,36 @@ std::string Messaging::updatePush(const std::string &messageId,
530530 }
531531}
532532
533+ std::string Messaging::createFcmProvider (std::string &providerId,
534+ std::string name,
535+ std::string service_account_json,
536+ bool enabled) {
537+ if (providerId.empty ()) {
538+ throw AppwriteException (" Missing required parameter: 'providerId'" );
539+ }
540+ if (name.empty ()) {
541+ throw AppwriteException (" Missing required parameter: 'name'" );
542+ }
543+ std::string url = Config::API_BASE_URL + " /messaging/providers/fcm" ;
544+ std::string payload =
545+ R"( {"providerId":")" + Utils::escapeJsonString (providerId) +
546+ R"( ","name":")" + Utils::escapeJsonString (name) +
547+ R"( ","serviceAccountJSON":)" + service_account_json + R"( ,"enabled":)" +
548+ (enabled ? " true" : " false" ) + R"( })" ;
549+ std::vector<std::string> headers = Config::getHeaders (projectId);
550+ headers.push_back (" X-Appwrite-Key: " + apiKey);
551+ headers.push_back (" Content-Type: application/json" );
552+ std::string response;
553+ int statusCode = Utils::postRequest (url, payload, headers, response);
554+ if (statusCode == HttpStatus::CREATED) {
555+ return response;
556+ } else {
557+ throw AppwriteException (" Error Creating fcm provider. Status code: " +
558+ std::to_string (statusCode) +
559+ " \n\n Response: " + response);
560+ }
561+ }
562+
533563std::string Messaging::deleteProvider (const std::string &providerId) {
534564 if (providerId.empty ()) {
535565 throw AppwriteException (" Missing required parameter: providerId" );
0 commit comments