Created
October 25, 2022 08:32
-
-
Save sasin91/09b22f5b1a72ba3f0cb653320b1e3fcd to your computer and use it in GitHub Desktop.
Action class that's called for creating Broadcast.mux_stats_jwt_token
This file contains hidden or 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
<?php | |
namespace App\Actions; | |
use App\Enums\JWTTokenType; | |
use App\Models\Broadcast; | |
use App\Services\MuxApiClient; | |
use App\Values\MuxJWTToken; | |
use MuxPhp\ApiException; | |
class CreateMuxJWTToken | |
{ | |
public function __construct( | |
public readonly MuxApiClient $mux | |
) { | |
// code... | |
} | |
/** | |
* @throws ApiException | |
*/ | |
public function forBroadcast(Broadcast $broadcast): MuxJWTToken | |
{ | |
return $this->mux->systemApi->createJWTToken( | |
type: JWTTokenType::VIDEO_ID, | |
id: $broadcast->getKey(), | |
expiresAt: $broadcast->ends_at->addHour() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment