Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/get booking id from i cal uid change #123

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo

## [Unreleased]

### Changed

- Changed getBookingIdFromICalUid graph call from /me/events to /users/*/events
- Add test command for getting booking from uid.

## [1.2.2] - 2023-11-28

### Changed
Expand Down
45 changes: 45 additions & 0 deletions src/Command/TestGetBookingFromUidCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

// @codeCoverageIgnoreStart

namespace App\Command;

use App\Service\BookingServiceInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:test:graph-booking-from-uid',
description: 'Get user booking from uid.',
)]
class TestGetBookingFromUidCommand extends Command
{
public function __construct(
private readonly BookingServiceInterface $bookingService
) {
parent::__construct();
}

protected function configure(): void
{
$this->addArgument('uid', InputArgument::REQUIRED, 'Uid to get booking for.');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$uid = $input->getArgument('uid');
$io->note(sprintf('You request bookings for uid: %s', $uid));

$data = $this->bookingService->getBookingIdFromIcalUid($uid);
$io->info(json_encode($data));

return Command::SUCCESS;
}
}
// @codeCoverageIgnoreEnd
5 changes: 2 additions & 3 deletions src/Service/MicrosoftGraphBookingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,7 @@ public function createBodyUserId(string $id): string
public function getBookingIdFromICalUid(string $iCalUId): ?string
{
$token = $this->graphHelperService->authenticateAsServiceAccount();

$path = "/me/events?\$filter=iCalUId eq '$iCalUId'";
$path = "/users/$this->serviceAccountUsername/events?\$filter=uid eq '$iCalUId'";

$response = $this->graphHelperService->request($path, $token);

Expand Down Expand Up @@ -597,7 +596,7 @@ private function getEventFromResourceByICalUid(string $resourceEmail, string $iC
{
$token = $this->graphHelperService->authenticateAsServiceAccount();

$path = "/users/$resourceEmail/events?\$filter=iCalUId eq '$iCalUId'";
$path = "/users/$resourceEmail/events?\$filter=uid eq '$iCalUId'";

$response = $this->graphHelperService->request($path, $token);

Expand Down
Loading