Appwrite C++ SDK
Auto-generated API documentation for the Appwrite C++ SDK
Loading...
Searching...
No Matches
Messaging.hpp
Go to the documentation of this file.
1/// @file Messaging.hpp
2/// @brief Provides messaging-related operations (messages, topics, subscribers)
3
4#ifndef MESSAGING_HPP
5#define MESSAGING_HPP
6
7#include "Query.hpp"
8#include "Utils.hpp"
11#include <string>
12
13/**
14 * @class Messaging
15 * @brief Provides APIs to manage messaging: messages, topics, subscribers.
16 */
17class Messaging {
18 public:
19 /**
20 * @brief Constructor for Messaging service.
21 * @param projectId Appwrite project ID
22 * @param apiKey Appwrite API key
23 */
24 Messaging(const std::string &projectId, const std::string &apiKey);
25
26 /**
27 * @brief List all messages with optional filters.
28 * @param queries Query parameters for filtering results
29 * @return JSON string of message list
30 */
31 std::string listMessages(Queries &queries);
32
33 /**
34 * @brief Get a specific message by ID.
35 * @param messageId ID of the message
36 * @return JSON string of the message details
37 */
38 std::string getMessages(const std::string &messageId);
39
40 /**
41 * @brief Get details of a topic by ID.
42 * @param topicId ID of the topic
43 * @return JSON string of the topic
44 */
45 std::string getTopic(const std::string &topicId);
46
47 /**
48 * @brief List all topics with optional filters.
49 * @param queries Query parameters for filtering
50 * @return JSON string of topic list
51 */
52 std::string listTopics(Queries &queries);
53
54 /**
55 * @brief Delete a topic by its ID.
56 * @param topicId ID of the topic
57 * @return JSON response
58 */
59 std::string deleteTopic(const std::string &topicId);
60
61 /**
62 * @brief Create a new topic.
63 * @param topicId Unique topic ID
64 * @param name Name of the topic
65 * @param subscribe List of subscriber IDs
66 * @return JSON response
67 */
68 std::string createTopic(const std::string &topicId, const std::string &name,
69 const std::vector<std::string> &subscribe);
70
71 /**
72 * @brief Update an existing topic.
73 * @param topicId ID of the topic to update
74 * @param name New name for the topic
75 * @param subscribe Updated list of subscribers (optional)
76 * @return JSON response
77 */
78 std::string updateTopic(const std::string &topicId, const std::string &name,
79 const std::vector<std::string> &subscribe = {});
80
81 /**
82 * @brief Get details of a subscriber to a topic.
83 * @param topicId ID of the topic
84 * @param subscriberId ID of the subscriber
85 * @return JSON string of the subscriber
86 */
87 std::string getSubscriber(const std::string &topicId,
88 const std::string &subscriberId);
89
90 /**
91 * @brief List all subscribers of a topic.
92 * @param topicId ID of the topic
93 * @param queries Optional query filters
94 * @return JSON string of subscriber list
95 */
96 std::string listSubscribers(const std::string &topicId, Queries &queries);
97
98 /**
99 * @brief Delete a subscriber from a topic.
100 * @param topicId ID of the topic
101 * @param subscriberId ID of the subscriber to remove
102 * @return JSON response
103 */
104 std::string deleteSubscribers(const std::string &topicId,
105 const std::string &subscriberId);
106
107 /**
108 * @brief Add a subscriber to a topic.
109 * @param topicId ID of the topic
110 * @param name Name of the subscriber
111 * @param targetId Target platform/device
112 * @param subscriberId Unique ID for the subscriber
113 * @return JSON response
114 */
115 std::string createSubscribers(const std::string &topicId,
116 const std::string &name,
117 const std::string &targetId,
118 const std::string &subscriberId);
119 /**
120 * @brief Creates a new push notification message.
121 *
122 * Sends a push notification to specified users, topics, or both.
123 *
124 * @param messageId A unique Id for the message.
125 * @param title Title of the push notification.
126 * @param body Body content of the push notification.
127 * @param topicId A list of topic IDs to which the notification should be sent.
128 * @param userId A list of user IDs to which the notification should be sent.
129 * @param draft If true, saves the message as a draft.
130 *
131 * @return JSON response.
132 */
133 std::string createPush(const std::string &messageId,
134 const std::string &title,
135 const std::string &body,
136 const std::vector<std::string> &topicId= {},
137 const std::vector<std::string> &userId = {},
138 bool draft = false);
139
140 /**
141 * @brief Create a new email message.
142 *
143 * Sends a new email message to specific topics and/or target recipients.
144 * At least one of `topics` or `targets` must be provided.
145 *
146 * @param messageId Unique ID for the message.
147 * @param subject Subject line of the email.
148 * @param content Body content of the email.
149 * @param topics List of topic IDs to send the message to (optional).
150 * @param targets List of target recipients (e.g., email:userId) (optional).
151 * @return JSON response.
152 */
153 std::string createMessage(const std::string& messageId,
154 const std::string& subject,
155 const std::string& content,
156 const std::vector<std::string>& topics = {},
157 const std::vector<std::string>& targets = {});
158
159 /**
160 * @brief Updates an existing push notification message.
161 *
162 * Modifies the title and body of an existing push message.
163 *
164 * @param messageId The ID of the message to update.
165 * @param title New title of the push notification.
166 * @param body New body content of the push notification.
167 * @param topicId List of topic IDs to update the message.
168 * @param userId List of user IDs to update the message.
169 * @return JSON response
170 */
171 std::string updatePush(const std::string &messageId,
172 const std::string &title,
173 const std::string &body,
174 const std::vector<std::string> &topicId = {},
175 const std::vector<std::string> &userId = {});
176
177 /**
178 * @brief List all message logs with optional filters.
179 * @param messageId ID of the message
180 * @param queries Query parameters for filtering
181 * @return JSON string of messageLog list
182 */
183 std::string listMessageLogs(const std::string &messageId, Queries &queries);
184
185 /**
186 * @brief Delete a message by its ID.
187 * @param messageId ID of the message.
188 * @return JSON response.
189 */
190 std::string deleteMessages(const std::string &messageId);
191
192 /**
193 * @brief List all targets for a given message.
194 * @param messageId ID of the message.
195 * @param queries Optional query filters.
196 * @return JSON response.
197 */
198 std::string listTargets(const std::string &messageId,
199 const std::vector<std::string> &queries = {});
200 private:
201 std::string projectId; ///< Project ID
202 std::string apiKey; ///< API Key
203};
204
205#endif
Declares the base exception class used to represent Appwrite SDK errors.
Defines HTTP status code enums for consistent error and response handling.
Offers helper methods to construct query parameters for filtering and sorting API responses.
Provides utility functions and helpers used across the SDK.
Provides APIs to manage messaging: messages, topics, subscribers.
Definition Messaging.hpp:17
std::string updatePush(const std::string &messageId, const std::string &title, const std::string &body, const std::vector< std::string > &topicId={}, const std::vector< std::string > &userId={})
Updates an existing push notification message.
std::string createTopic(const std::string &topicId, const std::string &name, const std::vector< std::string > &subscribe)
Create a new topic.
std::string deleteTopic(const std::string &topicId)
Delete a topic by its ID.
std::string createMessage(const std::string &messageId, const std::string &subject, const std::string &content, const std::vector< std::string > &topics={}, const std::vector< std::string > &targets={})
Create a new email message.
std::string deleteMessages(const std::string &messageId)
Delete a message by its ID.
std::string deleteSubscribers(const std::string &topicId, const std::string &subscriberId)
Delete a subscriber from a topic.
std::string createSubscribers(const std::string &topicId, const std::string &name, const std::string &targetId, const std::string &subscriberId)
Add a subscriber to a topic.
std::string listTopics(Queries &queries)
List all topics with optional filters.
std::string getMessages(const std::string &messageId)
Get a specific message by ID.
std::string listMessageLogs(const std::string &messageId, Queries &queries)
List all message logs with optional filters.
std::string createPush(const std::string &messageId, const std::string &title, const std::string &body, const std::vector< std::string > &topicId={}, const std::vector< std::string > &userId={}, bool draft=false)
Creates a new push notification message.
std::string getTopic(const std::string &topicId)
Get details of a topic by ID.
Messaging(const std::string &projectId, const std::string &apiKey)
Constructor for Messaging service.
std::string getSubscriber(const std::string &topicId, const std::string &subscriberId)
Get details of a subscriber to a topic.
std::string updateTopic(const std::string &topicId, const std::string &name, const std::vector< std::string > &subscribe={})
Update an existing topic.
std::string listTargets(const std::string &messageId, const std::vector< std::string > &queries={})
List all targets for a given message.
std::string listSubscribers(const std::string &topicId, Queries &queries)
List all subscribers of a topic.
std::string listMessages(Queries &queries)
List all messages with optional filters.
Utility class to construct and manage Appwrite-style database query filters.
Definition Query.hpp:24