61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* @package CleverOgre
|
|
* @subpackage OgreIssuu
|
|
* @version 0.1.0
|
|
* @since 0.1.0
|
|
*/
|
|
|
|
namespace OgreIssuu\Api;
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
use stdClass;
|
|
use lasselehtinen\Issuu\Issuu;
|
|
|
|
class Publications {
|
|
|
|
private Issuu $issuu;
|
|
|
|
public function __construct(Issuu $issuu) {
|
|
$this->issuu = $issuu;
|
|
}
|
|
|
|
private static function parse_args(array $args, array $defaults):array {
|
|
return array_filter(
|
|
wp_parse_args($args, $defaults),
|
|
function ($value, $key) use ($defaults) {
|
|
return $value !== $defaults[$key];
|
|
},
|
|
ARRAY_FILTER_USE_BOTH
|
|
);
|
|
}
|
|
|
|
public function getPublicationAssetsBySlug(string $slug, array $args = []):stdClass {
|
|
$args = self::parse_args($args, [
|
|
'assetType' => '',
|
|
'size' => 10,
|
|
'page' => 1,
|
|
'documentPageNumber' => 0.0,
|
|
]);
|
|
|
|
return $this->issuu->getResponse(method: 'GET', endpoint: "publications/{$slug}/assets", queryParameters: $args);
|
|
}
|
|
|
|
public function getPublicationEmbedBySlug(string $slug, array $args = []):stdClass {
|
|
$args = self::parse_args($args, [
|
|
'responsive' => true,
|
|
'width' => '100%',
|
|
'height' => '100%',
|
|
'hideIssuuLogo' => false,
|
|
'hideShareButton' => false,
|
|
'showOtherPublications' => false,
|
|
'bgColor' => '',
|
|
'fullScreenShareBgColor' => '',
|
|
]);
|
|
|
|
return $this->issuu->getResponse(method: 'GET', endpoint: "publications/{$slug}/embed", queryParameters: $args);
|
|
}
|
|
|
|
}
|