1: <?php
2:
3: namespace Saklient\Cloud\Resources;
4:
5: require_once __DIR__ . "/../../../Saklient/Errors/SaklientException.php";
6: use \Saklient\Errors\SaklientException;
7: require_once __DIR__ . "/../../../Saklient/Cloud/Client.php";
8: use \Saklient\Cloud\Client;
9: require_once __DIR__ . "/../../../Saklient/Cloud/Resources/Resource.php";
10: use \Saklient\Cloud\Resources\Resource;
11: require_once __DIR__ . "/../../../Saklient/Util.php";
12: use \Saklient\Util;
13:
14: 15: 16: 17: 18: 19:
20: class LicenseInfo extends Resource {
21:
22: 23: 24: 25: 26: 27: 28:
29: protected $m_id;
30:
31: 32: 33: 34: 35: 36: 37:
38: protected $m_name;
39:
40: 41: 42: 43: 44: 45:
46: protected function _apiPath()
47: {
48: return "/product/license";
49: }
50:
51: 52: 53: 54: 55: 56:
57: protected function _rootKey()
58: {
59: return "LicenseInfo";
60: }
61:
62: 63: 64: 65: 66: 67:
68: protected function _rootKeyM()
69: {
70: return "LicenseInfo";
71: }
72:
73: 74: 75: 76: 77: 78:
79: public function _className()
80: {
81: return "License";
82: }
83:
84: 85: 86: 87: 88: 89:
90: public function _id()
91: {
92: return $this->get_id();
93: }
94:
95: 96: 97: 98: 99: 100: 101:
102: public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
103: {
104: parent::__construct($client);
105: Util::validateArgCount(func_num_args(), 2);
106: Util::validateType($client, "\\Saklient\\Cloud\\Client");
107: Util::validateType($wrapped, "boolean");
108: $this->apiDeserialize($obj, $wrapped);
109: }
110:
111: 112: 113: 114: 115:
116: private $n_id = false;
117:
118: 119: 120: 121: 122: 123: 124:
125: private function get_id()
126: {
127: return $this->m_id;
128: }
129:
130:
131:
132: 133: 134: 135: 136:
137: private $n_name = false;
138:
139: 140: 141: 142: 143: 144: 145:
146: private function get_name()
147: {
148: return $this->m_name;
149: }
150:
151: 152: 153: 154: 155: 156: 157: 158:
159: private function set_name($v)
160: {
161: Util::validateArgCount(func_num_args(), 1);
162: Util::validateType($v, "string");
163: $this->m_name = $v;
164: $this->n_name = true;
165: return $this->m_name;
166: }
167:
168:
169:
170: 171: 172: 173: 174: 175: 176:
177: protected function apiDeserializeImpl($r)
178: {
179: Util::validateArgCount(func_num_args(), 1);
180: $this->isNew = $r == null;
181: if ($this->isNew) {
182: $r = (object)[];
183: }
184: $this->isIncomplete = false;
185: if (Util::existsPath($r, "ID")) {
186: $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
187: }
188: else {
189: $this->m_id = null;
190: $this->isIncomplete = true;
191: }
192: $this->n_id = false;
193: if (Util::existsPath($r, "Name")) {
194: $this->m_name = Util::getByPath($r, "Name") == null ? null : "" . Util::getByPath($r, "Name");
195: }
196: else {
197: $this->m_name = null;
198: $this->isIncomplete = true;
199: }
200: $this->n_name = false;
201: }
202:
203: 204: 205: 206: 207: 208:
209: protected function apiSerializeImpl($withClean=false)
210: {
211: Util::validateType($withClean, "boolean");
212: $missing = new \ArrayObject([]);
213: $ret = (object)[];
214: if ($withClean || $this->n_id) {
215: Util::setByPath($ret, "ID", $this->m_id);
216: }
217: if ($withClean || $this->n_name) {
218: Util::setByPath($ret, "Name", $this->m_name);
219: }
220: else {
221: if ($this->isNew) {
222: $missing->append("name");
223: }
224: }
225: if ($missing->count() > 0) {
226: throw new SaklientException("required_field", "Required fields must be set before the LicenseInfo creation: " . implode(", ", (array)($missing)));
227: }
228: return $ret;
229: }
230:
231: 232: 233:
234: public function __get($key) {
235: switch ($key) {
236: case "id": return $this->get_id();
237: case "name": return $this->get_name();
238: default: return parent::__get($key);
239: }
240: }
241:
242: 243: 244:
245: public function __set($key, $v) {
246: switch ($key) {
247: case "name": return $this->set_name($v);
248: default: return parent::__set($key, $v);
249: }
250: }
251:
252: }
253:
254: