2024-03-22 12:55:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Integrations\Lastfm\Requests;
|
|
|
|
|
2024-03-22 14:34:13 +00:00
|
|
|
use App\Http\Integrations\Lastfm\Contracts\RequiresSignature;
|
2024-03-22 12:55:25 +00:00
|
|
|
use App\Models\Song;
|
|
|
|
use App\Models\User;
|
|
|
|
use Saloon\Contracts\Body\HasBody;
|
|
|
|
use Saloon\Enums\Method;
|
2024-03-22 14:34:13 +00:00
|
|
|
use Saloon\Http\Request;
|
2024-03-22 12:55:25 +00:00
|
|
|
use Saloon\Traits\Body\HasFormBody;
|
|
|
|
|
2024-03-22 14:34:13 +00:00
|
|
|
final class ToggleLoveTrackRequest extends Request implements HasBody, RequiresSignature
|
2024-03-22 12:55:25 +00:00
|
|
|
{
|
|
|
|
use HasFormBody;
|
|
|
|
|
|
|
|
protected Method $method = Method::POST;
|
|
|
|
|
2024-04-18 14:36:28 +00:00
|
|
|
public function __construct(private readonly Song $song, private readonly User $user, private readonly bool $love)
|
2024-03-22 12:55:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function resolveEndpoint(): string
|
|
|
|
{
|
|
|
|
return '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return array<mixed> */
|
|
|
|
protected function defaultBody(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'method' => $this->love ? 'track.love' : 'track.unlove',
|
|
|
|
'sk' => $this->user->preferences->lastFmSessionKey,
|
|
|
|
'artist' => $this->song->artist->name,
|
|
|
|
'track' => $this->song->title,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|