Initial build of API endpoints.

This commit is contained in:
dcooperdalrymple
2024-09-06 17:05:22 -05:00
parent 513230c943
commit 162c79e986
3 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?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;
}
public function getPublicationAssetsBySlug(string $slug, array $args = []):stdClass {
$args = wp_parse_args($args, [
'assetType' => '',
'size' => 10,
'page' => 1,
'documentPageNumber' => 0.0,
]);
if (!$args['documentPageNumber']) unset($args['documentPageNumber']);
return $this->issuu->getResponse(method: 'GET', endpoint: "publications/{$slug}/assets", queryParameters: $args);
}
public function getPublicationEmbedBySlug(string $slug, array $args = []):stdClass {
$args = wp_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);
}
}