diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d85ec12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +nbproject +vendor +composer.phar +composer.lock +.idea + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk diff --git a/Client.php b/Client.php index 9a4b4d9..efd6609 100644 --- a/Client.php +++ b/Client.php @@ -17,10 +17,8 @@ * @see http://v2.wp-api.org/ * * @author Andre Schuurman - * @since 2.0 - * */ -class Client extends yii\base\Object { +class Client extends \yii\base\Object { /** * @var string API endpoint (default production) diff --git a/Exception.php b/Exception.php index 49ef9e0..908d656 100644 --- a/Exception.php +++ b/Exception.php @@ -8,20 +8,33 @@ * Error codes handling retry and other specific conditions * * @author Andre Schuurman - * @since 2.0 */ -class Exception extends yii\base\Exception { +class Exception extends \yii\base\Exception { const FAIL = 0; const RETRY = 1; const WAIT_RETRY = 2; const ITEM_EXISTS = 3; + static $code_names = [ + self::FAIL => ' unrecoverable', + self::RETRY => ' and can be retried', + self::WAIT_RETRY => ' and can be retried after wait time', + self::ITEM_EXISTS => ' because item already exists', + ]; + /** * @return string the user-friendly name of this exception */ public function getName() { - return 'API response failed, retry'; + return 'API request failed'.$this->getCodeName(); + } + + /** + * @return mixed|string + */ + public function getCodeName() { + return isset(self::$code_names[$this->getCode()])?self::$code_names[$this->getCode()]:''; } } \ No newline at end of file diff --git a/OAuth1.php b/OAuth1.php index d0de674..e7d50de 100644 --- a/OAuth1.php +++ b/OAuth1.php @@ -30,9 +30,8 @@ * @see https://wordpress.org/plugins/rest-api-oauth1/ * * @author Andre Schuurman - * @since 2.0 */ -class OAuth1 extends yii\authclient\OAuth1 +class OAuth1 extends \yii\authclient\OAuth1 { /** * @inheritdoc