File tree Expand file tree Collapse file tree
examples/messaging/messages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,9 @@ createMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp
257257deleteProvider : $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/deleteProvider.cpp
258258 @mkdir -p ./$(TESTS_DIR )
259259 $(CXX ) $(CXXFLAGS ) -o ./$(TESTS_DIR ) /deleteProvider $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/deleteProvider.cpp $(LDFLAGS )
260+ listProviders : $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/listProviders.cpp
261+ @mkdir -p ./$(TESTS_DIR )
262+ $(CXX ) $(CXXFLAGS ) -o ./$(TESTS_DIR ) /listProviders $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/listProviders.cpp $(LDFLAGS )
260263listMessageLogs : $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/listMessageLogs.cpp
261264 @mkdir -p ./$(TESTS_DIR )
262265 $(CXX ) $(CXXFLAGS ) -o ./$(TESTS_DIR ) /listMessageLogs $(SRCS ) $(EXAMPLES_DIR ) /messaging/messages/listMessageLogs.cpp $(LDFLAGS )
Original file line number Diff line number Diff line change 1+ #include " Appwrite.hpp"
2+ #include < iostream>
3+ int main () {
4+ std::string projectId = " 68853010003a3f4fc106" ;
5+ std::string apiKey = " " ;
6+ Appwrite appwrite (projectId, apiKey);
7+ Queries queries;
8+ queries.queryLimit (50 );
9+ try {
10+ std::string response = appwrite.getMessaging ().listProviders (queries);
11+ std::cout << " providers fetched! \n Response: " << response << std::endl;
12+ } catch (const AppwriteException &ex) {
13+ std::cerr << " Exception: " << ex.what () << std::endl;
14+ }
15+ return 0 ;
16+ }
Original file line number Diff line number Diff line change @@ -173,6 +173,13 @@ class Messaging {
173173 const std::string &body,
174174 const std::vector<std::string> &topicId = {},
175175 const std::vector<std::string> &userId = {});
176+
177+ /* *
178+ * @brief List all providers.
179+ * @param queries Optional query filters
180+ * @return JSON string of providers list
181+ */
182+ std::string listProviders (Queries &queries);
176183
177184 /* *
178185 * @brief Delete a provider.
Original file line number Diff line number Diff line change @@ -544,6 +544,19 @@ std::string Messaging::deleteProvider(const std::string &providerId) {
544544 return " provider deleted successfully." ;
545545 } else {
546546 throw AppwriteException (" Failed to delete provider. Status code: " +
547+ }
548+ }
549+
550+ std::string Messaging::listProviders (Queries &queries) {
551+ std::string url = Config::API_BASE_URL + " /messaging/providers" ;
552+ std::vector<std::string> headers = Config::getHeaders (projectId);
553+ headers.push_back (" X-Appwrite-Key: " + apiKey);
554+ std::string response;
555+ int statusCode = Utils::getRequest (url, headers, response);
556+ if (statusCode == HttpStatus::OK ) {
557+ return response;
558+ } else {
559+ throw AppwriteException (" Error listing providers . Status code: " +
547560 std::to_string (statusCode) +
548561 " \n Response: " + response);
549562 }
You can’t perform that action at this time.
0 commit comments