client = new Issuu(Settings::get('token')); } public function get_user():?stdClass { if (!isset($this->client)) return null; $user = new User($this->client); try { return $user->getUserProfile(); } catch (Exception $e) { error_log($e->getMessage()); return null; } } public function get_publications(array $args = []):?stdClass { if (!isset($this->client)) return null; $args = wp_parse_args($args, [ 'size' => 10, 'page' => 1, 'state' => 'ALL', 'q' => '', ]); $publications = new Publications($this->client); try { return $publications->list($args['size'], $args['page'], $args['state'], $args['q']); } catch (Exception $e) { error_log($e->getMessage()); return null; } } public function get_publication(string $slug):?stdClass { if (!isset($this->client)) return null; $publications = new Publications($this->client); try { return $publications->getPublicationBySlug($slug); } catch (Exception $e) { error_log($e->getMessage()); return null; } } public function get_publication_assets(string $slug, array $args = []):?stdClass { if (!isset($this->client)) return null; $publications = new ApiPublications($this->client); try { return $publications->getPublicationAssetsBySlug($slug, $args); } catch (Exception $e) { error_log($e->getMessage()); return null; } } public function get_publication_embed(string $slug, array $args = []):?stdClass { if (!isset($this->client)) return null; $publications = new ApiPublications($this->client); try { return $publications->getPublicationEmbedBySlug($slug, $args); } catch (Exception $e) { error_log($e->getMessage()); return null; } } }