generated from mirzaev/pot
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
11282f6311 | |||
87b2f2ca0b | |||
cda2d0bcb9 |
@@ -70,6 +70,17 @@ final class interneturok extends core
|
|||||||
*/
|
*/
|
||||||
public const string USER = 'https://api-gw.interneturok.ru/api/v2/homeschool/current_user';
|
public const string USER = 'https://api-gw.interneturok.ru/api/v2/homeschool/current_user';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TARIFFS
|
||||||
|
*
|
||||||
|
* Method: GET
|
||||||
|
* Authrorization: Bearer
|
||||||
|
*
|
||||||
|
* @var const string TARIFFS The user tariffs API URL
|
||||||
|
*/
|
||||||
|
public const string TARIFFS = 'https://api-gw.interneturok.ru/api/v2/schedules/users/current/tariffs';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SCHEDULES
|
* SCHEDULES
|
||||||
*
|
*
|
||||||
@@ -176,8 +187,7 @@ final class interneturok extends core
|
|||||||
if (!empty($accounts)) {
|
if (!empty($accounts)) {
|
||||||
// Initialized accounts
|
// Initialized accounts
|
||||||
|
|
||||||
/* if (shuffle($accounts)) { */
|
if (shuffle($accounts)) {
|
||||||
if (true) {
|
|
||||||
// Shuffled accounts
|
// Shuffled accounts
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
@@ -473,10 +483,32 @@ final class interneturok extends core
|
|||||||
// Initializing the user data
|
// Initializing the user data
|
||||||
$user = json_decode((string) $response->getBody())?->data?->homeschool?->response?->user;
|
$user = json_decode((string) $response->getBody())?->data?->homeschool?->response?->user;
|
||||||
|
|
||||||
if ($user->grade + 1 === $grade) {
|
if (!empty($user)) {
|
||||||
// Matched the account grade with the grade
|
// Initialized the user data
|
||||||
|
|
||||||
// Initialiint the user identifier
|
// Initializing the request to the user data API
|
||||||
|
$request = new request(
|
||||||
|
'GET',
|
||||||
|
static::TARIFFS,
|
||||||
|
[
|
||||||
|
'Authorization' => "Bearer $this->token"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->browser->sendAsync($request)
|
||||||
|
->then(function ($response) use ($grade, $week, $user) {
|
||||||
|
// Sended the request and received the response
|
||||||
|
|
||||||
|
// Initializing the tariffs data
|
||||||
|
$tariffs = json_decode((string) $response->getBody())?->data?->tariffs?->response;
|
||||||
|
|
||||||
|
foreach ($tariffs as $tariff) {
|
||||||
|
// Iterating over tariffs
|
||||||
|
|
||||||
|
if ($tariff->grade === $grade) {
|
||||||
|
// Matched the tariff grade with the target grade
|
||||||
|
|
||||||
|
// Initializing the user identifier
|
||||||
$identifier = $user?->id;
|
$identifier = $user?->id;
|
||||||
|
|
||||||
if (!empty($identifier)) {
|
if (!empty($identifier)) {
|
||||||
@@ -591,8 +623,13 @@ final class interneturok extends core
|
|||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Exit (fail)
|
||||||
|
return false;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// Not matched the account grade with the grade
|
// Not initialized the user data
|
||||||
|
|
||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user