2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_NOTIFICATION_H__
18 #define __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_NOTIFICATION_H__
20 #include <smartthings_resource.h>
27 * @file smartthings_notification.h
31 * @addtogroup CAPI_SMARTTHINGS_THING_NOTIFICATION_MODULE
36 * @brief Enumeration for the type of notification.
40 SMARTTHINGS_NOTIFICATION_TYPE_ALERT = 1, /**< Alert type */
41 SMARTTHINGS_NOTIFICATION_TYPE_NOTICE, /**< Notice type */
42 SMARTTHINGS_NOTIFICATION_TYPE_EVENT, /**< Event type */
43 SMARTTHINGS_NOTIFICATION_TYPE_INFO, /**< Info type */
44 SMARTTHINGS_NOTIFICATION_TYPE_WARNING /**< Warning type */
45 } smartthings_notification_type_e;
49 * @brief The SmartThings push message handle.
52 typedef struct smartthings_push_msg_s* smartthings_push_msg_h;
55 * @brief Creates a SmartThings push message handle.
58 * @remarks The @a handle must be released using smartthings_push_msg_destroy().
60 * @param[out] handle The SmartThings push message handle to be newly created on success
62 * @return @c 0 on success,
63 * otherwise a negative error value
64 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
65 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
66 * @retval #SMARTTHINGS_RESOURCE_ERROR_OUT_OF_MEMORY Out of memory
67 * @retval #SMARTTHINGS_RESOURCE_ERROR_OPERATION_FAILED Operation failed
69 * @see smartthings_push_msg_destroy()
71 int smartthings_push_msg_create(smartthings_push_msg_h *handle);
74 * @brief Destroys a SmartThings push message handle and releases all its resources.
77 * @param[in] handle The SmartThings push message handle
79 * @return @c 0 on success,
80 * otherwise a negative error value
81 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
82 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
84 * @see smartthings_push_msg_create()
86 int smartthings_push_msg_destroy(smartthings_push_msg_h handle);
89 * @brief Sets a URI for the push message.
92 * @param[in] handle The SmartThings push message handle
93 * @param[in] uri The URI of push message to set
95 * @return @c 0 on success,
96 * otherwise a negative error value
97 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
98 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
101 int smartthings_push_msg_set_uri(smartthings_push_msg_h handle, const char *uri);
104 * @brief Sets a type for the push message.
107 * @param[in] handle The SmartThings push message handle
108 * @param[in] type The type of push message to set
110 * @return @c 0 on success,
111 * otherwise a negative error value
112 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
113 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
116 int smartthings_push_msg_set_type(smartthings_push_msg_h handle, smartthings_notification_type_e type);
119 * @brief Sets a code for the push message.
122 * @param[in] handle The SmartThings push message handle
123 * @param[in] code The code of push message to set
125 * @return @c 0 on success,
126 * otherwise a negative error value
127 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
128 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
131 int smartthings_push_msg_set_code(smartthings_push_msg_h handle, const char *code);
134 * @brief Sets a payload for the push message.
137 * @param[in] handle The SmartThings push message handle
138 * @param[in] payload The payload of push message to set
140 * @return @c 0 on success,
141 * otherwise a negative error value
142 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
143 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
146 int smartthings_push_msg_set_payload(smartthings_push_msg_h handle, smartthings_payload_h payload);
149 * @brief Sends the push message.
151 * @privilege %http://com.samsung.tizen.smartthings-thing/appdefined/smartthings-thing.resource \n
152 * %http://tizen.org/privilege/appmanager.launch \n
153 * %http://tizen.org/privilege/datasharing \n
154 * %http://tizen.org/privilege/internet
156 * @param[in] st_h The SmartThings resource handle
157 * @param[in] push_msg_h The SmartThings push message handle
159 * @return @c 0 on success,
160 * otherwise a negative error value
161 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
162 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
163 * @retval #SMARTTHINGS_RESOURCE_ERROR_PERMISSION_DENIED Permission denied
164 * @retval #SMARTTHINGS_RESOURCE_ERROR_OPERATION_FAILED Operation failed
166 int smartthings_send_push_msg(smartthings_resource_h st_h, smartthings_push_msg_h push_msg_h);
170 * @brief The SmartThings notification message handle.
173 typedef struct smartthings_notification_msg_s* smartthings_notification_msg_h;
177 * @brief Creates a SmartThings notification message handle.
180 * @remarks The @a handle must be released using smartthings_notification_msg_destroy().
182 * @param[out] handle The SmartThings notification message handle to be newly created on success
184 * @return @c 0 on success,
185 * otherwise a negative error value
186 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
187 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
188 * @retval #SMARTTHINGS_RESOURCE_ERROR_OUT_OF_MEMORY Out of memory
189 * @retval #SMARTTHINGS_RESOURCE_ERROR_OPERATION_FAILED Operation failed
191 * @see smartthings_notification_msg_destroy()
193 int smartthings_notification_msg_create(smartthings_notification_msg_h *handle);
196 * @brief Destroys a SmartThings notification message handle and releases all its resources.
199 * @param[in] handle The SmartThings notification message handle
201 * @return @c 0 on success,
202 * otherwise a negative error value
203 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
204 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
206 * @see smartthings_notification_msg_create()
208 int smartthings_notification_msg_destroy(smartthings_notification_msg_h handle);
211 * @brief Sets a URI for the notification message.
214 * @param[in] handle The SmartThings notification message handle
215 * @param[in] uri The URI of notification message to set
217 * @return @c 0 on success,
218 * otherwise a negative error value
219 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
220 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
223 int smartthings_notification_msg_set_uri(smartthings_notification_msg_h handle, const char *uri);
226 * @brief Sets a type for the notification message.
229 * @param[in] handle The SmartThings notification message handle
230 * @param[in] type The type of notification message to set
232 * @return @c 0 on success,
233 * otherwise a negative error value
234 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
235 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
238 int smartthings_notification_msg_set_type(smartthings_notification_msg_h handle, smartthings_notification_type_e type);
241 * @brief Sets a payload for the notification message.
244 * @param[in] handle The SmartThings notification message handle
245 * @param[in] name The name of payload
246 * @param[in] payload The payload of notification message to set
248 * @return @c 0 on success,
249 * otherwise a negative error value
250 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
251 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
254 int smartthings_notification_msg_set_payload(smartthings_notification_msg_h handle, const char *name, smartthings_payload_h payload);
257 * @brief Sends the notification message.
259 * @privilege %http://com.samsung.tizen.smartthings-thing/appdefined/smartthings-thing.resource \n
260 * %http://tizen.org/privilege/appmanager.launch \n
261 * %http://tizen.org/privilege/datasharing \n
262 * %http://tizen.org/privilege/internet
264 * @param[in] st_h The SmartThings resource handle
265 * @param[in] notification_msg_h The SmartThings notification message handle
267 * @return @c 0 on success,
268 * otherwise a negative error value
269 * @retval #SMARTTHINGS_RESOURCE_ERROR_NONE Successful
270 * @retval #SMARTTHINGS_RESOURCE_ERROR_INVALID_PARAMETER Invalid parameter
271 * @retval #SMARTTHINGS_RESOURCE_ERROR_PERMISSION_DENIED Permission denied
272 * @retval #SMARTTHINGS_RESOURCE_ERROR_OPERATION_FAILED Operation failed
274 int smartthings_send_notification_msg(smartthings_resource_h st_h, smartthings_notification_msg_h notification_msg_h);
285 #endif /* __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_NOTIFICATION_H__ */