mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-08-26 12:35:38 -04:00
b7bdba06ba
Signed-off-by: sunfei <sunfei.sun@huawei.com> Change-Id: I8d97d06f7ec17e888c86c651070e8d20ffa22b69
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_RESPONSEDATA_H
|
|
#define FOUNDATION_ACE_ADAPTER_PREVIEW_RESPONSEDATA_H
|
|
|
|
#include <unordered_map>
|
|
#include <string>
|
|
|
|
#include "base/json/json_util.h"
|
|
|
|
namespace OHOS::Ace {
|
|
|
|
namespace {
|
|
// error code
|
|
constexpr int32_t ACTION_SUCCESS = 0;
|
|
constexpr int32_t ACTION_FAIL = 1;
|
|
constexpr int32_t COMMON_ERROR_CODE = 200;
|
|
// httpcode
|
|
constexpr int32_t HTTP_OK = 200;
|
|
} // namespace
|
|
|
|
class ResponseData {
|
|
public:
|
|
int32_t GetCode() const
|
|
{
|
|
return code_;
|
|
}
|
|
|
|
void SetCode(const int32_t code)
|
|
{
|
|
code_ = code;
|
|
}
|
|
|
|
std::string GetData() const
|
|
{
|
|
return data_;
|
|
}
|
|
|
|
void SetData(const std::string data)
|
|
{
|
|
data_ = data;
|
|
}
|
|
|
|
std::unordered_map<std::string, std::string> GetHeaders() const
|
|
{
|
|
return headers_;
|
|
}
|
|
|
|
void SetHeaders(std::string headersStr);
|
|
std::unique_ptr<JsonValue> GetResultString() const;
|
|
int GetActionCode() const;
|
|
private:
|
|
int32_t code_ = COMMON_ERROR_CODE;
|
|
std::string data_;
|
|
std::unordered_map<std::string, std::string> headers_;
|
|
|
|
std::unique_ptr<JsonValue> GetStringValue() const;
|
|
};
|
|
} // namespace OHOS::Ace
|
|
|
|
#endif // #ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_RESPONSEDATA_H
|