Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

namespace HiEvents\DomainObjects\Generated;

/**
* THIS FILE IS AUTOGENERATED - DO NOT EDIT IT DIRECTLY.
* @package HiEvents\DomainObjects\Generated
*/
abstract class TicketLookupTokenDomainObjectAbstract extends \HiEvents\DomainObjects\AbstractDomainObject
{
final public const SINGULAR_NAME = 'ticket_lookup_token';
final public const PLURAL_NAME = 'ticket_lookup_tokens';
final public const ID = 'id';
final public const EMAIL = 'email';
final public const TOKEN = 'token';
final public const EXPIRES_AT = 'expires_at';
final public const CREATED_AT = 'created_at';
final public const UPDATED_AT = 'updated_at';
final public const DELETED_AT = 'deleted_at';

protected int $id;
protected string $email;
protected string $token;
protected string $expires_at;
protected ?string $created_at = null;
protected ?string $updated_at = null;
protected ?string $deleted_at = null;

public function toArray(): array
{
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'token' => $this->token ?? null,
'expires_at' => $this->expires_at ?? null,
'created_at' => $this->created_at ?? null,
'updated_at' => $this->updated_at ?? null,
'deleted_at' => $this->deleted_at ?? null,
];
}

public function setId(int $id): self
{
$this->id = $id;
return $this;
}

public function getId(): int
{
return $this->id;
}

public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}

public function getEmail(): string
{
return $this->email;
}

public function setToken(string $token): self
{
$this->token = $token;
return $this;
}

public function getToken(): string
{
return $this->token;
}

public function setExpiresAt(string $expires_at): self
{
$this->expires_at = $expires_at;
return $this;
}

public function getExpiresAt(): string
{
return $this->expires_at;
}

public function setCreatedAt(?string $created_at): self
{
$this->created_at = $created_at;
return $this;
}

public function getCreatedAt(): ?string
{
return $this->created_at;
}

public function setUpdatedAt(?string $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}

public function getUpdatedAt(): ?string
{
return $this->updated_at;
}

public function setDeletedAt(?string $deleted_at): self
{
$this->deleted_at = $deleted_at;
return $this;
}

public function getDeletedAt(): ?string
{
return $this->deleted_at;
}
}
7 changes: 7 additions & 0 deletions backend/app/DomainObjects/TicketLookupTokenDomainObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace HiEvents\DomainObjects;

class TicketLookupTokenDomainObject extends Generated\TicketLookupTokenDomainObjectAbstract
{
}
10 changes: 10 additions & 0 deletions backend/app/Exceptions/InvalidTicketLookupTokenException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace HiEvents\Exceptions;

use Exception;

class InvalidTicketLookupTokenException extends Exception
{

}
1 change: 1 addition & 0 deletions backend/app/Helper/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Url
public const ATTENDEE_TICKET = 'app.frontend_urls.attendee_product';
public const ORDER_SUMMARY = 'app.frontend_urls.order_summary';
public const ORGANIZER_ORDER_SUMMARY = 'app.frontend_urls.organizer_order_summary';
public const TICKET_LOOKUP = 'app.frontend_urls.ticket_lookup';

public static function getFrontEndUrlFromConfig(string $key, array $queryParams = []): string
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace HiEvents\Http\Actions\TicketLookup;

use HiEvents\Exceptions\InvalidTicketLookupTokenException;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Resources\Order\OrderResourcePublic;
use HiEvents\Services\Application\Handlers\TicketLookup\DTO\GetOrdersByLookupTokenDTO;
use HiEvents\Services\Application\Handlers\TicketLookup\GetOrdersByLookupTokenHandler;
use Illuminate\Http\JsonResponse;

