33 if ($this->isVirtualCalendar($link))
35 return $result->addError(
new Error(
'This type of calendar doesnt support push.', 415));
38 $calendarId = $link->getVendorSectionId();
43 $this->httpClient->query(
45 $this->connection->getVendor()->getServer()->getFullPath()
46 .
'/calendars/' . urlencode($calendarId) .
'/events/watch',
47 Web\Json::encode($params, JSON_UNESCAPED_SLASHES)
50 if ($this->httpClient->getStatus() === 200)
52 $data = Web\Json::decode($this->httpClient->getResult());
54 'CHANNEL_ID' => $data[
'id'],
55 'RESOURCE_ID' => $data[
'resourceId'],
56 'EXPIRES' =>
new DateTime($data[
'expiration'] / 1000,
'U'),
59 else if ($this->httpClient->getStatus() === 401)
61 $this->handleUnauthorize($this->connection);
63 $result->addError(
new Error(
'Unauthorized', $this->httpClient->getStatus()));
67 $result->addError(
new Error(
'Error of create channel', $this->httpClient->getStatus()));
89 $this->httpClient->query(
91 $this->connection->getVendor()->getServer()->getFullPath() .
'/channels/stop',
95 ], JSON_UNESCAPED_SLASHES)
98 if ($this->httpClient->getStatus() !== 200)
100 $result->addError(
new Error(
'Error of stopping push channel.', $this->httpClient->getStatus()));
120 $this->httpClient->query(
122 $this->connection->getVendor()->getServer()->getFullPath() .
'/users/me/calendarList/watch',
123 Web\Json::encode($channelInfo, JSON_UNESCAPED_SLASHES)
126 if ($this->isRequestSuccess())
128 $data = Web\Json::decode($this->httpClient->getResult());
130 'CHANNEL_ID' => $data[
'id'],
131 'RESOURCE_ID' => $data[
'resourceId'],
132 'EXPIRES' =>
new DateTime($data[
'expiration'] / 1000,
'U'),
135 else if ($this->httpClient->getStatus() === 401)
137 $this->handleUnauthorize($this->connection);
139 $result->addError(
new Error(
'Unauthorized', $this->httpClient->getStatus()));
143 $result->addError(
new Error(
'Error of create channel', $this->httpClient->getStatus()));