-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add sync command to save on PMK recordings and then download and…
… import
- Loading branch information
Showing
9 changed files
with
282 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Pumukit\BlackboardBundle\Services; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
|
||
class CollaborateAPIRecording | ||
{ | ||
private HttpClientInterface $client; | ||
private CollaborateAPIConfiguration $configuration; | ||
|
||
public function __construct(HttpClientInterface $client, CollaborateAPIConfiguration $configuration) | ||
{ | ||
$this->client = $client; | ||
$this->configuration = $configuration; | ||
} | ||
|
||
public function getRecordingData(string $accessToken, string $recording): ?array | ||
{ | ||
$path = $this->configuration->recordingDataUrl($recording); | ||
$recordingsResponse = $this->recordings($accessToken, $path); | ||
|
||
return json_decode($recordingsResponse, true); | ||
} | ||
|
||
public function getRecordingInfo(string $accessToken, string $recording): ?array | ||
{ | ||
$path = $this->configuration->recordingInfoUrl($recording); | ||
$recordingsResponse = $this->recordings($accessToken, $path); | ||
|
||
return json_decode($recordingsResponse, true); | ||
} | ||
|
||
private function recordings(string $accessToken, string $path): ?string | ||
{ | ||
$response = $this->client->request('GET', $path, [ | ||
'headers' => [ | ||
'Authorization' => 'Bearer '.$accessToken, | ||
'Accept' => 'application/json', | ||
'Content-Type' => 'application/json' | ||
], | ||
'verify_peer' => true, | ||
]); | ||
|
||
if (Response::HTTP_OK !== $response->getStatusCode()) { | ||
return null; | ||
} | ||
|
||
return $response->getContent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Pumukit\BlackboardBundle\Services; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
|
||
class CollaborateAPISessionSearch | ||
{ | ||
private HttpClientInterface $client; | ||
private CollaborateAPIConfiguration $configuration; | ||
|
||
public function __construct(HttpClientInterface $client, CollaborateAPIConfiguration $configuration) | ||
{ | ||
$this->client = $client; | ||
$this->configuration = $configuration; | ||
} | ||
|
||
public function searchBySessionName(string $accessToken, string $sessionName): ?array | ||
{ | ||
$sessionResponse = $this->sessionByName($accessToken, $sessionName); | ||
|
||
return json_decode($sessionResponse, true); | ||
} | ||
|
||
public function getEnrollmentsBySessionId(string $accessToken, string $sessionId): ?array | ||
{ | ||
$sessionResponse = $this->sessionById($accessToken, $sessionId); | ||
|
||
return json_decode($sessionResponse, true); | ||
} | ||
|
||
private function sessionByName(string $accessToken, string $sessionName): ?string | ||
{ | ||
try { | ||
$response = $this->client->request('GET', $this->configuration->sessionDataUrl(), [ | ||
'headers' => [ | ||
'Authorization' => 'Bearer '.$accessToken, | ||
'Accept' => 'application/json', | ||
], | ||
// 'query' => [ | ||
// 'name' => $sessionName, | ||
// ], | ||
]); | ||
|
||
if (Response::HTTP_OK !== $response->getStatusCode()) { | ||
throw new \Exception('Unable to get session. Response status code: '.$response->getStatusCode()); | ||
} | ||
|
||
return $response->getContent(); | ||
} catch (\Exception $exception) { | ||
throw new \Exception($exception->getMessage()); | ||
} | ||
} | ||
|
||
private function sessionById(string $accessToken, string $sesionId): ?string | ||
{ | ||
try { | ||
$response = $this->client->request('GET', $this->configuration->sessionDataUrl().'/'.$sesionId.'/enrollments', [ | ||
'headers' => [ | ||
'Authorization' => 'Bearer '.$accessToken, | ||
'Accept' => 'application/json', | ||
] | ||
]); | ||
|
||
if (Response::HTTP_OK !== $response->getStatusCode()) { | ||
throw new \Exception('Unable to get session. Response status code: '.$response->getStatusCode()); | ||
} | ||
|
||
return $response->getContent(); | ||
} catch (\Exception $exception) { | ||
throw new \Exception($exception->getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Pumukit\BlackboardBundle\ValueObject; | ||
|
||
final class CollaborateRecording | ||
{ | ||
private string $id; | ||
private string $courseUUID; | ||
private string $downloadUrl; | ||
private string $sessionName; | ||
private string $user; | ||
|
||
private function __construct(string $id, string $courseUUID, string $downloadUrl, string $sessionName) | ||
{ | ||
$this->id = $id; | ||
$this->courseUUID = $courseUUID; | ||
$this->downloadUrl = $downloadUrl; | ||
$this->sessionName = $sessionName; | ||
} | ||
|
||
public static function create(string $id, string $courseUUID, string $downloadUrl, string $sessionName): CollaborateRecording | ||
{ | ||
return new self($id, $courseUUID, $downloadUrl, $sessionName); | ||
} | ||
|
||
public function addUser(string $user): void | ||
{ | ||
$this->user = $user; | ||
} | ||
|
||
public function id(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function courseUUID(): string | ||
{ | ||
return $this->courseUUID; | ||
} | ||
|
||
public function downloadUrl(): string | ||
{ | ||
return $this->downloadUrl; | ||
} | ||
|
||
public function sessionName(): string | ||
{ | ||
return $this->sessionName; | ||
} | ||
|
||
public function user(): ?string | ||
{ | ||
return $this->user; | ||
} | ||
} |