openvk/VKAPI/Handlers/Account.php

78 lines
2.4 KiB
PHP
Raw Normal View History

2020-08-12 14:36:18 +03:00
<?php declare(strict_types=1);
namespace openvk\VKAPI\Handlers;
final class Account extends VKAPIRequestHandler
{
function getProfileInfo(): object
{
$this->requireUser();
return (object) [
2022-07-21 22:13:09 +03:00
"first_name" => $this->getUser()->getFirstName(),
"id" => $this->getUser()->getId(),
"last_name" => $this->getUser()->getLastName(),
"home_town" => $this->getUser()->getHometown(),
"status" => $this->getUser()->getStatus(),
2022-08-11 23:20:36 +03:00
"bdate" => $this->getUser()->getBirthday()->format('%e.%m.%Y'),
"bdate_visibility" => $this->getUser()->getBirthdayPrivacy(),
2022-07-21 22:13:09 +03:00
"phone" => "+420 ** *** 228", # TODO
"relation" => $this->getUser()->getMaritalStatus(),
"sex" => $this->getUser()->isFemale() ? 1 : 2
2020-08-12 14:36:18 +03:00
];
}
function getInfo(): object
{
$this->requireUser();
return (object) [
2022-08-11 23:20:36 +03:00
"2fa_required" => $this->getUser()->is2faEnabled() ? 1 : 0,
2022-07-21 22:13:09 +03:00
"country" => "CZ", # TODO
"eu_user" => false, # TODO
"https_required" => 1,
"intro" => 0,
"community_comments" => false,
"is_live_streaming_enabled" => false,
2020-08-12 14:36:18 +03:00
"is_new_live_streaming_enabled" => false,
2022-07-21 22:13:09 +03:00
"lang" => 1,
"no_wall_replies" => 0,
"own_posts_default" => 0
2020-08-12 14:36:18 +03:00
];
}
function setOnline(): int
2020-08-12 14:36:18 +03:00
{
$this->requireUser();
$this->getUser()->setOnline(time());
2022-08-13 05:41:59 +03:00
$this->getUser()->save();
2020-08-12 14:36:18 +03:00
return 1;
}
function setOffline(): object
{
$this->requireUser();
# Цiй метод є заглушка
2020-08-12 14:36:18 +03:00
return 1;
}
function getAppPermissions(): int
2020-08-12 14:36:18 +03:00
{
return 9355263;
}
function getCounters(string $filter = ""): object
{
return (object) [
2022-07-21 22:13:09 +03:00
"friends" => $this->getUser()->getFollowersCount(),
"notifications" => $this->getUser()->getNotificationsCount(),
2022-07-21 22:13:09 +03:00
"messages" => $this->getUser()->getUnreadMessagesCount()
2020-08-12 14:36:18 +03:00
];
# TODO: Filter
2020-08-12 14:36:18 +03:00
}
}