3namespace Bitrix\Calendar\Sync\Office365;
5use Bitrix\Calendar\Core\Base\BaseException;
6use Bitrix\Calendar\Sync\Dictionary;
7use Bitrix\Calendar\Sync\Exceptions\ApiException;
8use Bitrix\Calendar\Sync\Exceptions\AuthException;
9use Bitrix\Calendar\Sync\Exceptions\ConflictException;
10use Bitrix\Calendar\Sync\Exceptions\GoneException;
11use Bitrix\Calendar\Sync\Exceptions\NotFoundException;
12use Bitrix\Calendar\Sync\Exceptions\PreconditionFailedException;
13use Bitrix\Calendar\Sync\Exceptions\RemoteAccountException;
14use Bitrix\Calendar\Sync\Internals\ContextInterface;
15use Bitrix\Calendar\Sync\Internals\HasContextTrait;
16use Bitrix\Calendar\Sync\Office365\Dto\EventDto;
17use Bitrix\Calendar\Sync\Office365\Dto\SectionDto;
18use Bitrix\Calendar\Sync\Connection\SectionConnection;
19use Bitrix\Main\ArgumentException;
20use Bitrix\Main\ArgumentNullException;
21use Bitrix\Main\LoaderException;
29 private const CALENDAR_SELECT_FIELDS = [
37 'canViewPrivateItems',
39 'isTallyingResponses',
61 $this->apiClient = $this->context->getApiClient();
62 $this->helper = $this->context->getHelper();
103 'me/calendars/' .
$params[
'filter'][
'section_id'] .
'/events',
127 $selectQuery = http_build_query($selectParams);
129 return $this->apiClient->post(
'me/calendars?' . $selectQuery, array_filter($sectionDto->
toArray()));
146 return $this->apiClient->patch(
'me/calendars/' . $sectionDto->id, array_filter($sectionDto->
toArray()));
164 return $this->apiClient->post(
165 'me/calendars/' . $sectionId .
'/events',
166 array_filter($eventDto->
toArray(
true),
static function (
$val) {
167 return $val !== [] &&
$val !==
null;
186 $baseUri =
'me/calendars/' . $sectionConnection->
getVendorSectionId() .
'/calendarView/delta?';
187 $breakingFlag =
false;
196 $breakingFlag = $this->processResponseAfterDelta($sectionConnection,
$response);
219 while(!$breakingFlag);
228 private function getUriParam(
string $uri,
string $name): ?string
231 if ($urlData = parse_url(
$uri))
233 parse_str($urlData[
'query'],
$params);
254 return $this->apiClient->get(
255 'me/events/' .
$params[
'filter'][
'event_id'],
275 if ($eventDto->isCancelled)
278 'me/events/' . $vendorEventId .
'/cancel',
280 'Comment' =>
'Deleted from Bitrix',
289 'me/events/' . $vendorEventId,
290 array_filter($eventDto->
toArray(
true),
static function (
$val) {
291 return $val !== [] &&
$val !==
null;
318 return $this->apiClient->get(
319 'me/events/' .
$params[
'filter'][
'event_id'] .
'/instances',
321 'startDateTime' =>
$params[
'filter'][
'from'],
322 'endDateTime' =>
$params[
'filter'][
'to'],
343 $this->apiClient->delete(
344 'me/events/' . $vendorEventId,
367 $this->apiClient->delete(
368 'me/calendars/' . $vendorSectionId,
388 'changeType' =>
'created,updated,deleted',
389 'notificationUrl' => $this->getNotificationUrl(),
390 'resource' =>
"me/calendars/$vendorSectionId/events",
391 'expirationDateTime' => $this->getExpirationDateTime(),
392 'clientState' => $state,
393 'latestSupportedTlsVersion' =>
'v1_2',
396 return $this->apiClient->post(
'subscriptions',
$data);
413 return $this->apiClient->patch(
'subscriptions/' . $subscriptionId, [
414 'expirationDateTime' => $this->getExpirationDateTime(),
433 return $this->apiClient->delete(
'subscriptions/' . $subscriptionId);
458 $interval = $this->helper->getDeltaInterval();
459 $uri = $baseUri .
'startDateTime=' . $interval[
'from']->format($this->helper::TIME_FORMAT_LONG)
460 .
'&endDateTime=' . $interval[
'to']->format($this->helper::TIME_FORMAT_LONG);
476 '$select' => implode(
',', self::CALENDAR_SELECT_FIELDS),
489 $breakingFlag =
true;
491 if ($token = $this->getPageToken(
$response))
494 $breakingFlag =
false;
507 return $breakingFlag;
517 return !empty(
$response[
'@odata.nextLink'])
518 ? $this->getUriParam(
$response[
'@odata.nextLink'],
'$skiptoken')
529 return !empty(
$response[
'@odata.deltaLink'])
530 ? $this->getUriParam(
$response[
'@odata.deltaLink'],
'$deltatoken')
538 private function getNotificationUrl(): string
540 return str_replace(
'http:',
'https:', CCalendar::GetServerPath())
541 . $this->helper::PUSH_PATH;
547 private function getExpirationDateTime(): string
549 $time = time() + 70 * 60 * 60;
550 return date(
"c",
$time);
setSyncToken(?string $token)
setLastSyncStatus(?string $lastSyncStatus)
setPageToken(?string $token)
getCalendarDelta(SectionConnection $sectionConnection)
getEventList(array $params)
renewSectionSubscription(string $subscriptionId)
getCalendarList(array $params)
deleteSection(string $vendorSectionId)
createSection(SectionDto $sectionDto)
deleteEvent(string $vendorEventId)
updateSection(SectionDto $sectionDto)
static getCalendarSelectParams()
updateEvent(EventDto $eventDto, string $vendorEventId)
getDeltaUri(SectionConnection $sectionConnection, string $baseUri)
addSectionSubscription(string $vendorSectionId, string $state='')
deleteSectionSubscription(string $subscriptionId)
getEventInstances(array $params)
createEvent(EventDto $eventDto, string $sectionId)
toArray(bool $filterEmptyValue=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']