Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sale/lib/exchange/integration/entity/ |
Upload File : |
<?php namespace Bitrix\Sale\Exchange\Integration\Entity; use Bitrix\Main\Type\DateTime; use Bitrix\Sale\Exchange\Integration\OAuth; class Token extends EO_B24integrationToken { public function refresh(OAuth\Client $oauthClient) { $response = $oauthClient->getAccessToken( "refresh_token", ["refresh_token" => $this->getRefreshToken()] ); if (!isset($response["error"]) && is_array($response)) { $this->update($response); return true; } return false; } /** * @param array $fields * @param null $guid * * @return \Bitrix\Main\ORM\Data\AddResult|\Bitrix\Main\ORM\Data\UpdateResult * @throws \Bitrix\Main\ObjectException */ public function update(array $fields = []) { if (isset($fields["guid"]) && $fields["guid"] <> '') { $this->setGuid($fields["guid"]); } if (isset($fields["access_token"])) { $this->setAccessToken($fields["access_token"]); } if (isset($fields["refresh_token"])) { $this->setRefreshToken($fields["refresh_token"]); } if (isset($fields["client_endpoint"])) { $this->setRestEndpoint($fields["client_endpoint"]); } if (isset($fields["member_id"])) { $this->setPortalId($fields["member_id"]); } if (isset($fields["expires_in"]) && intval($fields["expires_in"]) > 0) { $this->setExpires((new DateTime())->add(intval($fields["expires_in"])." seconds")); } $this->setChanged(new DateTime()); return $this->save(); } }