1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/chime/model/ChannelMessageSummary.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8 
9 #include <utility>
10 
11 using namespace Aws::Utils::Json;
12 using namespace Aws::Utils;
13 
14 namespace Aws
15 {
16 namespace Chime
17 {
18 namespace Model
19 {
20 
ChannelMessageSummary()21 ChannelMessageSummary::ChannelMessageSummary() :
22     m_messageIdHasBeenSet(false),
23     m_contentHasBeenSet(false),
24     m_metadataHasBeenSet(false),
25     m_type(ChannelMessageType::NOT_SET),
26     m_typeHasBeenSet(false),
27     m_createdTimestampHasBeenSet(false),
28     m_lastUpdatedTimestampHasBeenSet(false),
29     m_lastEditedTimestampHasBeenSet(false),
30     m_senderHasBeenSet(false),
31     m_redacted(false),
32     m_redactedHasBeenSet(false)
33 {
34 }
35 
ChannelMessageSummary(JsonView jsonValue)36 ChannelMessageSummary::ChannelMessageSummary(JsonView jsonValue) :
37     m_messageIdHasBeenSet(false),
38     m_contentHasBeenSet(false),
39     m_metadataHasBeenSet(false),
40     m_type(ChannelMessageType::NOT_SET),
41     m_typeHasBeenSet(false),
42     m_createdTimestampHasBeenSet(false),
43     m_lastUpdatedTimestampHasBeenSet(false),
44     m_lastEditedTimestampHasBeenSet(false),
45     m_senderHasBeenSet(false),
46     m_redacted(false),
47     m_redactedHasBeenSet(false)
48 {
49   *this = jsonValue;
50 }
51 
operator =(JsonView jsonValue)52 ChannelMessageSummary& ChannelMessageSummary::operator =(JsonView jsonValue)
53 {
54   if(jsonValue.ValueExists("MessageId"))
55   {
56     m_messageId = jsonValue.GetString("MessageId");
57 
58     m_messageIdHasBeenSet = true;
59   }
60 
61   if(jsonValue.ValueExists("Content"))
62   {
63     m_content = jsonValue.GetString("Content");
64 
65     m_contentHasBeenSet = true;
66   }
67 
68   if(jsonValue.ValueExists("Metadata"))
69   {
70     m_metadata = jsonValue.GetString("Metadata");
71 
72     m_metadataHasBeenSet = true;
73   }
74 
75   if(jsonValue.ValueExists("Type"))
76   {
77     m_type = ChannelMessageTypeMapper::GetChannelMessageTypeForName(jsonValue.GetString("Type"));
78 
79     m_typeHasBeenSet = true;
80   }
81 
82   if(jsonValue.ValueExists("CreatedTimestamp"))
83   {
84     m_createdTimestamp = jsonValue.GetDouble("CreatedTimestamp");
85 
86     m_createdTimestampHasBeenSet = true;
87   }
88 
89   if(jsonValue.ValueExists("LastUpdatedTimestamp"))
90   {
91     m_lastUpdatedTimestamp = jsonValue.GetDouble("LastUpdatedTimestamp");
92 
93     m_lastUpdatedTimestampHasBeenSet = true;
94   }
95 
96   if(jsonValue.ValueExists("LastEditedTimestamp"))
97   {
98     m_lastEditedTimestamp = jsonValue.GetDouble("LastEditedTimestamp");
99 
100     m_lastEditedTimestampHasBeenSet = true;
101   }
102 
103   if(jsonValue.ValueExists("Sender"))
104   {
105     m_sender = jsonValue.GetObject("Sender");
106 
107     m_senderHasBeenSet = true;
108   }
109 
110   if(jsonValue.ValueExists("Redacted"))
111   {
112     m_redacted = jsonValue.GetBool("Redacted");
113 
114     m_redactedHasBeenSet = true;
115   }
116 
117   return *this;
118 }
119 
Jsonize() const120 JsonValue ChannelMessageSummary::Jsonize() const
121 {
122   JsonValue payload;
123 
124   if(m_messageIdHasBeenSet)
125   {
126    payload.WithString("MessageId", m_messageId);
127 
128   }
129 
130   if(m_contentHasBeenSet)
131   {
132    payload.WithString("Content", m_content);
133 
134   }
135 
136   if(m_metadataHasBeenSet)
137   {
138    payload.WithString("Metadata", m_metadata);
139 
140   }
141 
142   if(m_typeHasBeenSet)
143   {
144    payload.WithString("Type", ChannelMessageTypeMapper::GetNameForChannelMessageType(m_type));
145   }
146 
147   if(m_createdTimestampHasBeenSet)
148   {
149    payload.WithDouble("CreatedTimestamp", m_createdTimestamp.SecondsWithMSPrecision());
150   }
151 
152   if(m_lastUpdatedTimestampHasBeenSet)
153   {
154    payload.WithDouble("LastUpdatedTimestamp", m_lastUpdatedTimestamp.SecondsWithMSPrecision());
155   }
156 
157   if(m_lastEditedTimestampHasBeenSet)
158   {
159    payload.WithDouble("LastEditedTimestamp", m_lastEditedTimestamp.SecondsWithMSPrecision());
160   }
161 
162   if(m_senderHasBeenSet)
163   {
164    payload.WithObject("Sender", m_sender.Jsonize());
165 
166   }
167 
168   if(m_redactedHasBeenSet)
169   {
170    payload.WithBool("Redacted", m_redacted);
171 
172   }
173 
174   return payload;
175 }
176 
177 } // namespace Model
178 } // namespace Chime
179 } // namespace Aws
180