Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ getMessages: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/getMessages.cpp
createMessage: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/createMessage $(SRCS) $(EXAMPLES_DIR)/messaging/messages/createMessage.cpp $(LDFLAGS)
listProviders: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviders.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listProviders $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviders.cpp $(LDFLAGS)
listMessageLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listMessageLogs $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listMessageLogs.cpp $(LDFLAGS)
Expand Down
16 changes: 16 additions & 0 deletions examples/messaging/messages/listProviders.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "68853010003a3f4fc106";
std::string apiKey = "";
Appwrite appwrite(projectId, apiKey);
Queries queries;
queries.queryLimit(50);
try {
std::string response = appwrite.getMessaging().listProviders(queries);
std::cout << "providers fetched! \nResponse: " << response << std::endl;
} catch (const AppwriteException &ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}
8 changes: 7 additions & 1 deletion include/classes/Messaging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,14 @@ class Messaging {
const std::string &body,
const std::vector<std::string> &topicId = {},
const std::vector<std::string> &userId = {});

/**
* @brief List all providers.
* @param queries Optional query filters
* @return JSON string of providers list
*/
std::string listProviders(Queries &queries);

* @brief List all message logs with optional filters.
* @param messageId ID of the message
* @param queries Query parameters for filtering
Expand Down
14 changes: 14 additions & 0 deletions src/services/Messaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,20 @@ std::string Messaging::updatePush(const std::string &messageId,
}
}

std::string Messaging::listProviders(Queries &queries) {
std::string url = Config::API_BASE_URL + "/messaging/providers";
std::vector<std::string> headers = Config::getHeaders(projectId);
headers.push_back("X-Appwrite-Key: " + apiKey);
std::string response;
int statusCode = Utils::getRequest(url, headers, response);
if (statusCode == HttpStatus::OK) {
return response;
} else {
throw AppwriteException("Error listing providers . Status code: " +
std::to_string(statusCode) +
"\nResponse: " + response);
}
}

std::string Messaging::listMessageLogs(const std::string &messageId,
Queries &queries) {
Expand Down