forked from pooranjoyb/cpp-sdk-appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessaging.hpp
More file actions
227 lines (203 loc) · 7.91 KB
/
Messaging.hpp
File metadata and controls
227 lines (203 loc) · 7.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/// @file Messaging.hpp
/// @brief Provides messaging-related operations (messages, topics, subscribers)
#ifndef MESSAGING_HPP
#define MESSAGING_HPP
#include "Query.hpp"
#include "Utils.hpp"
#include "enums/HttpStatus.hpp"
#include "exceptions/AppwriteException.hpp"
#include <string>
/**
* @class Messaging
* @brief Provides APIs to manage messaging: messages, topics, subscribers.
*/
class Messaging {
public:
/**
* @brief Constructor for Messaging service.
* @param projectId Appwrite project ID
* @param apiKey Appwrite API key
*/
Messaging(const std::string &projectId, const std::string &apiKey);
/**
* @brief List all messages with optional filters.
* @param queries Query parameters for filtering results
* @return JSON string of message list
*/
std::string listMessages(Queries &queries);
/**
* @brief Get a specific message by ID.
* @param messageId ID of the message
* @return JSON string of the message details
*/
std::string getMessages(const std::string &messageId);
/**
* @brief Get details of a topic by ID.
* @param topicId ID of the topic
* @return JSON string of the topic
*/
std::string getTopic(const std::string &topicId);
/**
* @brief List all topics with optional filters.
* @param queries Query parameters for filtering
* @return JSON string of topic list
*/
std::string listTopics(Queries &queries);
/**
* @brief Delete a topic by its ID.
* @param topicId ID of the topic
* @return JSON response
*/
std::string deleteTopic(const std::string &topicId);
/**
* @brief Create a new topic.
* @param topicId Unique topic ID
* @param name Name of the topic
* @param subscribe List of subscriber IDs
* @return JSON response
*/
std::string createTopic(const std::string &topicId, const std::string &name,
const std::vector<std::string> &subscribe);
/**
* @brief Update an existing topic.
* @param topicId ID of the topic to update
* @param name New name for the topic
* @param subscribe Updated list of subscribers (optional)
* @return JSON response
*/
std::string updateTopic(const std::string &topicId, const std::string &name,
const std::vector<std::string> &subscribe = {});
/**
* @brief Get details of a subscriber to a topic.
* @param topicId ID of the topic
* @param subscriberId ID of the subscriber
* @return JSON string of the subscriber
*/
std::string getSubscriber(const std::string &topicId,
const std::string &subscriberId);
/**
* @brief List all subscribers of a topic.
* @param topicId ID of the topic
* @param queries Optional query filters
* @return JSON string of subscriber list
*/
std::string listSubscribers(const std::string &topicId, Queries &queries);
/**
* @brief Delete a subscriber from a topic.
* @param topicId ID of the topic
* @param subscriberId ID of the subscriber to remove
* @return JSON response
*/
std::string deleteSubscribers(const std::string &topicId,
const std::string &subscriberId);
/**
* @brief Add a subscriber to a topic.
* @param topicId ID of the topic
* @param name Name of the subscriber
* @param targetId Target platform/device
* @param subscriberId Unique ID for the subscriber
* @return JSON response
*/
std::string createSubscribers(const std::string &topicId,
const std::string &name,
const std::string &targetId,
const std::string &subscriberId);
/**
* @brief Creates a new push notification message.
*
* Sends a push notification to specified users, topics, or both.
*
* @param messageId A unique Id for the message.
* @param title Title of the push notification.
* @param body Body content of the push notification.
* @param topicId A list of topic IDs to which the notification should be sent.
* @param userId A list of user IDs to which the notification should be sent.
* @param draft If true, saves the message as a draft.
*
* @return JSON response.
*/
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);
/**
* @brief Create a new email message.
*
* Sends a new email message to specific topics and/or target recipients.
* At least one of `topics` or `targets` must be provided.
*
* @param messageId Unique ID for the message.
* @param subject Subject line of the email.
* @param content Body content of the email.
* @param topics List of topic IDs to send the message to (optional).
* @param targets List of target recipients (e.g., email:userId) (optional).
* @return JSON response.
*/
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 = {});
/**
* @brief Updates an existing push notification message.
*
* Modifies the title and body of an existing push message.
*
* @param messageId The ID of the message to update.
* @param title New title of the push notification.
* @param body New body content of the push notification.
* @param topicId List of topic IDs to update the message.
* @param userId List of user IDs to update the message.
* @return JSON response
*/
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 = {});
/**
* @brief List all providers.
* @param queries Optional query filters
* @return JSON string of providers list
*/
std::string listProviders(Queries &queries);
/**
* @brief Delete a provider.
* @param providerId ID of the provider
* @return JSON response
*/
std::string deleteProvider(const std::string &providerId);
/**
* @brief Get a specific provider by ID.
* @param providerId ID of the provider
* @return JSON string of the provider details
*/
std::string getProvider(const std::string &providerId);
/**
* @brief List all message logs with optional filters.
* @param messageId ID of the message
* @param queries Query parameters for filtering
* @return JSON string of messageLog list
*/
std::string listMessageLogs(const std::string &messageId, Queries &queries);
/**
* @brief Delete a message by its ID.
* @param messageId ID of the message.
* @return JSON response.
*/
std::string deleteMessages(const std::string &messageId);
/**
* @brief List all targets for a given message.
* @param messageId ID of the message.
* @param queries Optional query filters.
* @return JSON response.
*/
std::string listTargets(const std::string &messageId,
const std::vector<std::string> &queries = {});
private:
std::string projectId; ///< Project ID
std::string apiKey; ///< API Key
};
#endif