Skip to content

Commit

Permalink
Added issue checks for temporary codes for access cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Jnesselr committed Sep 29, 2024
1 parent 05dee4f commit 7eddd11
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/DataCache/AggregateCustomerData.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function get()
last_name: $customer['last_name'],
primaryEmail: $primaryEmail,
emails: $emails,
idChecked: $idWasChecked,
isMember: $isMember,
hasSignedWaiver: $hasSignedWaiver,
subscriptions: $subscriptionMap->get($customer['id'], fn() => collect()),
Expand Down
1 change: 1 addition & 0 deletions app/DataCache/MemberData.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function __construct(
public string $last_name,
public string $primaryEmail,
public Collection $emails,
public bool $idChecked,
public bool $isMember,
public bool $hasSignedWaiver,
public Collection $subscriptions,
Expand Down
47 changes: 47 additions & 0 deletions app/Issues/Checkers/AccessCards/TemporaryCodeIssues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Issues\Checkers\AccessCards;


use App\DataCache\AggregateCustomerData;
use App\DataCache\MemberData;
use App\Issues\Checkers\IssueCheck;
use App\Issues\Checkers\IssueCheckTrait;
use App\Issues\Types\AccessCards\CustomerHasBothCardAndTemporaryCode;
use App\Issues\Types\AccessCards\NoTemporaryCodeOnCustomerWithoutIdCheck;
use App\Models\UserMembership;
use Illuminate\Support\Collection;

class TemporaryCodeIssues implements IssueCheck
{
use IssueCheckTrait;

public function __construct(
private readonly AggregateCustomerData $aggregateCustomerData,
)
{
}

protected function generateIssues(): void
{
/** @var Collection<MemberData> $members */
$members = $this->aggregateCustomerData->get();

foreach ($members as $member) {
/** @var MemberData $member */
if ($member->cards->count() > 0 && ! is_null($member->accessCardTemporaryCode)) {
$this->issues->add(new CustomerHasBothCardAndTemporaryCode($member));
}

$fullMemberUserMembership = $member->userMemberships
->first(fn($um) => $um['plan_id'] == UserMembership::MEMBERSHIP_FULL_MEMBER);

if (! $member->idChecked &&
is_null($member->accessCardTemporaryCode) &&
! is_null($fullMemberUserMembership)) {
// This issue is important because they won't be able to get their card once their id is checked
$this->issues->add(new NoTemporaryCodeOnCustomerWithoutIdCheck($member));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Issues\Types\AccessCards;

use App\DataCache\MemberData;
use App\Issues\Types\IssueBase;

class CustomerHasBothCardAndTemporaryCode extends IssueBase
{
public function __construct(
private readonly MemberData $member
)
{
}

public static function getIssueNumber(): int
{
return 7; // auto-generated based on namespace and existing issues
}

public static function getIssueTitle(): string
{
return "Access Cards: Customer has both card and temporary code";
}

public function getIssueText(): string
{
return "{$this->member->full_name} has both an access card and a temporary code";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Issues\Types\AccessCards;

use App\DataCache\MemberData;
use App\Issues\Types\IssueBase;

class NoTemporaryCodeOnCustomerWithoutIdCheck extends IssueBase
{
public function __construct(
private readonly MemberData $member
)
{
}

public static function getIssueNumber(): int
{
return 8; // auto-generated based on namespace and existing issues
}

public static function getIssueTitle(): string
{
return "Access Cards: No temporary code on customer without id check";
}

public function getIssueText(): string
{
return "{$this->member->full_name} has no temporary code to get their access card and has not had their id checked.";
}
}

0 comments on commit 7eddd11

Please sign in to comment.