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/Cloud/Enums/EScope.php";
12: use \Saklient\Cloud\Enums\EScope;
13: require_once __DIR__ . "/../../../Saklient/Util.php";
14: use \Saklient\Util;
15:
16: 17: 18: 19: 20: 21: 22: 23:
24: class Icon extends Resource {
25:
26: 27: 28: 29: 30: 31: 32:
33: protected $m_id;
34:
35: 36: 37: 38: 39: 40: 41:
42: protected $m_scope;
43:
44: 45: 46: 47: 48: 49: 50:
51: protected $m_name;
52:
53: 54: 55: 56: 57: 58: 59:
60: protected $m_url;
61:
62: 63: 64: 65: 66: 67:
68: protected function _apiPath()
69: {
70: return "/icon";
71: }
72:
73: 74: 75: 76: 77: 78:
79: protected function _rootKey()
80: {
81: return "Icon";
82: }
83:
84: 85: 86: 87: 88: 89:
90: protected function _rootKeyM()
91: {
92: return "Icons";
93: }
94:
95: 96: 97: 98: 99: 100:
101: public function _className()
102: {
103: return "Icon";
104: }
105:
106: 107: 108: 109: 110: 111:
112: public function _id()
113: {
114: return $this->get_id();
115: }
116:
117: 118: 119: 120: 121: 122:
123: public function save()
124: {
125: return $this->_save();
126: }
127:
128: 129: 130: 131: 132: 133:
134: public function reload()
135: {
136: return $this->_reload();
137: }
138:
139: 140: 141: 142: 143: 144: 145:
146: public function __construct(\Saklient\Cloud\Client $client, $obj, $wrapped=false)
147: {
148: parent::__construct($client);
149: Util::validateArgCount(func_num_args(), 2);
150: Util::validateType($client, "\\Saklient\\Cloud\\Client");
151: Util::validateType($wrapped, "boolean");
152: $this->apiDeserialize($obj, $wrapped);
153: }
154:
155: 156: 157: 158: 159:
160: private $n_id = false;
161:
162: 163: 164: 165: 166: 167: 168:
169: private function get_id()
170: {
171: return $this->m_id;
172: }
173:
174:
175:
176: 177: 178: 179: 180:
181: private $n_scope = false;
182:
183: 184: 185: 186: 187: 188: 189:
190: private function get_scope()
191: {
192: return $this->m_scope;
193: }
194:
195:
196:
197: 198: 199: 200: 201:
202: private $n_name = false;
203:
204: 205: 206: 207: 208: 209: 210:
211: private function get_name()
212: {
213: return $this->m_name;
214: }
215:
216: 217: 218: 219: 220: 221: 222: 223:
224: private function set_name($v)
225: {
226: Util::validateArgCount(func_num_args(), 1);
227: Util::validateType($v, "string");
228: $this->m_name = $v;
229: $this->n_name = true;
230: return $this->m_name;
231: }
232:
233:
234:
235: 236: 237: 238: 239:
240: private $n_url = false;
241:
242: 243: 244: 245: 246: 247: 248:
249: private function get_url()
250: {
251: return $this->m_url;
252: }
253:
254:
255:
256: 257: 258: 259: 260: 261: 262:
263: protected function apiDeserializeImpl($r)
264: {
265: Util::validateArgCount(func_num_args(), 1);
266: $this->isNew = $r == null;
267: if ($this->isNew) {
268: $r = (object)[];
269: }
270: $this->isIncomplete = false;
271: if (Util::existsPath($r, "ID")) {
272: $this->m_id = Util::getByPath($r, "ID") == null ? null : "" . Util::getByPath($r, "ID");
273: }
274: else {
275: $this->m_id = null;
276: $this->isIncomplete = true;
277: }
278: $this->n_id = false;
279: if (Util::existsPath($r, "Scope")) {
280: $this->m_scope = Util::getByPath($r, "Scope") == null ? null : "" . Util::getByPath($r, "Scope");
281: }
282: else {
283: $this->m_scope = null;
284: $this->isIncomplete = true;
285: }
286: $this->n_scope = false;
287: if (Util::existsPath($r, "Name")) {
288: $this->m_name = Util::getByPath($r, "Name") == null ? null : "" . Util::getByPath($r, "Name");
289: }
290: else {
291: $this->m_name = null;
292: $this->isIncomplete = true;
293: }
294: $this->n_name = false;
295: if (Util::existsPath($r, "URL")) {
296: $this->m_url = Util::getByPath($r, "URL") == null ? null : "" . Util::getByPath($r, "URL");
297: }
298: else {
299: $this->m_url = null;
300: $this->isIncomplete = true;
301: }
302: $this->n_url = false;
303: }
304:
305: 306: 307: 308: 309: 310:
311: protected function apiSerializeImpl($withClean=false)
312: {
313: Util::validateType($withClean, "boolean");
314: $missing = new \ArrayObject([]);
315: $ret = (object)[];
316: if ($withClean || $this->n_id) {
317: Util::setByPath($ret, "ID", $this->m_id);
318: }
319: if ($withClean || $this->n_scope) {
320: Util::setByPath($ret, "Scope", $this->m_scope);
321: }
322: if ($withClean || $this->n_name) {
323: Util::setByPath($ret, "Name", $this->m_name);
324: }
325: else {
326: if ($this->isNew) {
327: $missing->append("name");
328: }
329: }
330: if ($withClean || $this->n_url) {
331: Util::setByPath($ret, "URL", $this->m_url);
332: }
333: if ($missing->count() > 0) {
334: throw new SaklientException("required_field", "Required fields must be set before the Icon creation: " . implode(", ", (array)($missing)));
335: }
336: return $ret;
337: }
338:
339: 340: 341:
342: public function __get($key) {
343: switch ($key) {
344: case "id": return $this->get_id();
345: case "scope": return $this->get_scope();
346: case "name": return $this->get_name();
347: case "url": return $this->get_url();
348: default: return parent::__get($key);
349: }
350: }
351:
352: 353: 354:
355: public function __set($key, $v) {
356: switch ($key) {
357: case "name": return $this->set_name($v);
358: default: return parent::__set($key, $v);
359: }
360: }
361:
362: }
363:
364: