2 # ==================================================================================
3 # Copyright (c) 2020 HCL Technologies Limited.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ==================================================================================
18 #include"SubscriptionInstance.h"
21 void from_json(const nlohmann::json& j, SubscriptionInstance& ref) {
23 std::cout << __PRETTY_FUNCTION__ << std::endl;
26 j.at("XappEventInstanceId").get_to(ref.XappEventInstanceId);
27 j.at("E2EventInstanceId").get_to(ref.E2EventInstanceId);
28 j.at("ErrorCause").get_to(ref.ErrorCause);
29 j.at("ErrorSource").get_to(ref.ErrorSource);
30 j.at("TimeoutType").get_to(ref.TimeoutType);
32 void from_json(const nlohmann::json& j, std::vector<SubscriptionInstance>& ref) {
34 std::cout << __PRETTY_FUNCTION__ << std::endl;
35 for (auto& element : j) {
36 SubscriptionInstance tmp;
37 tmp.validate_json(element);
38 for (auto& val : element.items())
42 if (val.key() == "XappEventInstanceId") {
44 tmp.XappEventInstanceId = val.value();
47 else if (val.key() == "E2EventInstanceId") {
48 tmp.E2EventInstanceId = val.value();
50 else if (val.key() == "ErrorCause") {
51 tmp.ErrorCause = val.value();
53 else if (val.key() == "ErrorSource") {
54 tmp.ErrorSource = val.value();
56 else if (val.key() == "TimeoutType") {
57 tmp.TimeoutType = val.value();
70 void to_json(nlohmann::json& j, const SubscriptionInstance& ref) {
73 {"XappEventInstanceId", ref.XappEventInstanceId},
74 {"E2EventInstanceId", ref.E2EventInstanceId},
75 {"ErrorCause", ref.ErrorCause},
76 {"ErrorSource", ref.ErrorSource},
77 {"TimeoutType", ref.TimeoutType}
80 void to_json(nlohmann::json& j, const std::vector<SubscriptionInstance>& ref) {
83 for (int i = 0; i < ref.size(); i++)
86 nlohmann::json tmp = nlohmann::json{
87 {"XappEventInstanceId", ref[i].XappEventInstanceId},
88 {"E2EventInstanceId", ref[i].E2EventInstanceId},
89 {"ErrorCause", ref[i].ErrorCause},
90 {"ErrorSource", ref[i].ErrorSource},
91 {"TimeoutType", ref[i].TimeoutType}