1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/lexv2-runtime/model/PutSessionRequest.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8 #include <aws/core/utils/memory/stl/AWSStringStream.h>
9 
10 #include <utility>
11 
12 using namespace Aws::LexRuntimeV2::Model;
13 using namespace Aws::Utils::Json;
14 using namespace Aws::Utils;
15 
PutSessionRequest()16 PutSessionRequest::PutSessionRequest() :
17     m_botIdHasBeenSet(false),
18     m_botAliasIdHasBeenSet(false),
19     m_localeIdHasBeenSet(false),
20     m_sessionIdHasBeenSet(false),
21     m_messagesHasBeenSet(false),
22     m_sessionStateHasBeenSet(false),
23     m_requestAttributesHasBeenSet(false),
24     m_responseContentTypeHasBeenSet(false)
25 {
26 }
27 
SerializePayload() const28 Aws::String PutSessionRequest::SerializePayload() const
29 {
30   JsonValue payload;
31 
32   if(m_messagesHasBeenSet)
33   {
34    Array<JsonValue> messagesJsonList(m_messages.size());
35    for(unsigned messagesIndex = 0; messagesIndex < messagesJsonList.GetLength(); ++messagesIndex)
36    {
37      messagesJsonList[messagesIndex].AsObject(m_messages[messagesIndex].Jsonize());
38    }
39    payload.WithArray("messages", std::move(messagesJsonList));
40 
41   }
42 
43   if(m_sessionStateHasBeenSet)
44   {
45    payload.WithObject("sessionState", m_sessionState.Jsonize());
46 
47   }
48 
49   if(m_requestAttributesHasBeenSet)
50   {
51    JsonValue requestAttributesJsonMap;
52    for(auto& requestAttributesItem : m_requestAttributes)
53    {
54      requestAttributesJsonMap.WithString(requestAttributesItem.first, requestAttributesItem.second);
55    }
56    payload.WithObject("requestAttributes", std::move(requestAttributesJsonMap));
57 
58   }
59 
60   return payload.View().WriteReadable();
61 }
62 
GetRequestSpecificHeaders() const63 Aws::Http::HeaderValueCollection PutSessionRequest::GetRequestSpecificHeaders() const
64 {
65   Aws::Http::HeaderValueCollection headers;
66   Aws::StringStream ss;
67   if(m_responseContentTypeHasBeenSet)
68   {
69     ss << m_responseContentType;
70     headers.emplace("responsecontenttype",  ss.str());
71     ss.str("");
72   }
73 
74   return headers;
75 
76 }
77 
78 
79 
80 
81