user.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Client\Request {
  3. class User extends RequestBase {
  4. public $uid;
  5. public $ulogin;
  6. public $ufull_name;
  7. public $uemail;
  8. public $uavatar_url;
  9. public $uusername;
  10. protected $_scope = "/user";
  11. public function __construct($api_url, $api_token, $user) {
  12. if (strlen($user) != 0)
  13. $this->_scope .= "s/" . $user;
  14. parent::__construct($api_url, $api_token);
  15. }
  16. protected function set_scope() {
  17. $this->url .= $this->_scope;
  18. }
  19. public function load($force = true) {
  20. $ret = parent::load($force);
  21. //$this->url = API_URL . "/users/" . $this->ulogin;
  22. return $ret;
  23. }
  24. public function get($scope) {
  25. switch ($scope) {
  26. case "/repos":
  27. return new User\Repos($this->url, $this->token);
  28. case "/tokens":
  29. return new User\Tokens($this->url, $this->token);
  30. }
  31. }
  32. protected function json_set_property($obj) {
  33. foreach ($obj as $key => $value) {
  34. $key = 'u' . $key;
  35. if (property_exists($this, $key))
  36. $this->{$key} = $value;
  37. }
  38. }
  39. }
  40. }
  41. ?>