Files
photoprismupload/src/Entities/Album.php
2021-11-27 12:52:29 +01:00

52 lines
1.3 KiB
PHP

<?php
namespace PhotoPrismUpload\Entities;
use PhotoPrismUpload\API\LoggerFactory;
/** A PhotoPrism Album */
class Album
{
/** @var string $uid Unique Id of the album */
public string $uid = '';
/** @var string $slug URL slug of the album */
public string $slug = '';
/** @var string $title Title of the album */
public string $title = '';
/** @var string|null $token Secret token of the album. Needs to be set by the API */
public ?string $token = null;
/**
* Creates a new album from the api response
*
* @param array $response Photoprism API response containing an album object
*
* @return void
*/
public function __construct(
array $response
) {
$this->uid = $response['UID'];
$this->slug = $response['Slug'];
$this->title = $response['Title'];
$this->logger = LoggerFactory::create('PhotoPrismUpload.Album');
}
/**
* Gets the URL path for this album.
* Starts with a leading /
* Returns null if the album's token is not set
*
* @return string|null
*/
public function getUrlPath(): ?string
{
if (empty($this->token)) {
return null;
}
return "/s/{$this->token}/{$this->slug}";
}
}