-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMessaging.hpp
More file actions
158 lines (143 loc) · 5.39 KB
/
Messaging.hpp
File metadata and controls
158 lines (143 loc) · 5.39 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
/// @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>
#include <vector>
/**
* @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);
std::string createPush(const std::string &messageId,
const std::string &title,
const std::string &body,
const std::string &topicId);
/**
* @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 Create a new SMS message.
*
* Sends an SMS message to a specific recipient phone number.
*
* @param recipient Phone number of the recipient (e.g., +911234567890).
* @param message Text message content.
* @return JSON response.
*/
std::string createSms(const std::string &recipient,
const std::string &message);
private:
std::string projectId; ///< Project ID
std::string apiKey; ///< API Key
};
#endif