AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AVSDirective.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_AVSDIRECTIVE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_AVSDIRECTIVE_H_
18 
19 #include <iostream>
20 #include <memory>
21 #include <string>
22 #include <utility>
23 
25 #include "AVSMessage.h"
26 
27 namespace alexaClientSDK {
28 namespace avsCommon {
29 namespace avs {
30 
34 class AVSDirective : public AVSMessage {
35 public:
39  enum class ParseStatus {
41  SUCCESS,
42 
45 
48 
51 
54 
57 
60 
63  };
64 
74  static std::pair<std::unique_ptr<AVSDirective>, ParseStatus> create(
75  const std::string& unparsedDirective,
76  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
77  const std::string& attachmentContextId);
78 
90  static std::unique_ptr<AVSDirective> create(
91  const std::string& unparsedDirective,
92  std::shared_ptr<AVSMessageHeader> avsMessageHeader,
93  const std::string& payload,
94  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
95  const std::string& attachmentContextId,
97 
105  std::unique_ptr<avsCommon::avs::attachment::AttachmentReader> getAttachmentReader(
106  const std::string& contentId,
107  utils::sds::ReaderPolicy readerPolicy) const;
108 
113 
118 
119 private:
130  AVSDirective(
131  const std::string& unparsedDirective,
132  std::shared_ptr<AVSMessageHeader> avsMessageHeader,
133  const std::string& payload,
134  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
135  const std::string& attachmentContextId,
136  const utils::Optional<AVSMessageEndpoint>& endpoint);
137 
139  const std::string m_unparsedDirective;
141  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> m_attachmentManager;
143  std::string m_attachmentContextId;
144 };
145 
153  switch (status) {
155  return "SUCCESS";
157  return "ERROR_INVALID_JSON";
159  return "ERROR_MISSING_DIRECTIVE_KEY";
161  return "ERROR_MISSING_HEADER_KEY";
163  return "ERROR_MISSING_NAMESPACE_KEY";
165  return "ERROR_MISSING_NAME_KEY";
167  return "ERROR_MISSING_MESSAGE_ID_KEY";
169  return "ERROR_MISSING_PAYLOAD_KEY";
170  }
171  return "UNKNOWN_STATUS";
172 }
173 
181 inline std::ostream& operator<<(std::ostream& stream, const AVSDirective::ParseStatus& status) {
182  return stream << avsDirectiveParseStatusToString(status);
183 }
184 
185 } // namespace avs
186 } // namespace avsCommon
187 } // namespace alexaClientSDK
188 
189 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_AVSDIRECTIVE_H_
::std::string string
Definition: gtest-port.h:1097
The parse failed due to the message id key being missing.
static std::pair< std::unique_ptr< AVSDirective >, ParseStatus > create(const std::string &unparsedDirective, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, const std::string &attachmentContextId)
std::unique_ptr< avsCommon::avs::attachment::AttachmentReader > getAttachmentReader(const std::string &contentId, utils::sds::ReaderPolicy readerPolicy) const
ParseStatus
Definition: AVSDirective.h:39
std::string avsDirectiveParseStatusToString(AVSDirective::ParseStatus status)
Definition: AVSDirective.h:152
std::ostream & operator<<(std::ostream &stream, AlexaResponseType responseType)
Definition: AlexaResponseType.h:93
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
ReaderPolicy
Specifies the policy to use for reading from the stream.
Definition: ReaderPolicy.h:25
The parse failed due to the message payload key being missing.

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0