Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Finish Endpoint Bindings #2

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 1 addition & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Remove extra spaces in a nullable typehint.
'compact_nullable_typehint' => true,
// Concatenation should be spaced according to configuration.
'concat_space' => ['spacing' => 'none'],
'concat_space' => ['spacing' => 'one'],
// The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.
'constant_case' => ['case' => 'lower'],
// The body of each control structure MUST be enclosed within braces.
Expand Down Expand Up @@ -208,8 +208,6 @@
'short_scalar_cast' => true,
// A PHP file without end tag must always end with a single empty line feed.
'single_blank_line_at_eof' => true,
// There should be exactly one blank line before a namespace declaration.
'single_blank_line_before_namespace' => true,
// There MUST NOT be more than one property or constant declared per statement.
'single_class_element_per_statement' => ['elements' => ['const', 'property']],
// There MUST be one use keyword per declaration.
Expand Down
10 changes: 2 additions & 8 deletions src/Abstractions/Album/Tracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
namespace Tnapf\Spotify\Abstractions\Album;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;
use Tnapf\Spotify\Abstractions\Common\Pages;
use Tnapf\Spotify\Abstractions\Track\SimplifiedTrack;

class Tracks
class Tracks extends Pages
{
public string $href;
public int $limit;
public ?string $next;
public int $offset;
public ?string $previous;
public int $total;

/** @var SimplifiedTrack[] */
#[ObjectArrayType(name: 'items', class: SimplifiedTrack::class)]
public array $items;
Expand Down
13 changes: 13 additions & 0 deletions src/Abstractions/Artist/Artists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tnapf\Spotify\Abstractions\Artist;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;
use Tnapf\Spotify\Abstractions\Common\Pages;

class Artists extends Pages
{
/** @var Artist[] */
#[ObjectArrayType(name: 'items', class: Artist::class)]
public array $items;
}
51 changes: 51 additions & 0 deletions src/Abstractions/Audiobook/Audiobook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Tnapf\Spotify\Abstractions\Audiobook;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;
use Tnapf\JsonMapper\Attributes\PrimitiveArrayType;
use Tnapf\JsonMapper\Attributes\PrimitiveType;
use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;
use Tnapf\Spotify\Abstractions\Artist\Artist;
use Tnapf\Spotify\Abstractions\Artist\ExternalUrls;
use Tnapf\Spotify\Abstractions\Common\Copyright;
use Tnapf\Spotify\Abstractions\Common\Image;

#[SnakeToCamelCase]
class Audiobook
{
#[ObjectArrayType('artists', Artist::class, true)]
public ?array $artists;

#[PrimitiveArrayType('availableMarkets', PrimitiveType::STRING)]
public array $availableMarkets;

#[ObjectArrayType('copyrights', Copyright::class)]
public array $copyrights;

public string $description;
public string $htmlDescription;
public ?string $edition;
public bool $explicit;
public ExternalUrls $externalUrls;
public string $href;
public string $id;

#[ObjectArrayType('images', Image::class)]
public array $images;

#[PrimitiveArrayType('languages', PrimitiveType::STRING)]
public array $languages;

public string $mediaType;
public string $name;

#[ObjectArrayType('narrators', Narrator::class)]
public array $narrators;

public string $publisher;
public string $type;
public string $uri;
public int $totalChapters;
public Chapters $chapters;
}
18 changes: 18 additions & 0 deletions src/Abstractions/Audiobook/Chapters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Tnapf\Spotify\Abstractions\Audiobook;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;

class Chapters
{
public string $href;
public int $limit;
public ?string $next;
public int $offset;
public ?string $previous;
public int $total;

#[ObjectArrayType('items', SimplifiedChapter::class)]
public array $items;
}
8 changes: 8 additions & 0 deletions src/Abstractions/Audiobook/Narrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Tnapf\Spotify\Abstractions\Audiobook;

class Narrator
{
public string $name;
}
44 changes: 44 additions & 0 deletions src/Abstractions/Audiobook/SimplifiedChapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Tnapf\Spotify\Abstractions\Audiobook;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;
use Tnapf\JsonMapper\Attributes\PrimitiveArrayType;
use Tnapf\JsonMapper\Attributes\PrimitiveType;
use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;
use Tnapf\Spotify\Abstractions\Artist\ExternalUrls;
use Tnapf\Spotify\Abstractions\Common\Image;
use Tnapf\Spotify\Abstractions\Common\Restrictions;

#[SnakeToCamelCase]
class SimplifiedChapter
{
public ?string $audioPreviewUrl;

#[PrimitiveArrayType('availableMarkets', PrimitiveType::STRING, true)]
public ?array $availableMarkets;

public int $chapterNumber;
public string $description;
public string $htmlDescription;
public int $durationMs;
public bool $explicit;
public ExternalUrls $externalUrls;
public string $href;
public string $id;

#[ObjectArrayType('images', Image::class)]
public array $images;

public ?bool $isPlayable;

#[PrimitiveArrayType('languages', PrimitiveType::STRING, true)]
public array $languages;

public string $name;
public string $releaseDate;
public string $releaseDatePrecision;
public string $type;
public string $uri;
public ?Restrictions $restrictions;
}
1 change: 1 addition & 0 deletions src/Abstractions/Authorization/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AccessToken
public string $accessToken;
public string $tokenType;
public int $expiresIn;
public ?string $refreshToken;

public function isExpired(): bool
{
Expand Down
48 changes: 48 additions & 0 deletions src/Abstractions/Authorization/Scope.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Tnapf\Spotify\Abstractions\Authorization;

/** @see https://developer.spotify.com/documentation/web-api/concepts/scopes */
enum Scope: string
{
// IMAGES
case UGC_IMAGE_UPLOAD = 'ugc-image-upload';

// SPOTIFY CONNECT
case USER_READ_PLAYBACK_STATE = 'user-read-playback-state';
case USER_MODIFY_PLAYBACK_STATE = 'user-modify-playback-state';
case USER_READ_CURRENTLY_PLAYING = 'user-read-currently-playing';

// PLAYBACK
case APP_REMOTE_CONTROL = 'app-remote-control';
case STREAMING = 'streaming';

// PLAYLISTS
case PLAYLIST_READ_PRIVATE = 'playlist-read-private';
case PLAYLIST_READ_COLLABORATIVE = 'playlist-read-collaborative';
case PLAYLIST_MODIFY_PUBLIC = 'playlist-modify-public';

// FOLLOW
case USER_FOLLOW_MODIFY = 'user-follow-modify';
case USER_FOLLOW_READ = 'user-follow-read';

// LISTENING HISTORY
case USER_READ_PLAYBACK_POSITION = 'user-read-playback-position';
case USER_TOP_READ = 'user-top-read';
case USER_READ_RECENTLY_PLAYED = 'user-read-recently-played';

// LIBRARY
case USER_LIBRARY_MODIFY = 'user-library-modify';
case USER_LIBRARY_READ = 'user-library-read';

// USERS
case USER_READ_EMAIL = 'user-read-email';
case USER_READ_PRIVATE = 'user-read-private';

// OPEN ACCESS
case USER_SOA_LINK = 'user-soa-link';
case USER_SOA_UNLINK = 'user-soa-unlink';
case USER_MANAGE_ENTITLEMENTS = 'user-manage-entitlements';
case USER_MANAGE_PARTNER = 'user-manage-partner';
case USER_CREATE_PARTNER = 'user-create-partner';
}
13 changes: 13 additions & 0 deletions src/Abstractions/Common/Pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tnapf\Spotify\Abstractions\Common;

class Pages
{
public string $href;
public int $limit;
public ?string $next;
public int $offset;
public ?string $previous;
public int $total;
}
20 changes: 20 additions & 0 deletions src/Abstractions/Playback/Actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;

#[SnakeToCamelCase]
class Actions
{
public ?bool $interruptingPlayback;
public ?bool $pausing;
public ?bool $resuming;
public ?bool $seeking;
public ?bool $skippingNext;
public ?bool $skippingPrev;
public ?bool $togglingRepeatContext;
public ?bool $togglingRepeatTrack;
public ?bool $togglingShuffle;
public ?bool $transferringPlayback;
}
11 changes: 11 additions & 0 deletions src/Abstractions/Playback/ContentType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

enum ContentType: string
{
case ARTIST = 'artist';
case PLAYLIST = 'playlist';
case ALBUM = 'album';
case SHOW = 'show';
}
13 changes: 13 additions & 0 deletions src/Abstractions/Playback/Context.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

use Tnapf\Spotify\Abstractions\Artist\ExternalUrls;

class Context
{
public ContentType $type;
public string $href;
public ?ExternalUrls $externalUrls;
public string $uri;
}
18 changes: 18 additions & 0 deletions src/Abstractions/Playback/Device.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;

#[SnakeToCamelCase]
class Device
{
public ?string $id;
public ?bool $active;
public bool $isPrivateSession;
public bool $isRestricted;
public string $name;
public string $type;
public int $volumePercent;
public ?bool $supportsVolume;
}
10 changes: 10 additions & 0 deletions src/Abstractions/Playback/RepeatState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

enum RepeatState: string
{
case Off = 'off';
case Track = 'track';
case Context = 'context';
}
20 changes: 20 additions & 0 deletions src/Abstractions/Playback/State.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playback;

use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;
use Tnapf\Spotify\Abstractions\Track\Track;

#[SnakeToCamelCase]
class State
{
public Device $device;
public RepeatState $repeatState;
public Context $context;
public int $timestamp;
public int $progressMs;
public bool $isPlaying;
public ?Track $item;
public string $currentlyPlayingType;
public Actions $actions;
}
7 changes: 6 additions & 1 deletion src/Abstractions/Playlist/Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
use Tnapf\JsonMapper\Attributes\SnakeToCamelCase;
use Tnapf\Spotify\Abstractions\Artist\ExternalUrls;
use Tnapf\Spotify\Abstractions\Common\Image;
use Tnapf\Spotify\Abstractions\User\User;

#[SnakeToCamelCase]
class Playlist
{
public bool $collaborative;
public ?string $description;
public ExternalUrls $externalUrls;
public Followers $followers;
public ?Followers $followers;
public string $href;
public string $id;

#[ObjectArrayType('images', Image::class)]
public array $images;

public string $name;
public User $owner;
public bool $public;
public string $snapshotId;
public Tracks $tracks;
public string $type;
public string $uri;
}
13 changes: 13 additions & 0 deletions src/Abstractions/Playlist/Playlists.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Tnapf\Spotify\Abstractions\Playlist;

use Tnapf\JsonMapper\Attributes\ObjectArrayType;
use Tnapf\Spotify\Abstractions\Common\Pages;

class Playlists extends Pages
{
/** @var Playlist[] */
#[ObjectArrayType(name: 'items', class: Playlist::class)]
public array $items;
}
Loading
Loading