Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ listTargets: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listTargets.cpp
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listTargets $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listTargets.cpp $(LDFLAGS)


listProviderLogs: $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviderLogs.cpp
@mkdir -p ./$(TESTS_DIR)
$(CXX) $(CXXFLAGS) -o ./$(TESTS_DIR)/listProviderLogs $(SRCS) $(EXAMPLES_DIR)/messaging/messages/listProviderLogs.cpp $(LDFLAGS)

# Messaging - Topics
getTopic: $(SRCS) $(EXAMPLES_DIR)/messaging/topics/getTopic.cpp
@mkdir -p ./$(TESTS_DIR)
Expand Down
19 changes: 19 additions & 0 deletions examples/messaging/messages/listProviderLogs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "68853010003a3f4fc106";
std::string apiKey = "";
std::string providerId = "68bf146d003761d36496";
Appwrite appwrite(projectId, apiKey);
Queries queries;
queries.queryLimit(50);
try {
std::string response =
appwrite.getMessaging().listProviderLogs(providerId, queries);
std::cout << "provider logs fetched! \nResponse: " << response
<< std::endl;
} catch (const AppwriteException &ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}
11 changes: 10 additions & 1 deletion include/classes/Messaging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,16 @@ class Messaging {
*/
std::string listProviders(Queries &queries);

/**
/**
* @brief List all provider logs.
* @param providerId ID of the provider
* @param queries Optional query filters
* @return JSON string of provider logs list
*/
std::string listProviderLogs(const std::string &providerId,
Queries &queries);

/**
* @brief Create a new Firebase Cloud Messaging provider.
* @param providerId A unique Id for the provider.
* @param name provider name.
Expand Down
21 changes: 21 additions & 0 deletions src/services/Messaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,26 @@ std::string Messaging::updatePush(const std::string &messageId,
}
}

std::string Messaging::listProviderLogs(const std::string &providerId,
Queries &queries) {
if (providerId.empty()) {
throw AppwriteException("Missing required parameter: providerId");
}
std::string url =
Config::API_BASE_URL + "/messaging/providers/" + providerId + "/logs";
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 logs. Status code: " +
std::to_string(statusCode) +
"\nResponse: " + response);
}
}

std::string Messaging::createFcmProvider(std::string &providerId,
std::string name,
std::string service_account_json,
Expand Down Expand Up @@ -681,3 +701,4 @@ std::string Messaging::listTargets(const std::string &messageId,
}
}


Loading