AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SystemNamespace.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_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_NAMESPACES_SYSTEMNAMESPACE_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_NAMESPACES_SYSTEMNAMESPACE_H_
18 
19 #include <string>
20 
21 #include <rapidjson/document.h>
22 
24 
25 namespace alexaClientSDK {
26 namespace sampleApplications {
27 namespace ipcServerSampleApp {
28 namespace ipc {
29 namespace IPCNamespaces {
30 
32 static const char IPC_MSG_NAMESPACE_SYSTEM[] = "System";
33 
35 static const int IPC_MSG_VERSION_SYSTEM(1);
36 
38 static const char IPC_MSG_NAME_COMPLETE_AUTH[] = "completeAuthorization";
39 
41 static const char IPC_MSG_NAME_SET_ALEXA_STATE[] = "setAlexaState";
42 
44 static const char IPC_MSG_NAME_SET_AUTH_STATE[] = "setAuthorizationState";
45 
47 static const char IPC_MSG_NAME_SET_LOCALES[] = "setLocales";
48 
50 static const char IPC_MSG_LOCALES_TAG[] = "locales";
51 
53 static const char IPC_MSG_AUTH_URL_TAG[] = "url";
54 
56 static const char IPC_MSG_AUTH_CODE_TAG[] = "code";
57 
59 static const char IPC_MSG_CLIENT_ID_TAG[] = "clientId";
60 
66 public:
74  CompleteAuthorizationMessage(const std::string& url, const std::string& code, const std::string& authClientId) :
75  Message(IPC_MSG_NAMESPACE_SYSTEM, IPC_MSG_VERSION_SYSTEM, IPC_MSG_NAME_COMPLETE_AUTH) {
76  addMemberInPayload(IPC_MSG_AUTH_URL_TAG, url);
77  addMemberInPayload(IPC_MSG_AUTH_CODE_TAG, code);
78  addMemberInPayload(IPC_MSG_CLIENT_ID_TAG, authClientId);
79  addPayload();
80  }
81 };
82 
88 public:
94  SetAuthorizationStateMessage(const std::string& authorizationState) :
95  Message(IPC_MSG_NAMESPACE_SYSTEM, IPC_MSG_VERSION_SYSTEM, IPC_MSG_NAME_SET_AUTH_STATE) {
96  setStateInPayload(authorizationState);
97  addPayload();
98  }
99 };
100 
105 public:
111  explicit SetAlexaStateMessage(const std::string& alexaState) :
112  Message(IPC_MSG_NAMESPACE_SYSTEM, IPC_MSG_VERSION_SYSTEM, IPC_MSG_NAME_SET_ALEXA_STATE) {
113  setStateInPayload(alexaState);
114  addPayload();
115  }
116 };
117 
122 public:
128  explicit SetLocalesMessage(const std::string& localeStr) :
129  Message(IPC_MSG_NAMESPACE_SYSTEM, IPC_MSG_VERSION_SYSTEM, IPC_MSG_NAME_SET_LOCALES) {
130  rapidjson::Value payload(rapidjson::kObjectType);
131  rapidjson::Document messageDocument(&alloc());
132  payload.AddMember(
133  rapidjson::Value(IPC_MSG_LOCALES_TAG, alloc()).Move(), messageDocument.Parse(localeStr), alloc());
134  setPayload(std::move(payload));
135  };
136 };
137 
138 } // namespace IPCNamespaces
139 } // namespace ipc
140 } // namespace ipcServerSampleApp
141 } // namespace sampleApplications
142 } // namespace alexaClientSDK
143 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_IPC_NAMESPACES_SYSTEMNAMESPACE_H_
static const char IPC_MSG_NAME_SET_AUTH_STATE[]
The message name for setAuthorizationState.
Definition: SystemNamespace.h:44
Message & addMemberInPayload(const std::string &name, const std::string &value)
Definition: Message.h:101
static const char IPC_MSG_LOCALES_TAG[]
The locales json key in the message.
Definition: SystemNamespace.h:50
static const char IPC_MSG_AUTH_CODE_TAG[]
The auth code json key in the message.
Definition: SystemNamespace.h:56
::std::string string
Definition: gtest-port.h:1097
CompleteAuthorizationMessage(const std::string &url, const std::string &code, const std::string &authClientId)
Definition: SystemNamespace.h:74
static const char IPC_MSG_CLIENT_ID_TAG[]
The clientId json key in the message.
Definition: SystemNamespace.h:59
Message(const std::string &nameSpace, const int version, const std::string &name)
Definition: Message.h:64
auto alloc() -> decltype(mDocument.GetAllocator())
Definition: Message.h:227
static const char IPC_MSG_NAMESPACE_SYSTEM[]
The namespace namespace for System.
Definition: SystemNamespace.h:32
Message & setPayload(rapidjson::Value &&payload)
Definition: Message.h:218
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
static const char IPC_MSG_AUTH_URL_TAG[]
The auth url json key in the message.
Definition: SystemNamespace.h:53
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
SetAuthorizationStateMessage(const std::string &authorizationState)
Definition: SystemNamespace.h:94
SetAlexaStateMessage(const std::string &alexaState)
Definition: SystemNamespace.h:111
SetLocalesMessage(const std::string &localeStr)
Definition: SystemNamespace.h:128
static const char IPC_MSG_NAME_SET_ALEXA_STATE[]
The message name for setAlexaState.
Definition: SystemNamespace.h:41
Message & setStateInPayload(const std::string &state)
Definition: Message.h:148
static const int IPC_MSG_VERSION_SYSTEM(1)
The namespace version for System.
static const char IPC_MSG_NAME_COMPLETE_AUTH[]
The message name for completeAuthorization.
Definition: SystemNamespace.h:38
const T & move(const T &t)
Definition: gtest-port.h:1317
static const char IPC_MSG_NAME_SET_LOCALES[]
The message name for setLocales.
Definition: SystemNamespace.h:47

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