User.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <?php
  2. /**
  3. * User
  4. *
  5. * PHP version 5
  6. *
  7. * @category Class
  8. * @package XeroAPI\XeroPHP
  9. * @author OpenAPI Generator team
  10. * @link https://openapi-generator.tech
  11. */
  12. /**
  13. * Xero Accounting API
  14. *
  15. * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
  16. *
  17. * Contact: api@xero.com
  18. * Generated by: https://openapi-generator.tech
  19. * OpenAPI Generator version: 5.4.0
  20. */
  21. /**
  22. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
  23. * https://openapi-generator.tech
  24. * Do not edit the class manually.
  25. */
  26. namespace XeroAPI\XeroPHP\Models\Accounting;
  27. use \ArrayAccess;
  28. use \XeroAPI\XeroPHP\AccountingObjectSerializer;
  29. use \XeroAPI\XeroPHP\StringUtil;
  30. use ReturnTypeWillChange;
  31. /**
  32. * User Class Doc Comment
  33. *
  34. * @category Class
  35. * @package XeroAPI\XeroPHP
  36. * @author OpenAPI Generator team
  37. * @link https://openapi-generator.tech
  38. */
  39. class User implements ModelInterface, ArrayAccess
  40. {
  41. const DISCRIMINATOR = null;
  42. /**
  43. * The original name of the model.
  44. *
  45. * @var string
  46. */
  47. protected static $openAPIModelName = 'User';
  48. /**
  49. * Array of property to type mappings. Used for (de)serialization
  50. *
  51. * @var string[]
  52. */
  53. protected static $openAPITypes = [
  54. 'user_id' => 'string',
  55. 'email_address' => 'string',
  56. 'first_name' => 'string',
  57. 'last_name' => 'string',
  58. 'updated_date_utc' => 'string',
  59. 'is_subscriber' => 'bool',
  60. 'organisation_role' => 'string'
  61. ];
  62. /**
  63. * Array of property to format mappings. Used for (de)serialization
  64. *
  65. * @var string[]
  66. */
  67. protected static $openAPIFormats = [
  68. 'user_id' => 'uuid',
  69. 'email_address' => null,
  70. 'first_name' => null,
  71. 'last_name' => null,
  72. 'updated_date_utc' => null,
  73. 'is_subscriber' => null,
  74. 'organisation_role' => null
  75. ];
  76. /**
  77. * Array of property to type mappings. Used for (de)serialization
  78. *
  79. * @return array
  80. */
  81. public static function openAPITypes()
  82. {
  83. return self::$openAPITypes;
  84. }
  85. /**
  86. * Array of property to format mappings. Used for (de)serialization
  87. *
  88. * @return array
  89. */
  90. public static function openAPIFormats()
  91. {
  92. return self::$openAPIFormats;
  93. }
  94. /**
  95. * Array of attributes where the key is the local name,
  96. * and the value is the original name
  97. *
  98. * @var string[]
  99. */
  100. protected static $attributeMap = [
  101. 'user_id' => 'UserID',
  102. 'email_address' => 'EmailAddress',
  103. 'first_name' => 'FirstName',
  104. 'last_name' => 'LastName',
  105. 'updated_date_utc' => 'UpdatedDateUTC',
  106. 'is_subscriber' => 'IsSubscriber',
  107. 'organisation_role' => 'OrganisationRole'
  108. ];
  109. /**
  110. * Array of attributes to setter functions (for deserialization of responses)
  111. *
  112. * @var string[]
  113. */
  114. protected static $setters = [
  115. 'user_id' => 'setUserId',
  116. 'email_address' => 'setEmailAddress',
  117. 'first_name' => 'setFirstName',
  118. 'last_name' => 'setLastName',
  119. 'updated_date_utc' => 'setUpdatedDateUtc',
  120. 'is_subscriber' => 'setIsSubscriber',
  121. 'organisation_role' => 'setOrganisationRole'
  122. ];
  123. /**
  124. * Array of attributes to getter functions (for serialization of requests)
  125. *
  126. * @var string[]
  127. */
  128. protected static $getters = [
  129. 'user_id' => 'getUserId',
  130. 'email_address' => 'getEmailAddress',
  131. 'first_name' => 'getFirstName',
  132. 'last_name' => 'getLastName',
  133. 'updated_date_utc' => 'getUpdatedDateUtc',
  134. 'is_subscriber' => 'getIsSubscriber',
  135. 'organisation_role' => 'getOrganisationRole'
  136. ];
  137. /**
  138. * Array of attributes where the key is the local name,
  139. * and the value is the original name
  140. *
  141. * @return array
  142. */
  143. public static function attributeMap()
  144. {
  145. return self::$attributeMap;
  146. }
  147. /**
  148. * Array of attributes to setter functions (for deserialization of responses)
  149. *
  150. * @return array
  151. */
  152. public static function setters()
  153. {
  154. return self::$setters;
  155. }
  156. /**
  157. * Array of attributes to getter functions (for serialization of requests)
  158. *
  159. * @return array
  160. */
  161. public static function getters()
  162. {
  163. return self::$getters;
  164. }
  165. /**
  166. * The original name of the model.
  167. *
  168. * @return string
  169. */
  170. public function getModelName()
  171. {
  172. return self::$openAPIModelName;
  173. }
  174. const ORGANISATION_ROLE_READONLY = 'READONLY';
  175. const ORGANISATION_ROLE_INVOICEONLY = 'INVOICEONLY';
  176. const ORGANISATION_ROLE_STANDARD = 'STANDARD';
  177. const ORGANISATION_ROLE_FINANCIALADVISER = 'FINANCIALADVISER';
  178. const ORGANISATION_ROLE_MANAGEDCLIENT = 'MANAGEDCLIENT';
  179. const ORGANISATION_ROLE_CASHBOOKCLIENT = 'CASHBOOKCLIENT';
  180. const ORGANISATION_ROLE_UNKNOWN = 'UNKNOWN';
  181. const ORGANISATION_ROLE_REMOVED = 'REMOVED';
  182. /**
  183. * Gets allowable values of the enum
  184. *
  185. * @return string[]
  186. */
  187. public function getOrganisationRoleAllowableValues()
  188. {
  189. return [
  190. self::ORGANISATION_ROLE_READONLY,
  191. self::ORGANISATION_ROLE_INVOICEONLY,
  192. self::ORGANISATION_ROLE_STANDARD,
  193. self::ORGANISATION_ROLE_FINANCIALADVISER,
  194. self::ORGANISATION_ROLE_MANAGEDCLIENT,
  195. self::ORGANISATION_ROLE_CASHBOOKCLIENT,
  196. self::ORGANISATION_ROLE_UNKNOWN,
  197. self::ORGANISATION_ROLE_REMOVED,
  198. ];
  199. }
  200. /**
  201. * Associative array for storing property values
  202. *
  203. * @var mixed[]
  204. */
  205. protected $container = [];
  206. /**
  207. * Constructor
  208. *
  209. * @param mixed[] $data Associated array of property values
  210. * initializing the model
  211. */
  212. public function __construct(array $data = null)
  213. {
  214. $this->container['user_id'] = isset($data['user_id']) ? $data['user_id'] : null;
  215. $this->container['email_address'] = isset($data['email_address']) ? $data['email_address'] : null;
  216. $this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null;
  217. $this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null;
  218. $this->container['updated_date_utc'] = isset($data['updated_date_utc']) ? $data['updated_date_utc'] : null;
  219. $this->container['is_subscriber'] = isset($data['is_subscriber']) ? $data['is_subscriber'] : null;
  220. $this->container['organisation_role'] = isset($data['organisation_role']) ? $data['organisation_role'] : null;
  221. }
  222. /**
  223. * Show all the invalid properties with reasons.
  224. *
  225. * @return array invalid properties with reasons
  226. */
  227. public function listInvalidProperties()
  228. {
  229. $invalidProperties = [];
  230. $allowedValues = $this->getOrganisationRoleAllowableValues();
  231. if (!is_null($this->container['organisation_role']) && !in_array($this->container['organisation_role'], $allowedValues, true)) {
  232. $invalidProperties[] = sprintf(
  233. "invalid value for 'organisation_role', must be one of '%s'",
  234. implode("', '", $allowedValues)
  235. );
  236. }
  237. return $invalidProperties;
  238. }
  239. /**
  240. * Validate all the properties in the model
  241. * return true if all passed
  242. *
  243. * @return bool True if all properties are valid
  244. */
  245. public function valid()
  246. {
  247. return count($this->listInvalidProperties()) === 0;
  248. }
  249. /**
  250. * Gets user_id
  251. *
  252. * @return string|null
  253. */
  254. public function getUserId()
  255. {
  256. return $this->container['user_id'];
  257. }
  258. /**
  259. * Sets user_id
  260. *
  261. * @param string|null $user_id Xero identifier
  262. *
  263. * @return $this
  264. */
  265. public function setUserId($user_id)
  266. {
  267. $this->container['user_id'] = $user_id;
  268. return $this;
  269. }
  270. /**
  271. * Gets email_address
  272. *
  273. * @return string|null
  274. */
  275. public function getEmailAddress()
  276. {
  277. return $this->container['email_address'];
  278. }
  279. /**
  280. * Sets email_address
  281. *
  282. * @param string|null $email_address Email address of user
  283. *
  284. * @return $this
  285. */
  286. public function setEmailAddress($email_address)
  287. {
  288. $this->container['email_address'] = $email_address;
  289. return $this;
  290. }
  291. /**
  292. * Gets first_name
  293. *
  294. * @return string|null
  295. */
  296. public function getFirstName()
  297. {
  298. return $this->container['first_name'];
  299. }
  300. /**
  301. * Sets first_name
  302. *
  303. * @param string|null $first_name First name of user
  304. *
  305. * @return $this
  306. */
  307. public function setFirstName($first_name)
  308. {
  309. $this->container['first_name'] = $first_name;
  310. return $this;
  311. }
  312. /**
  313. * Gets last_name
  314. *
  315. * @return string|null
  316. */
  317. public function getLastName()
  318. {
  319. return $this->container['last_name'];
  320. }
  321. /**
  322. * Sets last_name
  323. *
  324. * @param string|null $last_name Last name of user
  325. *
  326. * @return $this
  327. */
  328. public function setLastName($last_name)
  329. {
  330. $this->container['last_name'] = $last_name;
  331. return $this;
  332. }
  333. /**
  334. * Gets updated_date_utc
  335. *
  336. * @return string|null
  337. */
  338. public function getUpdatedDateUtc()
  339. {
  340. return $this->container['updated_date_utc'];
  341. }
  342. public function getUpdatedDateUtcAsDate()
  343. {
  344. if ($this->getUpdatedDateUtc() != null) {
  345. return StringUtil::convertStringToDateTime($this->getUpdatedDateUtc());
  346. } else {
  347. throw new \Exception('can not convert null string to date');
  348. }
  349. }
  350. /**
  351. * Sets updated_date_utc
  352. *
  353. * @param string|null $updated_date_utc Timestamp of last change to user
  354. *
  355. * @return $this
  356. */
  357. public function setUpdatedDateUtc($updated_date_utc)
  358. {
  359. $this->container['updated_date_utc'] = $updated_date_utc;
  360. return $this;
  361. }
  362. /**
  363. * Gets is_subscriber
  364. *
  365. * @return bool|null
  366. */
  367. public function getIsSubscriber()
  368. {
  369. return $this->container['is_subscriber'];
  370. }
  371. /**
  372. * Sets is_subscriber
  373. *
  374. * @param bool|null $is_subscriber Boolean to indicate if user is the subscriber
  375. *
  376. * @return $this
  377. */
  378. public function setIsSubscriber($is_subscriber)
  379. {
  380. $this->container['is_subscriber'] = $is_subscriber;
  381. return $this;
  382. }
  383. /**
  384. * Gets organisation_role
  385. *
  386. * @return string|null
  387. */
  388. public function getOrganisationRole()
  389. {
  390. return $this->container['organisation_role'];
  391. }
  392. /**
  393. * Sets organisation_role
  394. *
  395. * @param string|null $organisation_role User role that defines permissions in Xero and via API (READONLY, INVOICEONLY, STANDARD, FINANCIALADVISER, etc)
  396. *
  397. * @return $this
  398. */
  399. public function setOrganisationRole($organisation_role)
  400. {
  401. $allowedValues = $this->getOrganisationRoleAllowableValues();
  402. if (!is_null($organisation_role) && !in_array($organisation_role, $allowedValues, true)) {
  403. throw new \InvalidArgumentException(
  404. sprintf(
  405. "Invalid value for 'organisation_role', must be one of '%s'",
  406. implode("', '", $allowedValues)
  407. )
  408. );
  409. }
  410. $this->container['organisation_role'] = $organisation_role;
  411. return $this;
  412. }
  413. /**
  414. * Returns true if offset exists. False otherwise.
  415. *
  416. * @param integer $offset Offset
  417. *
  418. * @return boolean
  419. */
  420. #[\ReturnTypeWillChange]
  421. public function offsetExists($offset)
  422. {
  423. return isset($this->container[$offset]);
  424. }
  425. /**
  426. * Gets offset.
  427. *
  428. * @param integer $offset Offset
  429. *
  430. * @return mixed
  431. */
  432. #[\ReturnTypeWillChange]
  433. public function offsetGet($offset)
  434. {
  435. return isset($this->container[$offset]) ? $this->container[$offset] : null;
  436. }
  437. /**
  438. * Sets value based on offset.
  439. *
  440. * @param integer $offset Offset
  441. * @param mixed $value Value to be set
  442. *
  443. * @return void
  444. */
  445. #[\ReturnTypeWillChange]
  446. public function offsetSet($offset, $value)
  447. {
  448. if (is_null($offset)) {
  449. $this->container[] = $value;
  450. } else {
  451. $this->container[$offset] = $value;
  452. }
  453. }
  454. /**
  455. * Unsets offset.
  456. *
  457. * @param integer $offset Offset
  458. *
  459. * @return void
  460. */
  461. #[\ReturnTypeWillChange]
  462. public function offsetUnset($offset)
  463. {
  464. unset($this->container[$offset]);
  465. }
  466. /**
  467. * Gets the string presentation of the object
  468. *
  469. * @return string
  470. */
  471. public function __toString()
  472. {
  473. return json_encode(
  474. AccountingObjectSerializer::sanitizeForSerialization($this),
  475. JSON_PRETTY_PRINT
  476. );
  477. }
  478. }