From 62278068602681f59b4d2fbb310414dcbd013aa8 Mon Sep 17 00:00:00 2001 From: Dmitry Fedyuk Date: Thu, 6 Jul 2017 06:12:32 +0300 Subject: [PATCH] 0.0.3 --- API/Client.php | 8 +++++++ API/Validator.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 4 ++-- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 API/Validator.php diff --git a/API/Client.php b/API/Client.php index f8c280d..1ed30e4 100644 --- a/API/Client.php +++ b/API/Client.php @@ -37,4 +37,12 @@ final protected function headers() {return ['Authorization' => "Zoho-authtoken { final protected function uriBase() {return sprintf( "https://%s.zoho.com/api/v{$this->version()}", df_zoho_app_lc($this) );} + + /** + * 2017-07-06 + * @see \Df\API\Client::responseValidatorC() + * @used-by \Df\API\Client::p() + * @return string + */ + final protected function responseValidatorC() {return \Df\ZohoBI\API\Validator::class;} } \ No newline at end of file diff --git a/API/Validator.php b/API/Validator.php new file mode 100644 index 0000000..0cbda4a --- /dev/null +++ b/API/Validator.php @@ -0,0 +1,56 @@ +": + * } + * https://www.zoho.eu/books/api/v3/#response + * https://www.zoho.eu/inventory/api/v1/#response + * @used-by \Df\ZohoBI\API\Client::responseValidatorC() + */ +final class Validator extends \Df\API\Response\Validator { + /** + * 2017-07-06 + * @override + * @see \Df\API\Response\Validator::message() + * @used-by \Df\API\Response\Validator::validate() + * @return string + */ + protected function message() {return $this->r()['message'];} + + /** + * 2017-07-06 + * @override + * @see \Df\API\Response\Validator::rs() + * @used-by \Df\API\Response\Validator::validate() + * @return string + */ + protected function rs() {return df_json_encode_pretty($this->r());} + + /** + * 2017-07-06 + * @override + * @see \Df\API\Response\Validator::title() + * @used-by \Df\API\Response\Validator::validate() + * @return string + */ + protected function title() {return 'Zoho ' . df_zoho_app($this->c()->m());} + + /** + * 2017-07-06 + * @override + * @see \Df\API\Response\Validator::valid() + * @used-by \Df\API\Response\Validator::validate() + * @return bool + */ + protected function valid() {return 0 === $this->r()['code'];} +} \ No newline at end of file diff --git a/composer.json b/composer.json index b576d30..5d19731 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mage2pro/zoho-bi" - ,"version": "0.0.2" + ,"version": "0.0.3" ,"description": "A common library for my «Zoho Books» and «Zoho Inventory» Magento 2 extensions." ,"type": "magento2-module" ,"homepage": "https://mage2.pro/tags/zoho" @@ -11,7 +11,7 @@ "homepage": "https://mage2.pro/users/dmitry_fedyuk", "role": "Developer" }] - ,"require": {"mage2pro/core": ">=2.7.38", "mage2pro/zoho": ">=0.0.4"} + ,"require": {"mage2pro/core": ">=2.7.39", "mage2pro/zoho": ">=0.0.4"} ,"autoload": {"files": ["registration.php"], "psr-4": {"Df\\ZohoBI\\": ""}} ,"keywords": [ "Zoho"