Server IP : 66.29.132.124 / Your IP : 18.188.106.47 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/tacafoundation.org/wp-content/plugins/give/src/Tracking/ |
Upload File : |
<?php namespace Give\Tracking; use Give\Tracking\Enum\EventType; use Give\Tracking\Repositories\TelemetryAccessDetails; use Give\Tracking\TrackingData\WebsiteInfoData; /** * Class AccessTokenGenerator * @package Give\Tracking * * @since 2.10.0 */ class AccessToken { /** * @var TrackClient */ private $trackClient; /** * @var TelemetryAccessDetails */ private $telemetryAccessDetails; /** * AccessToken constructor. * * @param TrackClient $trackClient * @param TelemetryAccessDetails $telemetryAccessDetails */ public function __construct(TrackClient $trackClient, TelemetryAccessDetails $telemetryAccessDetails) { $this->trackClient = $trackClient; $this->telemetryAccessDetails = $telemetryAccessDetails; } /** * Store access token * * @since 2.10.0 */ public function store() { /* @var WebsiteInfoData $dataClass */ $dataClass = give(WebsiteInfoData::class); $response = $this->trackClient->post(new EventType(EventType::CREATE_TOKEN), $dataClass, ['blocking' => true]); if (is_wp_error($response)) { return false; } $response = json_decode(wp_remote_retrieve_body($response), true); if (empty($response['success'])) { return false; } $token = $response['data']['access_token']; $this->telemetryAccessDetails->saveAccessTokenOptionValue($token); return true; } }