From acd8fa08030e317b89f8a831eea7d3ef9fa2e820 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 12 Nov 2022 14:30:23 +1100 Subject: [PATCH] Add ability to alter page and limit properties of content requests, as well as iterate over pages --- src/XIVAPI/Api/ContentHandler.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/XIVAPI/Api/ContentHandler.php b/src/XIVAPI/Api/ContentHandler.php index dd2d06e..351858e 100644 --- a/src/XIVAPI/Api/ContentHandler.php +++ b/src/XIVAPI/Api/ContentHandler.php @@ -8,6 +8,8 @@ class ContentHandler { /** @var string */ private $contentName; + private $page = 1; + private $limiti = 100; public function setContentName(string $name): ContentHandler { @@ -22,6 +24,30 @@ public function one($id) public function list() { - return Guzzle::get("/{$this->contentName}"); + return Guzzle::get("/{$this->contentName}", [ + "query" => [ + "page" => $this->page, + "limit" => $this->limit, + ], + ]); } + + public function setPage(int $page): ContentHandler + { + $this->page = $page; + return $this; + } + + public function setLimit(int $limit): ContentHandler + { + $this->limit = $limit; + return $this; + } + + public function next() + { + $this->setPage($this->page + 1); + return $this->list(); + } + }