1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUTTON_OPTION_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUTTON_OPTION_H
18 
19 #include "notification_json_convert.h"
20 #include "parcel.h"
21 
22 namespace OHOS {
23 namespace Notification {
24 class NotificationButtonOption : public Parcelable, public NotificationJsonConvertionBase {
25 public:
26     NotificationButtonOption() = default;
27 
28     ~NotificationButtonOption() = default;
29 
30     /**
31      * @brief Sets devices that support display.
32      *
33      * @param devices Indicates the devices that support display.
34      */
35     void SetButtonName(const std::string &buttonName);
36 
37     /**
38      * @brief Obtains the devices that support display.
39      *
40      * @return Returns the devices that support display.
41      */
42     std::string GetButtonName() const;
43 
44     /**
45      * @brief Returns a string representation of the object.
46      *
47      * @return Returns a string representation of the object.
48      */
49     std::string Dump();
50 
51     /**
52      * @brief Converts a NotificationButtonOptions object into a Json.
53      *
54      * @param jsonObject Indicates the Json object.
55      * @return Returns true if succeed; returns false otherwise.
56      */
57     bool ToJson(nlohmann::json &jsonObject) const override;
58 
59     /**
60      * @brief Creates a NotificationButtonOptions object from a Json.
61      *
62      * @param jsonObject Indicates the Json object.
63      * @return Returns the NotificationButtonOptions.
64      */
65     static NotificationButtonOption *FromJson(const nlohmann::json &jsonObject);
66 
67     /**
68      * @brief Marshal a object into a Parcel.
69      *
70      * @param parcel Indicates the object into the parcel.
71      * @return Returns true if succeed; returns false otherwise.
72      */
73     virtual bool Marshalling(Parcel &parcel) const override;
74 
75     /**
76      * @brief Unmarshal object from a Parcel.
77      *
78      * @param parcel Indicates the parcel object.
79      * @return Returns the NotificationButtonOptions object.
80      */
81     static NotificationButtonOption *Unmarshalling(Parcel &parcel);
82 
83 private:
84     /**
85      * @brief Read a NotificationButtonOptions object from a Parcel.
86      *
87      * @param parcel Indicates the parcel object.
88      * @return Returns true if succeed; returns false otherwise.
89      */
90     bool ReadFromParcel(Parcel &parcel);
91 
92 private:
93     std::string buttonName_ {};
94 };
95 }  // namespace Notification
96 }  // namespace OHOS
97 
98 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUTTON_OPTION_H