mirror of
https://github.com/koel/koel
synced 2024-12-23 02:53:20 +00:00
39 lines
954 B
PHP
39 lines
954 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Integrations\Lastfm\Requests;
|
||
|
|
||
|
use App\Models\Song;
|
||
|
use App\Models\User;
|
||
|
use Saloon\Contracts\Body\HasBody;
|
||
|
use Saloon\Enums\Method;
|
||
|
use Saloon\Traits\Body\HasFormBody;
|
||
|
|
||
|
final class ToggleLoveTrackRequest extends SignedRequest implements HasBody
|
||
|
{
|
||
|
use HasFormBody;
|
||
|
|
||
|
protected Method $method = Method::POST;
|
||
|
|
||
|
public function __construct(private Song $song, private User $user, private bool $love)
|
||
|
{
|
||
|
parent::__construct();
|
||
|
}
|
||
|
|
||
|
public function resolveEndpoint(): string
|
||
|
{
|
||
|
return '/';
|
||
|
}
|
||
|
|
||
|
/** @return array<mixed> */
|
||
|
protected function defaultBody(): array
|
||
|
{
|
||
|
return [
|
||
|
'api_key' => config('koel.lastfm.key'),
|
||
|
'method' => $this->love ? 'track.love' : 'track.unlove',
|
||
|
'sk' => $this->user->preferences->lastFmSessionKey,
|
||
|
'artist' => $this->song->artist->name,
|
||
|
'track' => $this->song->title,
|
||
|
];
|
||
|
}
|
||
|
}
|