Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
token.php
1<?php
2
3
5
6
9
10class Token extends EO_B24integrationToken
11{
12 public function refresh(OAuth\Client $oauthClient)
13 {
14 $response = $oauthClient->getAccessToken(
15 "refresh_token",
16 ["refresh_token" => $this->getRefreshToken()]
17 );
18
19 if (!isset($response["error"]) && is_array($response))
20 {
21 $this->update($response);
22 return true;
23 }
24
25 return false;
26 }
27
35 public function update(array $fields = [])
36 {
37 if (isset($fields["guid"]) && $fields["guid"] <> '')
38 {
39 $this->setGuid($fields["guid"]);
40 }
41
42 if (isset($fields["access_token"]))
43 {
44 $this->setAccessToken($fields["access_token"]);
45 }
46
47 if (isset($fields["refresh_token"]))
48 {
49 $this->setRefreshToken($fields["refresh_token"]);
50 }
51
52 if (isset($fields["client_endpoint"]))
53 {
54 $this->setRestEndpoint($fields["client_endpoint"]);
55 }
56
57 if (isset($fields["member_id"]))
58 {
59 $this->setPortalId($fields["member_id"]);
60 }
61
62 if (isset($fields["expires_in"]) && intval($fields["expires_in"]) > 0)
63 {
64 $this->setExpires((new DateTime())->add(intval($fields["expires_in"])." seconds"));
65 }
66
67 $this->setChanged(new DateTime());
68
69 return $this->save();
70 }
71}
refresh(OAuth\Client $oauthClient)
Definition token.php:12