4
0
api-powers/src/a752e4b2-9b5e-4188-8d33-3799c46d5119/code.php

101 lines
2.5 KiB
PHP
Raw Normal View History

2023-06-01 00:47:38 +00:00
<?php
/**
* @package GetBible
*
* @created 30th May, 2023
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git GetBible <https://git.vdm.dev/getBible>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\GetBible\Api;
use VDM\Joomla\GetBible\Abstraction\Api;
/**
* The GetBible Book Chapters
*
2023-06-02 02:47:47 +00:00
* @since 2.0.1
2023-06-01 00:47:38 +00:00
*/
final class Chapters extends Api
{
/**
* Get the chapters in a book in a translation
*
* @param string $translation The translation.
2023-06-04 18:30:49 +00:00
* @param int $book The book number.
2023-06-01 00:47:38 +00:00
*
* @return object|null The response object or null if an error occurs.
2023-06-02 02:47:47 +00:00
* @since 2.0.1
2023-06-01 00:47:38 +00:00
*/
2023-06-04 18:30:49 +00:00
public function get(string $translation, int $book): ?object
2023-06-01 00:47:38 +00:00
{
return $this->response->get(
$this->http->get(
$this->uri->get($translation . '/' . $book . '.json')
)
);
}
/**
* List the chapters of a book in a translation
*
* @param string $translation The translation.
2023-06-04 18:30:49 +00:00
* @param int $book The book number.
2023-06-01 00:47:38 +00:00
*
* @return object|null The response object or null if an error occurs.
2023-06-02 02:47:47 +00:00
* @since 2.0.1
2023-06-01 00:47:38 +00:00
*/
2023-06-04 18:30:49 +00:00
public function list( string $translation, int $book): ?object
2023-06-01 00:47:38 +00:00
{
return $this->response->get(
$this->http->get(
$this->uri->get($translation . '/' . $book . '/chapters.json')
)
);
}
/**
* List the chapters checksums of a book in a translation
*
* @param string $translation The translation.
2023-06-04 18:30:49 +00:00
* @param int $book The book number.
2023-06-01 00:47:38 +00:00
*
* @return object|null The response object or null if an error occurs.
2023-06-02 02:47:47 +00:00
* @since 2.0.1
2023-06-01 00:47:38 +00:00
*/
2023-06-04 18:30:49 +00:00
public function checksum(string $translation, int $book): ?object
2023-06-01 00:47:38 +00:00
{
return $this->response->get(
$this->http->get(
$this->uri->get($translation . '/' . $book . '/checksum.json')
)
);
2023-06-02 02:47:47 +00:00
}
/**
* Get the chapter's checksums of a book in a translation
*
* @param string $translation The translation.
2023-06-04 18:30:49 +00:00
* @param int $book The book number.
* @param int $chapter The chapter number.
2023-06-02 02:47:47 +00:00
*
* @return string|null The response checksum or null if an error occurs.
* @since 2.0.1
*/
2023-06-04 18:30:49 +00:00
public function sha(string $translation, int $book, int $chapter): ?string
2023-06-02 02:47:47 +00:00
{
return trim(
$this->response->get(
$this->http->get(
$this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha')
)
)
);
2023-06-01 00:47:38 +00:00
}
}