From 39bd8e75b46220878709887343031efc5a19aa14 Mon Sep 17 00:00:00 2001 From: Brian Gregg Date: Mon, 16 Nov 2020 10:45:59 -0500 Subject: [PATCH] Enable interface to code tables --- src/Client.php | 7 ++++++ src/Conf/CodeTable.php | 49 +++++++++++++++++++++++++++++++++++++++++ src/Conf/CodeTables.php | 38 ++++++++++++++++++++++++++++++++ src/Conf/Conf.php | 1 + 4 files changed, 95 insertions(+) create mode 100644 src/Conf/CodeTable.php create mode 100644 src/Conf/CodeTables.php diff --git a/src/Client.php b/src/Client.php index d3b1714..1bd16d2 100644 --- a/src/Client.php +++ b/src/Client.php @@ -24,6 +24,7 @@ use Scriptotek\Alma\Conf\Jobs; use Scriptotek\Alma\Conf\Libraries; use Scriptotek\Alma\Conf\Library; +use Scriptotek\Alma\Conf\CodeTables; use Scriptotek\Alma\Exception\ClientException as AlmaClientException; use Scriptotek\Alma\Exception\InvalidApiKey; use Scriptotek\Alma\Exception\MaxNumberOfAttemptsExhausted; @@ -103,6 +104,11 @@ class Client */ public $jobs; + /** + * @var CodeTables + */ + public $codetables; + /** * @var TaskLists */ @@ -152,6 +158,7 @@ public function __construct( $this->conf = new Conf($this); $this->libraries = $this->conf->libraries; // shortcut $this->jobs = $this->conf->jobs; // shortcut + $this->codetables = $this->conf->codetables; // shortcut $this->taskLists = new TaskLists($this); diff --git a/src/Conf/CodeTable.php b/src/Conf/CodeTable.php new file mode 100644 index 0000000..b7ce871 --- /dev/null +++ b/src/Conf/CodeTable.php @@ -0,0 +1,49 @@ +code = $code; + } + + /** + * Check if we have the full representation of our data object. + * + * @param \stdClass $data + * + * @return bool + */ + protected function isInitialized($data) + { + return isset($data->name); + } + + /** + * Generate the base URL for this resource. + * + * @return string + */ + protected function urlBase() + { + return "/conf/code-tables/{$this->code}"; + } +} diff --git a/src/Conf/CodeTables.php b/src/Conf/CodeTables.php new file mode 100644 index 0000000..d0c853b --- /dev/null +++ b/src/Conf/CodeTables.php @@ -0,0 +1,38 @@ +client = $client; + } + + /** + * Get a CodeTable by identifier + * + * @param $code The identifier of a CodeTable + * + * @return CodeTable + */ + public function get($code) + { + return CodeTable::make($this->client, $code); + } +} diff --git a/src/Conf/Conf.php b/src/Conf/Conf.php index 65d44e3..4a7b1cb 100644 --- a/src/Conf/Conf.php +++ b/src/Conf/Conf.php @@ -12,5 +12,6 @@ public function __construct(Client $client) $this->client = $client; $this->libraries = new Libraries($client); $this->jobs = new Jobs($client); + $this->codetables = new CodeTables($client); } }