blob: 3d8e8d4fabca74a197154dd626101c0746903f40 [file] [log] [blame]
Nhat Anha0bada62022-11-07 23:06:23 +07001#ifndef XAPP_MODEL_SubscriptionResponse_H
2#define XAPP_MODEL_SubscriptionResponse_H
3#include "ModelBase.h"
4#include "SubscriptionInstance.h"
5
6namespace xapp {
7namespace model {
8
9struct SubscriptionResponse: ModelBase {
10 int SubscriptionID;
11 SubscriptionInstances m_SubscriptionInstances;
12
13 json validator_schema = R"(
14 {
15 "$schema": "http://json-schema.org/draft-07/schema#",
16 "title": "SubscriptionResponse",
17 "properties": {
18 "SubscriptionId": {
19 "description": "Indentification of Subscription",
20 "type": "integer"
21 },
22 "SubscriptionInstances": {
23 "description": "List of Subscription Instance",
24 "type": "array"
25 }
26 },
27 "required": [
28 "SubscriptionId",
29 "SubscriptionInstances"
30 ],
31 "type": "object"
32 })"_json;
33
34 virtual json get_validator_schema() const { return validator_schema; }
35};
36
37void from_json(const json& j, SubscriptionResponse& ref) {
38
39 std::cout << __PRETTY_FUNCTION__ << std::endl;
40 ref.validate_json(j);
41
42 j.at("SubscriptionId").get_to(ref.SubscriptionID);
43 j.at("SubscriptionInstances").get_to(ref.m_SubscriptionInstances);
44}
45
46void to_json(json& j, const SubscriptionResponse& ref) {
47
48 j = json {
49 {"SubscriptionId",ref.SubscriptionID},
50 {"SubscriptionInstances", ref.m_SubscriptionInstances}
51 };
52}
53
54} /*model*/
55} /*xapp*/
56#endif /*XAPP_MODEL_SubscriptionResponse_H*/