CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.1) (pull_request) Successful in 49s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m49s
CI / Coding Standards (pull_request) Successful in 2m55s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m40s
CI / Build Plugin Zip (pull_request) Skipped
Group classes can now be marked invite-only (us_offerings.access_mode). Invite-only classes are hidden from the public catalog and reachable only when the instructor lets someone in via one of three paths, managed from My Lessons -> My Group Classes: - Add students directly: enrols them now with a pending payment. - Make available: grants registered students access to self-enrol through the normal paid flow (multi-select, emailed a notice). - Invite by email: tokenised registration invite tied to the class for a non-account address; after they register the class becomes enrollable. Reuses an existing pending invite instead of sending a second link. New us_group_access table records grants; GET /offerings merges granted invite-only classes for the caller; enrolment requires a grant (403 invite_required) and flips it to enrolled on success. composer test (487), composer lint, composer cs all pass. Co-Authored-By: Claude Opus 4.8 <[email protected]>
63 lines
3.2 KiB
PHP
63 lines
3.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular;
|
|
|
|
use Unsupervised\Schedular\Availability\AvailabilityEndpoint;
|
|
use Unsupervised\Schedular\Availability\AvailabilityRepository;
|
|
use Unsupervised\Schedular\Booking\BookingEndpoint;
|
|
use Unsupervised\Schedular\Booking\BookingRepository;
|
|
use Unsupervised\Schedular\Booking\CancellationPolicy;
|
|
use Unsupervised\Schedular\GroupClass\EnrollmentEndpoint;
|
|
use Unsupervised\Schedular\GroupClass\GroupAccessRepository;
|
|
use Unsupervised\Schedular\GroupClass\EnrollmentRepository;
|
|
use Unsupervised\Schedular\Offering\OfferingEndpoint;
|
|
use Unsupervised\Schedular\Offering\OfferingRepository;
|
|
use Unsupervised\Schedular\Payment\PaymentEndpoint;
|
|
use Unsupervised\Schedular\Payment\PaymentService;
|
|
use Unsupervised\Schedular\Payment\StudioSettings;
|
|
use Unsupervised\Schedular\Policy\PolicyEndpoint;
|
|
use Unsupervised\Schedular\Policy\PolicyRepository;
|
|
use Unsupervised\Schedular\Policy\PolicyService;
|
|
use Unsupervised\Schedular\Policy\PolicyVersionRepository;
|
|
use Unsupervised\Schedular\Registration\QuestionEndpoint;
|
|
use Unsupervised\Schedular\Registration\QuestionRepository;
|
|
use Unsupervised\Schedular\Registration\RegistrationGate;
|
|
|
|
class RestRegistrar {
|
|
|
|
public const NAMESPACE = 'us-scheduler/v1';
|
|
|
|
private AvailabilityEndpoint $availabilityEndpoint;
|
|
private BookingEndpoint $bookingEndpoint;
|
|
private OfferingEndpoint $offeringEndpoint;
|
|
private QuestionEndpoint $questionEndpoint;
|
|
private PolicyEndpoint $policyEndpoint;
|
|
private EnrollmentEndpoint $enrollmentEndpoint;
|
|
private PaymentEndpoint $paymentEndpoint;
|
|
|
|
public function __construct( AvailabilityRepository $availability, BookingRepository $bookings, OfferingRepository $offerings, QuestionRepository $questions, PolicyRepository $policies, PolicyVersionRepository $policyVersions, PolicyService $policyService, RegistrationGate $gate, EnrollmentRepository $enrollments, GroupAccessRepository $groupAccess, PaymentService $paymentService ) {
|
|
$this->availabilityEndpoint = new AvailabilityEndpoint( $availability, $offerings );
|
|
$this->bookingEndpoint = new BookingEndpoint( $availability, $bookings, $offerings, $gate, $paymentService, new CancellationPolicy( new StudioSettings() ) );
|
|
$this->offeringEndpoint = new OfferingEndpoint( $offerings, $groupAccess );
|
|
$this->questionEndpoint = new QuestionEndpoint( $questions, $offerings );
|
|
$this->policyEndpoint = new PolicyEndpoint( $policies, $policyVersions, $policyService );
|
|
$this->enrollmentEndpoint = new EnrollmentEndpoint( $enrollments, $offerings, $gate, $paymentService, $groupAccess );
|
|
$this->paymentEndpoint = new PaymentEndpoint( $paymentService );
|
|
}
|
|
|
|
public function register(): void {
|
|
add_action( 'rest_api_init', [ $this, 'registerRoutes' ] );
|
|
}
|
|
|
|
public function registerRoutes(): void {
|
|
$this->availabilityEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->bookingEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->offeringEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->questionEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->policyEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->enrollmentEndpoint->registerRoutes( self::NAMESPACE );
|
|
$this->paymentEndpoint->registerRoutes( self::NAMESPACE );
|
|
}
|
|
}
|