class GetOrdersByLookupTokenAction extends BaseAction
{
public function __construct(
private readonly GetOrdersByLookupTokenHandler $getOrdersByLookupTokenHandler,
) {
}

public function __invoke(string $token): JsonResponse
{
try {
$orders = $this->getOrdersByLookupTokenHandler->handle(
new GetOrdersByLookupTokenDTO(
token: $token,
)
);

return $this->resourceResponse(
resource: OrderResourcePublic::class,
data: $orders,
);
} catch (InvalidTicketLookupTokenException $e) {
return $this->errorResponse(
message: $e->getMessage(),
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace HiEvents\Http\Actions\TicketLookup;

use HiEvents\Http\Actions\BaseAction;
use HiEvents\Http\Request\TicketLookup\SendTicketLookupEmailRequest;
use HiEvents\Services\Application\Handlers\TicketLookup\DTO\SendTicketLookupEmailDTO;
use HiEvents\Services\Application\Handlers\TicketLookup\SendTicketLookupEmailHandler;
use Illuminate\Http\JsonResponse;

class SendTicketLookupEmailAction extends BaseAction
{
public function __construct(
private readonly SendTicketLookupEmailHandler $sendTicketLookupEmailHandler,
) {
}

public function __invoke(SendTicketLookupEmailRequest $request): JsonResponse
{
$this->sendTicketLookupEmailHandler->handle(
new SendTicketLookupEmailDTO(
email: $request->validated('email'),
)
);

return $this->jsonResponse(
data: [
'message' => __('If you have tickets associated with this email, we will send you an email with the details.'),
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace HiEvents\Http\Request\TicketLookup;

use Illuminate\Foundation\Http\FormRequest;

class SendTicketLookupEmailRequest extends FormRequest
{
public function rules(): array
{
return [
'email' => 'required|email',
];
}
}
44 changes: 44 additions & 0 deletions backend/app/Mail/TicketLookup/TicketLookupEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace HiEvents\Mail\TicketLookup;

use HiEvents\Helper\Url;
use HiEvents\Mail\BaseMail;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

/**
* @uses /backend/resources/views/emails/ticket-lookup/ticket-lookup.blade.php
*/
class TicketLookupEmail extends BaseMail
{
public function __construct(
private readonly string $email,
private readonly string $token,
private readonly int $orderCount,
) {
parent::__construct();
}

public function envelope(): Envelope
{
return new Envelope(
subject: __('Your Tickets'),
);
}

public function content(): Content
{
return new Content(
markdown: 'emails.ticket-lookup.ticket-lookup',
with: [
'email' => $this->email,
'orderCount' => $this->orderCount,
'ticketLookupUrl' => sprintf(
Url::getFrontEndUrlFromConfig(Url::TICKET_LOOKUP),
$this->token,
),
]
);
}
}
14 changes: 14 additions & 0 deletions backend/app/Models/TicketLookupToken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace HiEvents\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class TicketLookupToken extends BaseModel
{
use SoftDeletes;

protected $casts = [
'expires_at' => 'datetime',
];
}
3 changes: 3 additions & 0 deletions backend/app/Providers/RepositoryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use HiEvents\Repository\Eloquent\StripeCustomerRepository;
use HiEvents\Repository\Eloquent\StripePaymentsRepository;
use HiEvents\Repository\Eloquent\TaxAndFeeRepository;
use HiEvents\Repository\Eloquent\TicketLookupTokenRepository;
use HiEvents\Repository\Eloquent\UserRepository;
use HiEvents\Repository\Eloquent\WebhookLogRepository;
use HiEvents\Repository\Eloquent\WebhookRepository;
Expand Down Expand Up @@ -81,6 +82,7 @@
use HiEvents\Repository\Interfaces\StripeCustomerRepositoryInterface;
use HiEvents\Repository\Interfaces\StripePaymentsRepositoryInterface;
use HiEvents\Repository\Interfaces\TaxAndFeeRepositoryInterface;
use HiEvents\Repository\Interfaces\TicketLookupTokenRepositoryInterface;
use HiEvents\Repository\Interfaces\UserRepositoryInterface;
use HiEvents\Repository\Interfaces\WebhookLogRepositoryInterface;
use HiEvents\Repository\Interfaces\WebhookRepositoryInterface;
Expand Down Expand Up @@ -132,6 +134,7 @@ class RepositoryServiceProvider extends ServiceProvider
OrganizerSettingsRepositoryInterface::class => OrganizerSettingsRepository::class,
EmailTemplateRepositoryInterface::class => EmailTemplateRepository::class,
AccountStripePlatformRepositoryInterface::class => AccountStripePlatformRepository::class,
TicketLookupTokenRepositoryInterface::class => TicketLookupTokenRepository::class,
];

public function register(): void
Expand Down
20 changes: 20 additions & 0 deletions backend/app/Repository/Eloquent/TicketLookupTokenRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace HiEvents\Repository\Eloquent;

use HiEvents\DomainObjects\TicketLookupTokenDomainObject;
use HiEvents\Models\TicketLookupToken;
use HiEvents\Repository\Interfaces\TicketLookupTokenRepositoryInterface;

class TicketLookupTokenRepository extends BaseRepository implements TicketLookupTokenRepositoryInterface
{
protected function getModel(): string
{
return TicketLookupToken::class;
}

public function getDomainObject(): string
{
return TicketLookupTokenDomainObject::class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace HiEvents\Repository\Interfaces;

interface TicketLookupTokenRepositoryInterface extends RepositoryInterface
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace HiEvents\Services\Application\Handlers\TicketLookup\DTO;

use HiEvents\DataTransferObjects\BaseDataObject;

class GetOrdersByLookupTokenDTO extends BaseDataObject
{
public function __construct(
public readonly string $token,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace HiEvents\Services\Application\Handlers\TicketLookup\DTO;

use HiEvents\DataTransferObjects\BaseDataObject;

class SendTicketLookupEmailDTO extends BaseDataObject
{
public function __construct(
public readonly string $email,
) {
}
}
Loading
Loading