diff --git a/.travis.yml b/.travis.yml index 715c62e..dc98059 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,21 @@ language: php +sudo: false + php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 + - 7.1 + - 7.2 + - 7.3 + - nightly + +matrix: + allow_failures: + - php: nightly + +before_install: + - travis_retry composer self-update + +install: + - travis_retry composer update --prefer-dist --no-interaction --prefer-stable + +script: vendor/bin/phpunit diff --git a/README.en.md b/README.en.md index 01d05ca..8405f0e 100644 --- a/README.en.md +++ b/README.en.md @@ -1,38 +1,36 @@ Rakuten Web Service SDK for PHP =============================== -[![Build Status](https://secure.travis-ci.org/rakuten-ws/rws-php-sdk.png?branch=master)](http://travis-ci.org/rakuten-ws/rws-php-sdk) +[![Build Status](https://secure.travis-ci.org/rakuten-ws/rws-php-sdk.png?branch=master)](https://travis-ci.org/rakuten-ws/rws-php-sdk) Rakuten Web Service SDK for PHP is a library to make it easy to connect to the Rakuten APIs. Requirement ----------- -- PHP5.2.3+ (Recommended: PHP5.2.10+ with [curl extension](http://php.net/manual/en/book.curl.php)) -- If you want to use this library on PHP5.2.10-, please install [HTTP_Client](http://pear.php.net/manual/en/package.http.http-client.php) on PEAR - or curl extension. +- PHP 7.1.0+ (Recommended: PHP 7.3.0+ with [curl extension](https://php.net/manual/en/book.curl.php)) Download -------- You can download SDK from following links. -- [Stable 1.1.0 - zip](https://github.com/rakuten-ws/rws-php-sdk/archive/1.1.0.zip) +- [Stable 2.0.0 - zip](https://github.com/rakuten-ws/rws-php-sdk/archive/2.0.0.zip) - [Source Code (Github)](https://github.com/rakuten-ws/rws-php-sdk) -RWS PHP SDK is registered at [Packagist](http://packagist.org/). -Therefore, you can get and manage the library with [Composer](http://getcomposer.org). +RWS PHP SDK is registered at [Packagist](https://packagist.org/). +Therefore, you can get and manage the library with [Composer](https://getcomposer.org). Get composer - curl -s http://getcomposer.org/installer | php + curl -s https://getcomposer.org/installer | php Create *composer.json* file in the project root: { "require": { - "rakuten-ws/rws-php-sdk": "1.*" + "rakuten-ws/rws-php-sdk": "2.*" } } @@ -44,10 +42,9 @@ Install Basic Usage ----------- -Please register your application using our Web Service site (http://webservice.rakuten.co.jp). +Please register your application using our Web Service site (https://webservice.rakuten.co.jp). -Next, load *autoload.php* in your application. -The *autoload.php* file is in the same directory as this readme file. +Next, load *vendor/autoload.php* in your application. Now you can use the library. For APIs that don't need user authorization, like IchibaItemSearch API and Books API, @@ -56,9 +53,9 @@ you can fetch data by following this sample code. ```php setApplicationId('YOUR_APPLICATION_ID'); @@ -79,11 +76,11 @@ if ($response->isOk()) { } ``` You can pass "API Name (string)", "Request Paramters (array)", and -"version" to *RakutenRws_Client::execute()* method. +"version" to *Rakuten\WebService\Client::execute()* method. "version" is an optional parameter. If you don't specify the "version" then the library will auotmatically select the latest version. -The following APIs support [Iterator (http://php.net/manual/en/class.iterator.php)], +The following APIs support [Iterator (https://php.net/manual/en/class.iterator.php)], so you can access each item's data with a foreach statement. * AuctionGenreKeywordSearch @@ -117,9 +114,9 @@ Example: ```php setApplicationId('YOUR_APPLICATION_ID'); $client->setAffiliateId('YOUR_AFFILIATE_ID'); @@ -141,14 +138,14 @@ To access APIs that need user's authorization, like the RakutenBookmark API, you need to get an *access_token* in advance. First, send the user to the authorization page. You can get the authorization page URL with the following code. -At the same time, please don't forget the scope in *RakutenRws_Client::getAuthorizeUrl()*. +At the same time, please don't forget the scope in *Rakuten\WebService\Client::getAuthorizeUrl()*. ```php setApplicationId('YOUR_APPLICATION_ID'); // Set Application Secret @@ -167,9 +164,9 @@ You can access API by this *access_token*. ```php setApplicationId('YOUR_APPLICATION_ID'); // Set Application Secret @@ -203,16 +200,16 @@ if ($response->isOk()) { Proxy Configuration ------------------- -You can use this API with a proxy. Please set proxy information with *RakutenRws_Client::setProxy()*. +You can use this API with a proxy. Please set proxy information with *Rakuten\WebService\Client::setProxy()*. Example: ```php setProxy('proxy-host.example.com:port'); $client->setApplicationId('YOUR_APPLICATION_ID'); @@ -228,19 +225,19 @@ $response = $client->execute('ItemSearch', array( Sample Code ----------- -- There is sample code in the [sample] (https://github.com/rakuten-ws/rws-php-sdk/tree/master/sample) directory. +- There is sample code in the [sample](https://github.com/rakuten-ws/rws-php-sdk/tree/master/sample) directory. - Please rename *config.php.sample* and set Application ID, Application Secret and Affiliate ID. Official API Document --------------------- -- http://webservice.rakuten.co.jp +- https://webservice.rakuten.co.jp SDK API Document ---------------- -- [API Docs](http://webservice.rakuten.co.jp/sdkapi/php/) +- [API Docs](https://webservice.rakuten.co.jp/sdkapi/php/) License ------- diff --git a/README.md b/README.md index a964236..d8beb1c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Rakuten Web Service SDK for PHP There is an English version in [here](https://github.com/rakuten-ws/rws-php-sdk/blob/master/README.en.md). -[![Build Status](https://secure.travis-ci.org/rakuten-ws/rws-php-sdk.png?branch=master)](http://travis-ci.org/rakuten-ws/rws-php-sdk) +[![Build Status](https://secure.travis-ci.org/rakuten-ws/rws-php-sdk.png?branch=master)](https://travis-ci.org/rakuten-ws/rws-php-sdk) Rakuten Web Service SDK for PHP は、PHPアプリケーションから 楽天が提供しているAPIに、簡単にアクセスすることができるSDK @@ -12,24 +12,22 @@ Rakuten Web Service SDK for PHP は、PHPアプリケーションから 動作要件 -------- -- PHP5.2.3以上 (PHP5.2.10以上, [curl拡張](http://php.net/manual/ja/book.curl.php) 導入を推奨) -- PHP5.2.10未満を利用する場合、PEAR の [HTTP_Client](http://pear.php.net/manual/ja/package.http.http-client.php) - か curl拡張の導入が必要です。 +- PHP7.1.0以上 (PHP5.2.10以上, [curl拡張](https://php.net/manual/ja/book.curl.php) 導入を推奨) ダウンロード ------------ 以下からSDKをダウンロードすることができます。 -- [最新版 1.1.0 - zipアーカイブ](https://github.com/rakuten-ws/rws-php-sdk/archive/1.1.0.zip) +- [最新版 2.0.0 - zipアーカイブ](https://github.com/rakuten-ws/rws-php-sdk/archive/2.0.0.zip) - [ソースコード (Github)](https://github.com/rakuten-ws/rws-php-sdk) -また、RWS PHP SDK は、[Packagist](http://packagist.org/) にパッケージ登録を行っています。 -そのため、 [Composer](http://getcomposer.org/) を通してパッケージを入手することができます。 +また、RWS PHP SDK は、[Packagist](https://packagist.org/) にパッケージ登録を行っています。 +そのため、 [Composer](https://getcomposer.org/) を通してパッケージを入手することができます。 composer を入手します - curl -s http://getcomposer.org/installer | php + curl -s https://getcomposer.org/installer | php あなたの開発プロジェクトのルートに composer.json を作成します。 @@ -47,20 +45,19 @@ composer を通してパッケージを入手します 基本的な使い方 -------------- -事前に、楽天ウェブサービスのドキュメントページ(http://webservice.rakuten.co.jp) +事前に、楽天ウェブサービスのドキュメントページ(https://webservice.rakuten.co.jp) にて、アプリ登録を行ってください。 -このドキュメントと同じディレクトリにある *autoload.php* を読み込むことにより、 -SDK の利用準備が整います。 +*vendor/autoload.php*を読み込むことにより、SDKの利用準備が整います。 ユーザ認証の必要のない、APIについては、以下のように情報を取得することができます。 ```php setApplicationId('YOUR_APPLICATION_ID'); @@ -81,7 +78,7 @@ if ($response->isOk()) { } ``` -*RakutenRws_Client::execute()* には、API名、パラメータ、バージョンを +*Rakuten\WebService\Client::execute()* には、API名、パラメータ、バージョンを 指定します。そのうち、バージョンについては省略することが可能で、 省略した場合、自動的にSDKが指定した最新バージョンを選択します。 @@ -119,9 +116,9 @@ foreach で 情報(商品情報・施設情報など) を順次取得するこ ```php setApplicationId('YOUR_APPLICATION_ID'); $client->setAffiliateId('YOUR_AFFILIATE_ID'); @@ -143,14 +140,14 @@ FavoriteBookmarkAPI (楽天ブックマーク系API) のようなユーザ認証 APIを使う場合は、 *access_token* を取得する必要があります。 まず、ユーザを認証ページに誘導してください。認証ページのURLは、以下のように取得することができます。 -この時、 *RakutenRws_Client::getAuthorizeUrl()* には、API利用スコープを設定することを忘れないください。 +この時、 *Rakuten\WebService\Client::getAuthorizeUrl()* には、API利用スコープを設定することを忘れないください。 ```php setApplicationId('YOUR_APPLICATION_ID'); // Secret をセットします @@ -169,9 +166,9 @@ echo $client->getAuthorizeUrl('rakuten_favoritebookmark_read'); ```php setApplicationId('YOUR_APPLICATION_ID'); // Secret をセットします @@ -206,16 +203,16 @@ if ($response->isOk()) { プロキシの設定 -------------- -*RakutenRws_Client::setProxy()* で、プロキシを通してAPIにアクセスすることができます。 +*Rakuten\WebService\Client::setProxy()* で、プロキシを通してAPIにアクセスすることができます。 以下が利用例になります ```php setProxy('proxy-host.example.com:port'); $client->setApplicationId('YOUR_APPLICATION_ID'); $client->setAffiliateId('YOUR_AFFILIATE_ID'); @@ -254,18 +251,18 @@ $response = $client->execute('IchibaItemSearch', array( サンプルコード ------------- -- [sample] (https://github.com/rakuten-ws/rws-php-sdk/tree/master/sample) ディレクトリにサンプルを用意しています。 +- [sample](https://github.com/rakuten-ws/rws-php-sdk/tree/master/sample) ディレクトリにサンプルを用意しています。 - config.php.sample を config.php にリネームし、アプリID, application_secret をセットすることで動作します。 公開APIドキュメント ------------------- -- http://webservice.rakuten.co.jp +- https://webservice.rakuten.co.jp SDK API Document ---------------- -- [API Docs](http://webservice.rakuten.co.jp/sdkapi/php/) +- [API Docs](https://webservice.rakuten.co.jp/sdkapi/php/) ライセンス ---------- diff --git a/autoload.php b/autoload.php deleted file mode 100644 index 8d81e95..0000000 --- a/autoload.php +++ /dev/null @@ -1,4 +0,0 @@ -=5.2.3", + "php": ">=7.1.0", "ext-openssl": "*" }, + "require-dev": { + "phpunit/phpunit": "~7.5" + }, "suggest": { - "ext-curl": "*", - "pear-pear/HTTP_Client": "*" + "ext-curl": "*" }, "autoload": { - "psr-0": {"RakutenRws_": "lib/"} + "psr-4": { + "Rakuten\\WebService\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Rakuten\\WebService\\": "tests/" + } }, "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } } } diff --git a/lib/RakutenRws/Autoloader.php b/lib/RakutenRws/Autoloader.php deleted file mode 100644 index 43c0146..0000000 --- a/lib/RakutenRws/Autoloader.php +++ /dev/null @@ -1,42 +0,0 @@ -client === null) { - $this->client = new Http_Client(); - } - - if ($this->proxy !== null) { - $parsedUrl = parse_url($this->proxy); - $this->client->setRequestParameter('proxy_host', $parsedUrl['host']); - - if (isset($parsedUrl['port'])) { - $this->client->setRequestParameter('proxy_port', $parsedUrl['port']); - } - - if (isset($parsedUrl['user'])) { - $this->client->setRequestParameter('proxy_user', $parsedUrl['user']); - } - - if (isset($parsedUrl['pass'])) { - $this->client->setRequestParameter('proxy_pass', $parsedUrl['pass']); - } - } - - $this->client->setRequestParameter('timeout', $this->timeout); - - $this->client->setDefaultHeader('User-Agent', 'RakutenWebService SDK for PHP-'.RakutenRws_Client::VERSION); - - return $this->client; - } - - public function get($url, $params = array()) - { - $client = $this->getHttpClient(); - - $client->get($url, $params); - - $response = $client->currentResponse(); - - return new RakutenRws_HttpResponse( - $url, - $params, - $response['code'], - $response['headers'], - $response['body'] - ); - } - - public function post($url, $params = array()) - { - $client = $this->getHttpClient(); - - $client->post($url, $params); - - $response = $client->currentResponse(); - - return new RakutenRws_HttpResponse( - $url, - $params, - $response['code'], - $response['headers'], - $response['body'] - ); - } -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4881c10..668dfec 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,21 @@ - - + - - ./test/RakutenRws/ + + tests - - ./lib/ - - ./lib/RakutenRws/HttpClient - ./lib/RakutenRws/Api/Definition - + + src diff --git a/sample/bookmark.php b/sample/bookmark.php index a78f4ab..1d4894a 100644 --- a/sample/bookmark.php +++ b/sample/bookmark.php @@ -1,7 +1,10 @@ setApplicationId(RAKUTEN_APP_ID); // Secretをセット diff --git a/sample/index.php b/sample/index.php index 4531c66..b71c9e6 100644 --- a/sample/index.php +++ b/sample/index.php @@ -1,9 +1,11 @@ setApplicationId(RAKUTEN_APP_ID); // アフィリエイトIDをセット (任意) Set Affiliate ID (Optional) diff --git a/lib/RakutenRws/Api/ApiInterface.php b/src/Api/ApiInterface.php similarity index 81% rename from lib/RakutenRws/Api/ApiInterface.php rename to src/Api/ApiInterface.php index e4c3fc5..e372906 100644 --- a/lib/RakutenRws/Api/ApiInterface.php +++ b/src/Api/ApiInterface.php @@ -9,13 +9,15 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api; + /** * The interface of API * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage Api */ -interface RakutenRws_Api_ApiInterface +interface ApiInterface { public function getAvailableVersions(); public function getOperationName(); diff --git a/lib/RakutenRws/Api/AppRakutenApi.php b/src/Api/AppRakutenApi.php similarity index 87% rename from lib/RakutenRws/Api/AppRakutenApi.php rename to src/Api/AppRakutenApi.php index 4605d7a..202f150 100644 --- a/lib/RakutenRws/Api/AppRakutenApi.php +++ b/src/Api/AppRakutenApi.php @@ -9,13 +9,18 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api; + +use Rakuten\WebService\ApiResponse\AppRakutenResponse; +use Rakuten\WebService\Exception; + /** * API for app.rakuten.co.jp * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage Api */ -abstract class RakutenRws_Api_AppRakutenApi extends RakutenRws_Api_Base +abstract class AppRakutenApi extends Base { const BASE_URL = 'https://app.rakuten.co.jp/services/api'; @@ -68,12 +73,12 @@ public function execute($parameter) $response = $client->$method($url, $parameter); - $appresponse = new RakutenRws_ApiResponse_AppRakutenResponse($this->getOperationName(), $response); + $appresponse = new AppRakutenResponse($this->getOperationName(), $response); if ($this->autoSetIterator && $appresponse->isOk()) { $data = $appresponse->getData(); if (!isset($data[$this->arrayName])) { - throw new RakutenRws_Exception(); + throw new Exception(); } $items = array(); diff --git a/lib/RakutenRws/Api/Base.php b/src/Api/Base.php similarity index 75% rename from lib/RakutenRws/Api/Base.php rename to src/Api/Base.php index e282e9d..c017a5a 100644 --- a/lib/RakutenRws/Api/Base.php +++ b/src/Api/Base.php @@ -9,13 +9,19 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api; + +use LogicException; +use Rakuten\WebService\Client; +use Rakuten\WebService\Exception; + /** * API base class * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage Api */ -abstract class RakutenRws_Api_Base implements RakutenRws_Api_ApiInterface +abstract class Base implements ApiInterface { protected $version = null, @@ -24,7 +30,7 @@ abstract class RakutenRws_Api_Base implements RakutenRws_Api_ApiInterface $autoSetIterator = false, $options = array(); - public function __construct(RakutenRws_Client $client, $options = array()) + public function __construct(Client $client, $options = array()) { $this->options = $options; $this->client = $client; @@ -38,7 +44,7 @@ public function getAvailableVersions() public function getOperationName() { - $className = explode('_', get_class($this)); + $className = explode('\\', get_class($this)); return end($className); } @@ -59,7 +65,7 @@ public function getLatestVersion() public function setVersion($version) { if (!in_array($version, $this->getAvailableVersions())) { - throw new RakutenRws_Exception(sprintf('version %s is not defined.', $version)); + throw new Exception(sprintf('version %s is not defined.', $version)); } $this->version = $version; diff --git a/lib/RakutenRws/Api/Definition/AuctionGenreIdSearch.php b/src/Api/Definition/AuctionGenreIdSearch.php similarity index 72% rename from lib/RakutenRws/Api/Definition/AuctionGenreIdSearch.php rename to src/Api/Definition/AuctionGenreIdSearch.php index baee923..2a9b5b8 100644 --- a/lib/RakutenRws/Api/Definition/AuctionGenreIdSearch.php +++ b/src/Api/Definition/AuctionGenreIdSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * AuctionGenreIdSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Definition */ -class RakutenRws_Api_Definition_AuctionGenreIdSearch extends RakutenRws_Api_AppRakutenApi +class AuctionGenreIdSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/AuctionGenreKeywordSearch.php b/src/Api/Definition/AuctionGenreKeywordSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/AuctionGenreKeywordSearch.php rename to src/Api/Definition/AuctionGenreKeywordSearch.php index 9e9912a..411a092 100644 --- a/lib/RakutenRws/Api/Definition/AuctionGenreKeywordSearch.php +++ b/src/Api/Definition/AuctionGenreKeywordSearch.php @@ -9,13 +9,18 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; +use Rakuten\WebService\Exception; + /** * AuctionGenreKeywordSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_AuctionGenreKeywordSearch extends RakutenRws_Api_AppRakutenApi +class AuctionGenreKeywordSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, @@ -40,7 +45,7 @@ public function execute($parameter) if ($appresponse->isOk()) { $data = $appresponse->getData(); if (!isset($data['auctionGenreList'])) { - throw new RakutenRws_Exception(); + throw new Rakuten\WebService_Exception(); } $appresponse->setIterator($data['auctionGenreList']); diff --git a/lib/RakutenRws/Api/Definition/AuctionItemCodeSearch.php b/src/Api/Definition/AuctionItemCodeSearch.php similarity index 72% rename from lib/RakutenRws/Api/Definition/AuctionItemCodeSearch.php rename to src/Api/Definition/AuctionItemCodeSearch.php index 2cb41b7..a98dd15 100644 --- a/lib/RakutenRws/Api/Definition/AuctionItemCodeSearch.php +++ b/src/Api/Definition/AuctionItemCodeSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * AuctionItemCodeSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_AuctionItemCodeSearch extends RakutenRws_Api_AppRakutenApi +class AuctionItemCodeSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/AuctionItemSearch.php b/src/Api/Definition/AuctionItemSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/AuctionItemSearch.php rename to src/Api/Definition/AuctionItemSearch.php index 72d048f..c14e0b4 100644 --- a/lib/RakutenRws/Api/Definition/AuctionItemSearch.php +++ b/src/Api/Definition/AuctionItemSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * AuctionItemSearch2 * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_AuctionItemSearch extends RakutenRws_Api_AppRakutenApi +class AuctionItemSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksBookSearch.php b/src/Api/Definition/BooksBookSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksBookSearch.php rename to src/Api/Definition/BooksBookSearch.php index 4862add..c15d263 100644 --- a/lib/RakutenRws/Api/Definition/BooksBookSearch.php +++ b/src/Api/Definition/BooksBookSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksBookSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksBookSearch extends RakutenRws_Api_AppRakutenApi +class BooksBookSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksCDSearch.php b/src/Api/Definition/BooksCDSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksCDSearch.php rename to src/Api/Definition/BooksCDSearch.php index f80ae52..e6f14a6 100644 --- a/lib/RakutenRws/Api/Definition/BooksCDSearch.php +++ b/src/Api/Definition/BooksCDSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksCDSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksCDSearch extends RakutenRws_Api_AppRakutenApi +class BooksCDSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksDVDSearch.php b/src/Api/Definition/BooksDVDSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksDVDSearch.php rename to src/Api/Definition/BooksDVDSearch.php index 53ffd51..dff90d8 100644 --- a/lib/RakutenRws/Api/Definition/BooksDVDSearch.php +++ b/src/Api/Definition/BooksDVDSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksDVDSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksDVDSearch extends RakutenRws_Api_AppRakutenApi +class BooksDVDSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksForeignBookSearch.php b/src/Api/Definition/BooksForeignBookSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksForeignBookSearch.php rename to src/Api/Definition/BooksForeignBookSearch.php index 80f304e..c1b8fbf 100644 --- a/lib/RakutenRws/Api/Definition/BooksForeignBookSearch.php +++ b/src/Api/Definition/BooksForeignBookSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksForeignBooksSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksForeignBookSearch extends RakutenRws_Api_AppRakutenApi +class BooksForeignBookSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksGameSearch.php b/src/Api/Definition/BooksGameSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksGameSearch.php rename to src/Api/Definition/BooksGameSearch.php index c648566..bc4ef56 100644 --- a/lib/RakutenRws/Api/Definition/BooksGameSearch.php +++ b/src/Api/Definition/BooksGameSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksGameSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksGameSearch extends RakutenRws_Api_AppRakutenApi +class BooksGameSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksGenreSearch.php b/src/Api/Definition/BooksGenreSearch.php similarity index 73% rename from lib/RakutenRws/Api/Definition/BooksGenreSearch.php rename to src/Api/Definition/BooksGenreSearch.php index ad69ad7..6a3c9d0 100644 --- a/lib/RakutenRws/Api/Definition/BooksGenreSearch.php +++ b/src/Api/Definition/BooksGenreSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksGenreSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksGenreSearch extends RakutenRws_Api_AppRakutenApi +class BooksGenreSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/BooksMagazineSearch.php b/src/Api/Definition/BooksMagazineSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksMagazineSearch.php rename to src/Api/Definition/BooksMagazineSearch.php index 1c79e78..d59121d 100644 --- a/lib/RakutenRws/Api/Definition/BooksMagazineSearch.php +++ b/src/Api/Definition/BooksMagazineSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksMagazineSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksMagazineSearch extends RakutenRws_Api_AppRakutenApi +class BooksMagazineSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksSoftwareSearch.php b/src/Api/Definition/BooksSoftwareSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksSoftwareSearch.php rename to src/Api/Definition/BooksSoftwareSearch.php index 8d2d8ba..37c3a21 100644 --- a/lib/RakutenRws/Api/Definition/BooksSoftwareSearch.php +++ b/src/Api/Definition/BooksSoftwareSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksSoftwareSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksSoftwareSearch extends RakutenRws_Api_AppRakutenApi +class BooksSoftwareSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/BooksTotalSearch.php b/src/Api/Definition/BooksTotalSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/BooksTotalSearch.php rename to src/Api/Definition/BooksTotalSearch.php index cf1c7a4..23bf34c 100644 --- a/lib/RakutenRws/Api/Definition/BooksTotalSearch.php +++ b/src/Api/Definition/BooksTotalSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * BooksTotalSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_BooksTotalSearch extends RakutenRws_Api_AppRakutenApi +class BooksTotalSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/FavoriteBookmarkAdd.php b/src/Api/Definition/FavoriteBookmarkAdd.php similarity index 74% rename from lib/RakutenRws/Api/Definition/FavoriteBookmarkAdd.php rename to src/Api/Definition/FavoriteBookmarkAdd.php index f5bddf6..26e6f5e 100644 --- a/lib/RakutenRws/Api/Definition/FavoriteBookmarkAdd.php +++ b/src/Api/Definition/FavoriteBookmarkAdd.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * FavoriteBookmarkAdd * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_FavoriteBookmarkAdd extends RakutenRws_Api_AppRakutenApi +class FavoriteBookmarkAdd extends AppRakutenApi { protected $versionMap = array( diff --git a/lib/RakutenRws/Api/Definition/FavoriteBookmarkDelete.php b/src/Api/Definition/FavoriteBookmarkDelete.php similarity index 73% rename from lib/RakutenRws/Api/Definition/FavoriteBookmarkDelete.php rename to src/Api/Definition/FavoriteBookmarkDelete.php index 2732ab0..ca4bd9c 100644 --- a/lib/RakutenRws/Api/Definition/FavoriteBookmarkDelete.php +++ b/src/Api/Definition/FavoriteBookmarkDelete.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * FavoriteBookmarkDelete * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_FavoriteBookmarkDelete extends RakutenRws_Api_AppRakutenApi +class FavoriteBookmarkDelete extends AppRakutenApi { protected $versionMap = array( diff --git a/lib/RakutenRws/Api/Definition/FavoriteBookmarkList.php b/src/Api/Definition/FavoriteBookmarkList.php similarity index 77% rename from lib/RakutenRws/Api/Definition/FavoriteBookmarkList.php rename to src/Api/Definition/FavoriteBookmarkList.php index 40d5a27..e95e6d0 100644 --- a/lib/RakutenRws/Api/Definition/FavoriteBookmarkList.php +++ b/src/Api/Definition/FavoriteBookmarkList.php @@ -9,13 +9,18 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; +use Rakuten\WebService\Exception; + /** * FavoriteBookmarkList * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_FavoriteBookmarkList extends RakutenRws_Api_AppRakutenApi +class FavoriteBookmarkList extends AppRakutenApi { protected $versionMap = array( @@ -39,7 +44,7 @@ public function execute($parameter) if ($response->isOk()) { $data = $response->getData(); if (!isset($data['items'])) { - throw new RakutenRws_Exception(); + throw new Exception(); } $items = array(); diff --git a/lib/RakutenRws/Api/Definition/GoraGoraGolfCourseDetail.php b/src/Api/Definition/GoraGoraGolfCourseDetail.php similarity index 72% rename from lib/RakutenRws/Api/Definition/GoraGoraGolfCourseDetail.php rename to src/Api/Definition/GoraGoraGolfCourseDetail.php index 51f693a..aee207c 100644 --- a/lib/RakutenRws/Api/Definition/GoraGoraGolfCourseDetail.php +++ b/src/Api/Definition/GoraGoraGolfCourseDetail.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * GoraGoraGolfCourseDetail * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_GoraGoraGolfCourseDetail extends RakutenRws_Api_AppRakutenApi +class GoraGoraGolfCourseDetail extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/GoraGoraGolfCourseSearch.php b/src/Api/Definition/GoraGoraGolfCourseSearch.php similarity index 74% rename from lib/RakutenRws/Api/Definition/GoraGoraGolfCourseSearch.php rename to src/Api/Definition/GoraGoraGolfCourseSearch.php index 37add39..fb75ccf 100644 --- a/lib/RakutenRws/Api/Definition/GoraGoraGolfCourseSearch.php +++ b/src/Api/Definition/GoraGoraGolfCourseSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * GoraGoraGolfCourseSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_GoraGoraGolfCourseSearch extends RakutenRws_Api_AppRakutenApi +class GoraGoraGolfCourseSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/GoraGoraPlanSearch.php b/src/Api/Definition/GoraGoraPlanSearch.php similarity index 74% rename from lib/RakutenRws/Api/Definition/GoraGoraPlanSearch.php rename to src/Api/Definition/GoraGoraPlanSearch.php index 9b5068e..508ffa6 100644 --- a/lib/RakutenRws/Api/Definition/GoraGoraPlanSearch.php +++ b/src/Api/Definition/GoraGoraPlanSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * GoraGoraPlanSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_GoraGoraPlanSearch extends RakutenRws_Api_AppRakutenApi +class GoraGoraPlanSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/HighCommissionShopList.php b/src/Api/Definition/HighCommissionShopList.php similarity index 76% rename from lib/RakutenRws/Api/Definition/HighCommissionShopList.php rename to src/Api/Definition/HighCommissionShopList.php index bbc3180..723e817 100644 --- a/lib/RakutenRws/Api/Definition/HighCommissionShopList.php +++ b/src/Api/Definition/HighCommissionShopList.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * HighCommissionShopList * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_HighCommissionShopList extends RakutenRws_Api_AppRakutenApi +class HighCommissionShopList extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/IchibaGenreSearch.php b/src/Api/Definition/IchibaGenreSearch.php similarity index 74% rename from lib/RakutenRws/Api/Definition/IchibaGenreSearch.php rename to src/Api/Definition/IchibaGenreSearch.php index f028606..23fc8a3 100644 --- a/lib/RakutenRws/Api/Definition/IchibaGenreSearch.php +++ b/src/Api/Definition/IchibaGenreSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * IchibaGenreSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_IchibaGenreSearch extends RakutenRws_Api_AppRakutenApi +class IchibaGenreSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/IchibaItemRanking.php b/src/Api/Definition/IchibaItemRanking.php similarity index 74% rename from lib/RakutenRws/Api/Definition/IchibaItemRanking.php rename to src/Api/Definition/IchibaItemRanking.php index 21951e7..cd4ff12 100644 --- a/lib/RakutenRws/Api/Definition/IchibaItemRanking.php +++ b/src/Api/Definition/IchibaItemRanking.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * IchibaItemRanking * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_IchibaItemRanking extends RakutenRws_Api_AppRakutenApi +class IchibaItemRanking extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/IchibaItemSearch.php b/src/Api/Definition/IchibaItemSearch.php similarity index 77% rename from lib/RakutenRws/Api/Definition/IchibaItemSearch.php rename to src/Api/Definition/IchibaItemSearch.php index c445670..71bbdbe 100644 --- a/lib/RakutenRws/Api/Definition/IchibaItemSearch.php +++ b/src/Api/Definition/IchibaItemSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * IchibaItemSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_IchibaItemSearch extends RakutenRws_Api_AppRakutenApi +class IchibaItemSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/IchibaTagSearch.php b/src/Api/Definition/IchibaTagSearch.php similarity index 73% rename from lib/RakutenRws/Api/Definition/IchibaTagSearch.php rename to src/Api/Definition/IchibaTagSearch.php index 373186b..5256daf 100644 --- a/lib/RakutenRws/Api/Definition/IchibaTagSearch.php +++ b/src/Api/Definition/IchibaTagSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * IchibaTagSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_IchibaTagSearch extends RakutenRws_Api_AppRakutenApi +class IchibaTagSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/KoboEbookSearch.php b/src/Api/Definition/KoboEbookSearch.php similarity index 75% rename from lib/RakutenRws/Api/Definition/KoboEbookSearch.php rename to src/Api/Definition/KoboEbookSearch.php index 8f1af90..0dc32c2 100644 --- a/lib/RakutenRws/Api/Definition/KoboEbookSearch.php +++ b/src/Api/Definition/KoboEbookSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * KoboEbookSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_KoboEbookSearch extends RakutenRws_Api_AppRakutenApi +class KoboEbookSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/KoboGenreSearch.php b/src/Api/Definition/KoboGenreSearch.php similarity index 73% rename from lib/RakutenRws/Api/Definition/KoboGenreSearch.php rename to src/Api/Definition/KoboGenreSearch.php index 0a0652b..efac057 100644 --- a/lib/RakutenRws/Api/Definition/KoboGenreSearch.php +++ b/src/Api/Definition/KoboGenreSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * KoboGenreSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_KoboGenreSearch extends RakutenRws_Api_AppRakutenApi +class KoboGenreSearch extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/ProductSearch.php b/src/Api/Definition/ProductSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/ProductSearch.php rename to src/Api/Definition/ProductSearch.php index e6adc32..279b148 100644 --- a/lib/RakutenRws/Api/Definition/ProductSearch.php +++ b/src/Api/Definition/ProductSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * ProductSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_ProductSearch extends RakutenRws_Api_AppRakutenApi +class ProductSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/RecipeCategoryList.php b/src/Api/Definition/RecipeCategoryList.php similarity index 73% rename from lib/RakutenRws/Api/Definition/RecipeCategoryList.php rename to src/Api/Definition/RecipeCategoryList.php index 227d580..75d9ab2 100644 --- a/lib/RakutenRws/Api/Definition/RecipeCategoryList.php +++ b/src/Api/Definition/RecipeCategoryList.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * RecipeCategoryList * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_RecipeCategoryList extends RakutenRws_Api_AppRakutenApi +class RecipeCategoryList extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/RecipeCategoryRanking.php b/src/Api/Definition/RecipeCategoryRanking.php similarity index 76% rename from lib/RakutenRws/Api/Definition/RecipeCategoryRanking.php rename to src/Api/Definition/RecipeCategoryRanking.php index 2cfa077..bef24d3 100644 --- a/lib/RakutenRws/Api/Definition/RecipeCategoryRanking.php +++ b/src/Api/Definition/RecipeCategoryRanking.php @@ -9,13 +9,18 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; +use Rakuten\WebService\Exception; + /** * RecipeCategoryList * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_RecipeCategoryRanking extends RakutenRws_Api_AppRakutenApi +class RecipeCategoryRanking extends AppRakutenApi { protected $isRequiredAccessToken = false, @@ -40,7 +45,7 @@ public function execute($parameter) if ($appresponse->isOk()) { $data = $appresponse->getData(); if (!isset($data['result'])) { - throw new RakutenRws_Exception(); + throw new Exception(); } $appresponse->setIterator($data['result']); diff --git a/lib/RakutenRws/Api/Definition/TravelGetAreaClass.php b/src/Api/Definition/TravelGetAreaClass.php similarity index 73% rename from lib/RakutenRws/Api/Definition/TravelGetAreaClass.php rename to src/Api/Definition/TravelGetAreaClass.php index d5c6aac..ebe6ec2 100644 --- a/lib/RakutenRws/Api/Definition/TravelGetAreaClass.php +++ b/src/Api/Definition/TravelGetAreaClass.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelGetAreaClass * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelGetAreaClass extends RakutenRws_Api_AppRakutenApi +class TravelGetAreaClass extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/TravelGetHotelChainList.php b/src/Api/Definition/TravelGetHotelChainList.php similarity index 72% rename from lib/RakutenRws/Api/Definition/TravelGetHotelChainList.php rename to src/Api/Definition/TravelGetHotelChainList.php index d3ad7f0..910b7cf 100644 --- a/lib/RakutenRws/Api/Definition/TravelGetHotelChainList.php +++ b/src/Api/Definition/TravelGetHotelChainList.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelGetHotelChainList * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelGetHotelChainList extends RakutenRws_Api_AppRakutenApi +class TravelGetHotelChainList extends AppRakutenApi { protected $isRequiredAccessToken = false, @@ -32,4 +36,4 @@ public function getOperation() { return 'GetHotelChainList'; } -} \ No newline at end of file +} diff --git a/lib/RakutenRws/Api/Definition/TravelHotelDetailSearch.php b/src/Api/Definition/TravelHotelDetailSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/TravelHotelDetailSearch.php rename to src/Api/Definition/TravelHotelDetailSearch.php index 2ba808c..011466a 100644 --- a/lib/RakutenRws/Api/Definition/TravelHotelDetailSearch.php +++ b/src/Api/Definition/TravelHotelDetailSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelHotelDetailSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelHotelDetailSearch extends RakutenRws_Api_AppRakutenApi +class TravelHotelDetailSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/TravelHotelRanking.php b/src/Api/Definition/TravelHotelRanking.php similarity index 73% rename from lib/RakutenRws/Api/Definition/TravelHotelRanking.php rename to src/Api/Definition/TravelHotelRanking.php index c3ba840..578452a 100644 --- a/lib/RakutenRws/Api/Definition/TravelHotelRanking.php +++ b/src/Api/Definition/TravelHotelRanking.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelHotelRanking * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelHotelRanking extends RakutenRws_Api_AppRakutenApi +class TravelHotelRanking extends AppRakutenApi { protected $isRequiredAccessToken = false, diff --git a/lib/RakutenRws/Api/Definition/TravelKeywordHotelSearch.php b/src/Api/Definition/TravelKeywordHotelSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/TravelKeywordHotelSearch.php rename to src/Api/Definition/TravelKeywordHotelSearch.php index 595357c..c60d808 100644 --- a/lib/RakutenRws/Api/Definition/TravelKeywordHotelSearch.php +++ b/src/Api/Definition/TravelKeywordHotelSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelKeywordHotelSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelKeywordHotelSearch extends RakutenRws_Api_AppRakutenApi +class TravelKeywordHotelSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/TravelSimpleHotelSearch.php b/src/Api/Definition/TravelSimpleHotelSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/TravelSimpleHotelSearch.php rename to src/Api/Definition/TravelSimpleHotelSearch.php index 1b5b70d..2f4f92f 100644 --- a/lib/RakutenRws/Api/Definition/TravelSimpleHotelSearch.php +++ b/src/Api/Definition/TravelSimpleHotelSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelSimpleHotelSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelSimpleHotelSearch extends RakutenRws_Api_AppRakutenApi +class TravelSimpleHotelSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/Api/Definition/TravelVacantHotelSearch.php b/src/Api/Definition/TravelVacantHotelSearch.php similarity index 76% rename from lib/RakutenRws/Api/Definition/TravelVacantHotelSearch.php rename to src/Api/Definition/TravelVacantHotelSearch.php index bbd5772..a77c22f 100644 --- a/lib/RakutenRws/Api/Definition/TravelVacantHotelSearch.php +++ b/src/Api/Definition/TravelVacantHotelSearch.php @@ -9,13 +9,17 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\Api\Definition; + +use Rakuten\WebService\Api\AppRakutenApi; + /** * TravelVacantHotelSearch * - * @package RakutenRws - * @subpackage Api_Definition + * @package Rakuten\WebService + * @subpackage Api\Defintion */ -class RakutenRws_Api_Definition_TravelVacantHotelSearch extends RakutenRws_Api_AppRakutenApi +class TravelVacantHotelSearch extends AppRakutenApi { protected $autoSetIterator = true, diff --git a/lib/RakutenRws/ApiResponse.php b/src/ApiResponse.php similarity index 89% rename from lib/RakutenRws/ApiResponse.php rename to src/ApiResponse.php index 95405e4..c3d4dab 100644 --- a/lib/RakutenRws/ApiResponse.php +++ b/src/ApiResponse.php @@ -9,12 +9,21 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService; + +use ArrayAccess; +use ArrayIterator; +use BadMethodCallException; +use Iterator; +use IteratorAggregate; +use LogicException; + /** * ApiResponse * - * @package RakutenRws + * @package Rakuten\WebService */ -abstract class RakutenRws_ApiResponse implements +abstract class ApiResponse implements IteratorAggregate, ArrayAccess { @@ -31,9 +40,9 @@ abstract class RakutenRws_ApiResponse implements * Constructor * * @param string $operation The operation - * @param RakutenRws_HttpResponse $response + * @param HttpResponse $response */ - public function __construct($operation, RakutenRws_HttpResponse $response) + public function __construct($operation, HttpResponse $response) { $this->operation = $operation; $this->httpResponse = $response; @@ -65,7 +74,7 @@ public function getOperation() /** * Gets the HttpResponse * - * @return RakutenRws_HttpResponse + * @return HttpResponse */ public function getHttpResponse() { diff --git a/lib/RakutenRws/ApiResponse/AppRakutenResponse.php b/src/ApiResponse/AppRakutenResponse.php similarity index 79% rename from lib/RakutenRws/ApiResponse/AppRakutenResponse.php rename to src/ApiResponse/AppRakutenResponse.php index 9b3e532..43108a9 100644 --- a/lib/RakutenRws/ApiResponse/AppRakutenResponse.php +++ b/src/ApiResponse/AppRakutenResponse.php @@ -9,13 +9,18 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\ApiResponse; + +use Rakuten\WebService\ApiResponse; +use Rakuten\WebService\Exception; + /** * API Response for app.rakuten.co.jp * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage ApiResponse */ -class RakutenRws_ApiResponse_AppRakutenResponse extends RakutenRws_ApiResponse +class AppRakutenResponse extends ApiResponse { protected function handleResponse() { @@ -32,7 +37,7 @@ protected function handleResponse() if (null === $rawData) { - throw new RakutenRws_Exception(); + throw new Exception(); } $this->data = $rawData; diff --git a/lib/RakutenRws/Client.php b/src/Client.php similarity index 75% rename from lib/RakutenRws/Client.php rename to src/Client.php index a3d499d..1b4ad77 100644 --- a/lib/RakutenRws/Client.php +++ b/src/Client.php @@ -9,39 +9,77 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService; + +use LogicException; +use Rakuten\WebService\Api\AppRakutenApi; +use Rakuten\WebService\HttpClient\BasicHttpClient; +use Rakuten\WebService\HttpClient\CurlHttpClient; +use Rakuten\WebService\HttpClient\PearHttpClient; + /** * Rakuten Web Service Client * - * @package RakutenRws + * @package Rakuten\WebService */ -class RakutenRws_Client +class Client { - const VERSION = '1.1.1-dev'; - - protected - $developerId = null, - $secret = null, - $accessToken = null, - $accessTokenInfo = null, - $redirectUrl = null, - $httpClient = null, - $affiliateId = null, - $options = array(); + const VERSION = '2.0.0-dev'; + + /** + * @var string + */ + protected $developerId = null; + + /** + * @var string + */ + protected $secret = null; + + /** + * @var string + */ + protected $accessToken = null; + + /** + * @var string + */ + protected $accessTokenInfo = null; + + /** + * @var string + */ + protected $redirectUrl = null; + + /** + * @var HttpClient + */ + protected $httpClient = null; + + /** + * @var string + */ + protected $affiliateId = null; + + /** + * @var array + */ + protected $options = array(); /** * Constructor. * - * @param RakutenRws_HttpClient $httpClient HTTP Client instance - * @throws RakutenRws_Exception + * @param HttpClient $httpClient HTTP Client instance + * @throws Exception * * option parameter * - keys */ - public function __construct(RakutenRws_HttpClient $httpClient = null, $options = array()) + public function __construct(HttpClient $httpClient = null, $options = array()) { if (!extension_loaded('openssl')) { // @codeCoverageIgnoreStart - throw new RakutenRws_Exception('openssl extension is not loaded.'); + throw new Exception('openssl extension is not loaded.'); // @codeCoverageIgnoreEnd } @@ -49,15 +87,11 @@ public function __construct(RakutenRws_HttpClient $httpClient = null, $options = // @codeCoverageIgnoreStart if (function_exists('curl_init')) { - $httpClient = new RakutenRws_HttpClient_CurlHttpClient(); + $httpClient = new CurlHttpClient(); } else if (version_compare(PHP_VERSION, '5.2.10') >= 0) { - $httpClient = new RakutenRws_HttpClient_BasicHttpClient(); + $httpClient = new BasicHttpClient(); } else { - if (!@include('HTTP/Client.php')) { - throw new RakutenRws_Exception('Failed to include Pear HTTP_Client'); - } - - $httpClient = new RakutenRws_HttpClient_PearHttpClient(); + $httpClient = new PearHttpClient(); } // @codeCoverageIgnoreEnd } @@ -213,7 +247,7 @@ public function getAccessToken() /** * Gets Http Client instance * - * @return RakutenRws_HttpClient The Http Client + * @return HttpClient The Http Client */ public function getHttpClient() { @@ -237,18 +271,19 @@ public function setProxy($proxy) * @param array $parameter The request parameter * @param string $version The API version * @throws LogicException - * @throws RakutenRws_Exception + * @throws Exception */ public function execute($operation, $parameter = array(), $version = null) { // remove '/' from operation $operation = preg_replace('/\//', '', $operation); - $className = 'RakutenRws_Api_Definition_'.$operation; + $className = 'Rakuten\\WebService\\Api\\Definition\\'.$operation; if (!class_exists($className)) { throw new LogicException('Operation is not definied.'); } + /** @var AppRakutenApi $api */ $api = new $className($this, $this->options); if ($version !== null) { $api->setVersion($version); diff --git a/lib/RakutenRws/Exception.php b/src/Exception.php similarity index 62% rename from lib/RakutenRws/Exception.php rename to src/Exception.php index 0127384..ec15539 100644 --- a/lib/RakutenRws/Exception.php +++ b/src/Exception.php @@ -9,11 +9,15 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService; + +use RuntimeException; + /** - * RakutenRws_Exception + * Exception * - * @package RakutenRws + * @package Rakuten\WebService */ -class RakutenRws_Exception extends RuntimeException +class Exception extends RuntimeException { } diff --git a/lib/RakutenRws/HttpClient.php b/src/HttpClient.php similarity index 85% rename from lib/RakutenRws/HttpClient.php rename to src/HttpClient.php index d774201..1aefe69 100644 --- a/lib/RakutenRws/HttpClient.php +++ b/src/HttpClient.php @@ -9,12 +9,14 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService; + /** - * RakutenRws_HttpClient + * Rakuten\WebService_HttpClient * - * @package RakutenRws + * @package Rakuten\WebService */ -abstract class RakutenRws_HttpClient +abstract class HttpClient { protected $proxy = null, diff --git a/lib/RakutenRws/HttpClient/BasicHttpClient.php b/src/HttpClient/BasicHttpClient.php similarity index 90% rename from lib/RakutenRws/HttpClient/BasicHttpClient.php rename to src/HttpClient/BasicHttpClient.php index 8ad3bf2..54f6234 100644 --- a/lib/RakutenRws/HttpClient/BasicHttpClient.php +++ b/src/HttpClient/BasicHttpClient.php @@ -9,14 +9,20 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\HttpClient; + +use Rakuten\WebService\Client; +use Rakuten\WebService\HttpClient; +use Rakuten\WebService\HttpResponse; + /** * Http Client that use file_get_contents() * This class is needed >= PHP5.2.10 * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage HttpClient */ -class RakutenRws_HttpClient_BasicHttpClient extends RakutenRws_HttpClient +class BasicHttpClient extends HttpClient { protected function getStreamContext($url, $params, $method = 'GET') { @@ -28,7 +34,7 @@ protected function getStreamContext($url, $params, $method = 'GET') ); $headers = array( - 'header' => 'User-Agent: RakutenWebService SDK for PHP-'.RakutenRws_Client::VERSION, + 'header' => 'User-Agent: RakutenWebService SDK for PHP-'.Client::VERSION, ); if ($method === 'POST') { @@ -85,7 +91,7 @@ public function get($url, $params = array()) $contents = @file_get_contents($requestUrl, false, $context); $headerInfo = $this->parseHeader($http_response_header); - return new RakutenRws_HttpResponse( + return new HttpResponse( $url, $params, $headerInfo['code'], @@ -100,7 +106,7 @@ public function post($url, $params = array()) $contents = @file_get_contents($url, false, $context); $headerInfo = $this->parseHeader($http_response_header); - return new RakutenRws_HttpResponse( + return new HttpResponse( $url, $params, $headerInfo['code'], diff --git a/lib/RakutenRws/HttpClient/CurlHttpClient.php b/src/HttpClient/CurlHttpClient.php similarity index 88% rename from lib/RakutenRws/HttpClient/CurlHttpClient.php rename to src/HttpClient/CurlHttpClient.php index 98aa583..155a361 100644 --- a/lib/RakutenRws/HttpClient/CurlHttpClient.php +++ b/src/HttpClient/CurlHttpClient.php @@ -9,13 +9,20 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService\HttpClient; + +use Rakuten\WebService\Client; +use Rakuten\WebService\Exception; +use Rakuten\WebService\HttpClient; +use Rakuten\WebService\HttpResponse; + /** * Http Client that use curl extension * - * @package RakutenRws + * @package Rakuten\WebService * @subpackage HttpClient */ -class RakutenRws_HttpClient_CurlHttpClient extends RakutenRws_HttpClient +class CurlHttpClient extends HttpClient { protected $curlOptions = array(); @@ -34,7 +41,7 @@ protected function getHandler() curl_setopt($ch, CURLOPT_PROXY, $this->proxy); } - curl_setopt($ch, CURLOPT_USERAGENT, 'RakutenWebService SDK for PHP-'.RakutenRws_Client::VERSION); + curl_setopt($ch, CURLOPT_USERAGENT, 'RakutenWebService SDK for PHP-'.Client::VERSION); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); @@ -50,7 +57,7 @@ protected function makeResponse($url, $params, $curl) if ($rawResponse === false) { $msg = curl_error($curl); - throw new RakutenRws_Exception('http reqeust error: '.$msg); + throw new Exception('http reqeust error: '.$msg); } $parts = preg_split('/((?:\\r?\\n){2})/', $rawResponse, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -79,7 +86,7 @@ protected function makeResponse($url, $params, $curl) $headers[] = $header; } - return new RakutenRws_HttpResponse( + return new HttpResponse( $url, $params, $code, diff --git a/lib/RakutenRws/HttpResponse.php b/src/HttpResponse.php similarity index 87% rename from lib/RakutenRws/HttpResponse.php rename to src/HttpResponse.php index d8767a4..2b24b75 100644 --- a/lib/RakutenRws/HttpResponse.php +++ b/src/HttpResponse.php @@ -9,12 +9,14 @@ * file that was distributed with source code. */ +namespace Rakuten\WebService; + /** - * RakutenRws_HttpResponse + * HttpResponse * - * @package RakutenRws + * @package Rakuten\WebService */ -class RakutenRws_HttpResponse +class HttpResponse { protected $requestUrl = null, diff --git a/test/RakutenRws/Api/AutoloaderTest.php b/test/RakutenRws/Api/AutoloaderTest.php deleted file mode 100644 index 12764a7..0000000 --- a/test/RakutenRws/Api/AutoloaderTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertTrue(class_exists('RakutenRws_Client')); - $this->assertFalse(class_exists('Foo')); - - $this->assertEquals(null, RakutenRws_Autoloader::autoload('Foo')); - } -} diff --git a/test/bootstrap.php b/test/bootstrap.php deleted file mode 100644 index f8ddda5..0000000 --- a/test/bootstrap.php +++ /dev/null @@ -1,7 +0,0 @@ -getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation1/19890108'; $param = array( 'access_token' => 'abc' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'Items' => array(array('Item' => 'data')) ))); @@ -30,10 +41,14 @@ public function testExecuteAppRakutenApi() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( 'getHttpClient', 'getAccessToken', - ), array(), 'rwsClient_for_'.__FUNCTION__); + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -43,7 +58,7 @@ public function testExecuteAppRakutenApi() ->method('getAccessToken') ->will($this->returnValue('abc')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($rwsClient); + $api = new DummyAppRakutenApi1($rwsClient); $response = $api->execute(array()); $this->assertEquals('DummyService', $api->getService()); @@ -54,16 +69,16 @@ public function testExecuteAppRakutenApi() $this->assertEquals(array(array('Item' => 'data')), $response['Items']); } - /** - * - * @test - */ public function testExecuteNonAuthorizedAppRakutenApi() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation2/19890108'; $param = array( @@ -71,7 +86,7 @@ public function testExecuteNonAuthorizedAppRakutenApi() 'affiliateId' => '456' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -83,11 +98,15 @@ public function testExecuteNonAuthorizedAppRakutenApi() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( - 'getHttpClient', - 'getApplicationId', - 'getAffiliateId' - ), array(), 'rwsClient_for_'.__FUNCTION__); + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( + 'getHttpClient', + 'getApplicationId', + 'getAffiliateId' + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -101,7 +120,7 @@ public function testExecuteNonAuthorizedAppRakutenApi() ->method('getAffiliateId') ->will($this->returnValue('456')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi2($rwsClient); + $api = new DummyAppRakutenApi2($rwsClient); $response = $api->execute(array()); $this->assertEquals('DummyService', $api->getService()); @@ -112,23 +131,23 @@ public function testExecuteNonAuthorizedAppRakutenApi() $this->assertEquals('the response', $response['data']); } - /** - * - * @test - */ public function testExecutePostAppRakutenApi() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation3/19890108'; $param = array( 'access_token' => 'abc' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -140,10 +159,14 @@ public function testExecutePostAppRakutenApi() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( - 'getHttpClient', - 'getAccessToken', - ), array(), 'rwsClient_for_'.__FUNCTION__); + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( + 'getHttpClient', + 'getAccessToken', + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -153,7 +176,7 @@ public function testExecutePostAppRakutenApi() ->method('getAccessToken') ->will($this->returnValue('abc')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi3($rwsClient); + $api = new DummyAppRakutenApi3($rwsClient); $response = $api->execute(array()); $this->assertEquals('DummyService', $api->getService()); @@ -164,64 +187,48 @@ public function testExecutePostAppRakutenApi() $this->assertEquals('the response', $response['data']); } - /** - * - * @test - */ public function testSetVersion() { - $clinet = new RakutenRws_Client(); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($clinet); + $client = new Client(); + $api = new DummyAppRakutenApi1($client); $api->setVersion('2012-01-08'); $this->assertEquals('2012-01-08', $api->getVersion()); } - /** - * - * @test - */ public function testSetVersionWithoutHyphen() { - $clinet = new RakutenRws_Client(); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($clinet); + $client = new Client(); + $api = new DummyAppRakutenApi1($client); $api->setVersion('20120108'); $this->assertEquals('2012-01-08', $api->getVersion()); } - /** - * - * @test - */ public function testSetVersionWithNumber() { - $clinet = new RakutenRws_Client(); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($clinet); + $client = new Client(); + $api = new DummyAppRakutenApi1($client); $api->setVersion(20120108); $this->assertEquals('2012-01-08', $api->getVersion()); } - /** - * - * @test - * @expectedException RakutenRws_Exception - */ public function testSetVersion_When_Sets_Wrong_Version() { - $clinet = new RakutenRws_Client(); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($clinet); + $this->expectException(Exception::class); + $client = new Client(); + $api = new DummyAppRakutenApi1($client); $api->setVersion('2020-01-08'); } - /** - * - * @test - */ public function testExecuteNonAuthorizedAppRakutenApi_With_callback() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation2/19890108'; $param = array( @@ -229,7 +236,7 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_callback() 'affiliateId' => '456' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -241,11 +248,15 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_callback() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( - 'getHttpClient', - 'getApplicationId', - 'getAffiliateId' - ), array(), 'rwsClient_for_'.__FUNCTION__); + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( + 'getHttpClient', + 'getApplicationId', + 'getAffiliateId' + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -259,7 +270,7 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_callback() ->method('getAffiliateId') ->will($this->returnValue('456')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi2($rwsClient); + $api = new DummyAppRakutenApi2($rwsClient); $response = $api->execute(array('callback' => 'it_will_be_deleted')); $this->assertEquals('DummyService', $api->getService()); @@ -270,16 +281,16 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_callback() $this->assertEquals('the response', $response['data']); } - /** - * - * @test - */ public function testExecuteNonAuthorizedAppRakutenApi_With_format() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation2/19890108'; $param = array( @@ -287,7 +298,7 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_format() 'affiliateId' => '456' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -299,11 +310,15 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_format() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( - 'getHttpClient', - 'getApplicationId', - 'getAffiliateId' - ), array(), 'rwsClient_for_'.__FUNCTION__); + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( + 'getHttpClient', + 'getApplicationId', + 'getAffiliateId' + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -317,7 +332,7 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_format() ->method('getAffiliateId') ->will($this->returnValue('456')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi2($rwsClient); + $api = new DummyAppRakutenApi2($rwsClient); $response = $api->execute(array('format' => 'it_will_be_deleted')); $this->assertEquals('DummyService', $api->getService()); @@ -328,24 +343,24 @@ public function testExecuteNonAuthorizedAppRakutenApi_With_format() $this->assertEquals('the response', $response['data']); } - /** - * - * @test - * @expectedException RakutenRws_Exception - */ public function testExecuteAppRakutenApi_with_BrokenData() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $this->expectException(Exception::class); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation1/19890108'; $param = array( 'access_token' => 'abc' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'Ooooooohhhhhhhh!!!!' ))); @@ -357,10 +372,14 @@ public function testExecuteAppRakutenApi_with_BrokenData() ) ->will($this->returnValue($httpResponse)); - $rwsClient = $this->getMock('RakutenRws_Client', array( - 'getHttpClient', - 'getAccessToken', - ), array(), 'rwsClient_for_'.__FUNCTION__); + $rwsClient = $this->getMockBuilder(Client::class) + ->setMethods(array( + 'getHttpClient', + 'getAccessToken', + )) + ->setConstructorArgs(array()) + ->setMockClassName('rwsClient_for_'.__FUNCTION__) + ->getMock(); $rwsClient->expects($this->once()) ->method('getHttpClient') @@ -370,7 +389,7 @@ public function testExecuteAppRakutenApi_with_BrokenData() ->method('getAccessToken') ->will($this->returnValue('abc')); - $api = new RakutenRws_Api_Definition_DummyAppRakutenApi1($rwsClient); + $api = new DummyAppRakutenApi1($rwsClient); $api->execute(array()); } } diff --git a/test/fixture/DummyAppRakutenApi1.php b/tests/Api/Definition/DummyAppRakutenApi1.php similarity index 71% rename from test/fixture/DummyAppRakutenApi1.php rename to tests/Api/Definition/DummyAppRakutenApi1.php index c807014..31d5e81 100644 --- a/test/fixture/DummyAppRakutenApi1.php +++ b/tests/Api/Definition/DummyAppRakutenApi1.php @@ -1,6 +1,10 @@ 'the data' ); - $httpResponse = new RakutenRws_HttpResponse( + $httpResponse = new HttpResponse( 'http://example.com', array(), 200, array(), json_encode($data) ); - $response = new RakutenRws_ApiResponse_AppRakutenResponse('operation', $httpResponse); + $response = new AppRakutenResponse('operation', $httpResponse); $response->setIterator(array('foo', 'bar')); @@ -31,7 +37,7 @@ public function test() { } public function testError() { - $httpResponse = new RakutenRws_HttpResponse( + $httpResponse = new HttpResponse( 'http://example.com', array(), 404, @@ -41,25 +47,22 @@ public function testError() { 'error_description' => 'not found' )) ); - $response = new RakutenRws_ApiResponse_AppRakutenResponse('operation', $httpResponse); + $response = new AppRakutenResponse('operation', $httpResponse); $this->assertFalse($response->isOk()); $this->assertEquals(404, $response->getCode()); $this->assertEquals('not_found: not found', $response->getMessage()); } - /** - * - * @expectedException RakutenRws_Exception - */ public function testBrokenData() { - $httpResponse = new RakutenRws_HttpResponse( + $this->expectException(Exception::class); + $httpResponse = new HttpResponse( 'http://example.com', array(), 404, array(), '' ); - new RakutenRws_ApiResponse_AppRakutenResponse('operation', $httpResponse); + new AppRakutenResponse('operation', $httpResponse); } } diff --git a/test/RakutenRws/ClientTest.php b/tests/ClientTest.php similarity index 51% rename from test/RakutenRws/ClientTest.php rename to tests/ClientTest.php index 40a4686..3a5dfa2 100644 --- a/test/RakutenRws/ClientTest.php +++ b/tests/ClientTest.php @@ -1,33 +1,35 @@ setApplicationId('123'); - $clinet->setSecret('foo-bar'); - $clinet->setRedirectUrl('http://example.com'); - $url = $clinet->getAuthorizeUrl('the_scope'); + $client->setApplicationId('123'); + $client->setSecret('foo-bar'); + $client->setRedirectUrl('http://example.com'); + $url = $client->getAuthorizeUrl('the_scope'); $this->assertEquals('https://app.rakuten.co.jp/services/authorize?response_type=code&client_id=123&redirect_uri=http%3A%2F%2Fexample.com&scope=the_scope', $url); } - /** - * - * @test - */ public function testfetchAccessTokenFromCode1() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'HttpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('HttpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/token'; $param = array( @@ -38,7 +40,7 @@ public function testfetchAccessTokenFromCode1() 'redirect_uri' => 'http://example.com' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'access_token' => 'abc', 'refresh_token' => 'def', 'token_type' => 'BEARER', @@ -54,26 +56,26 @@ public function testfetchAccessTokenFromCode1() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); + $client = new Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setSecret('foo-bar'); - $clinet->setRedirectUrl('http://example.com'); + $client->setApplicationId('123'); + $client->setSecret('foo-bar'); + $client->setRedirectUrl('http://example.com'); - $this->assertEquals('abc', $clinet->fetchAccessTokenFromCode('codecode')); - $this->assertEquals('abc', $clinet->getAccessToken()); + $this->assertEquals('abc', $client->fetchAccessTokenFromCode('codecode')); + $this->assertEquals('abc', $client->getAccessToken()); } - /** - * - * @test - */ public function testfetchAccessTokenFromCode2() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'HttpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('HttpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/token'; $param = array( @@ -84,7 +86,7 @@ public function testfetchAccessTokenFromCode2() 'redirect_uri' => 'http://example.com' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 401, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 401, array(), json_encode(array( 'error' => 'invalid_request', 'error_description' => 'invalid code' ))); @@ -97,25 +99,25 @@ public function testfetchAccessTokenFromCode2() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); + $client = new Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setSecret('foo-bar'); - $clinet->setRedirectUrl('http://example.com'); + $client->setApplicationId('123'); + $client->setSecret('foo-bar'); + $client->setRedirectUrl('http://example.com'); - $this->assertNull($clinet->fetchAccessTokenFromCode('codecode')); + $this->assertNull($client->fetchAccessTokenFromCode('codecode')); } - /** - * - * @Test - */ public function testfetchAccessTokenFromCode3() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'HttpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('HttpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/token'; $param = array( @@ -126,7 +128,7 @@ public function testfetchAccessTokenFromCode3() 'redirect_uri' => 'http://example.com' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'access_token' => 'abc', 'refresh_token' => 'def', 'token_type' => 'BEARER', @@ -142,39 +144,35 @@ public function testfetchAccessTokenFromCode3() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); + $client = new Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setSecret('foo-bar'); - $clinet->setRedirectUrl('http://example.com'); + $client->setApplicationId('123'); + $client->setSecret('foo-bar'); + $client->setRedirectUrl('http://example.com'); $_GET['code'] = 'codecode'; - $this->assertEquals('abc', $clinet->fetchAccessTokenFromCode()); - $this->assertEquals('abc', $clinet->getAccessToken()); + $this->assertEquals('abc', $client->fetchAccessTokenFromCode()); + $this->assertEquals('abc', $client->getAccessToken()); } - /** - * - * @test - * @expectedException LogicException - */ public function testfetchAccessTokenFromCode4_Error() { - $clinet = new RakutenRws_Client(); + $this->expectException(LogicException::class); + $client = new Client(); unset($_GET['code']); - $clinet->fetchAccessTokenFromCode(); + $client->fetchAccessTokenFromCode(); } - /** - * - * @test - */ public function testfetchAccessTokenFromCode5_BrokenData() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'HttpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('HttpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/token'; $param = array( @@ -185,7 +183,7 @@ public function testfetchAccessTokenFromCode5_BrokenData() 'redirect_uri' => 'http://example.com' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'error' => 'invalid_request', 'error_description' => 'invalid code' ))); @@ -198,37 +196,32 @@ public function testfetchAccessTokenFromCode5_BrokenData() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); + $client = new Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setSecret('foo-bar'); - $clinet->setRedirectUrl('http://example.com'); + $client->setApplicationId('123'); + $client->setSecret('foo-bar'); + $client->setRedirectUrl('http://example.com'); - $this->assertNull($clinet->fetchAccessTokenFromCode('codecode')); + $this->assertNull($client->fetchAccessTokenFromCode('codecode')); } - /** - * - * @test - */ public function testSetProxy() { - $clinet = new RakutenRws_Client(); - $clinet->setProxy('http://example.com'); - $this->assertEquals('http://example.com', $clinet->getHttpClient()->getProxy()); + $client = new Client(); + $client->setProxy('http://example.com'); + $this->assertEquals('http://example.com', $client->getHttpClient()->getProxy()); } - /** - * testExecute - * - * @test - */ public function testExecute() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation2/19890108'; $param = array( @@ -236,7 +229,7 @@ public function testExecute() 'affiliateId' => '456' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -248,24 +241,23 @@ public function testExecute() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setAffiliateId('456'); - $response = $clinet->execute('DummyAppRakutenApi2'); - $this->assertInstanceOf('RakutenRws_ApiResponse', $response); + $client = new Client($httpClient); + $client->setApplicationId('123'); + $client->setAffiliateId('456'); + $response = $client->execute('DummyAppRakutenApi2'); + $this->assertInstanceOf(ApiResponse::class, $response); } - /** - * testExecute - * - * @test - */ public function testExecuteWithOperationAlias() { - $httpClient = $this->getMock('RakutenRws_HttpClient', array( - 'post', - 'get' - ), array(), 'httpClient_for_'.__FUNCTION__); + $httpClient = $this->getMockBuilder(HttpClient::class) + ->setMethods(array( + 'post', + 'get' + )) + ->setConstructorArgs(array()) + ->setMockClassName('httpClient_for_'.__FUNCTION__) + ->getMock(); $url = 'https://app.rakuten.co.jp/services/api/DummyService/DummyOperation2/19890108'; $param = array( @@ -273,7 +265,7 @@ public function testExecuteWithOperationAlias() 'affiliateId' => '456' ); - $httpResponse = new RakutenRws_HttpResponse($url, $param, 200, array(), json_encode(array( + $httpResponse = new HttpResponse($url, $param, 200, array(), json_encode(array( 'data' => 'the response' ))); @@ -285,22 +277,18 @@ public function testExecuteWithOperationAlias() ) ->will($this->returnValue($httpResponse)); - $clinet = new RakutenRws_Client($httpClient); - $clinet->setApplicationId('123'); - $clinet->setAffiliateId('456'); - $response = $clinet->execute('DummyAppRakuten/Api2'); - $this->assertInstanceOf('RakutenRws_ApiResponse', $response); + $client = new Client($httpClient); + $client->setApplicationId('123'); + $client->setAffiliateId('456'); + $response = $client->execute('DummyAppRakuten/Api2'); + $this->assertInstanceOf(ApiResponse::class, $response); } - /** - * - * @test - * @expectedException LogicException - */ public function testExecute_with_WrongOperation() { - $clinet = new RakutenRws_Client(); + $this->expectException(LogicException::class); + $client = new Client(); - $clinet->execute('WrongOperation'); + $client->execute('WrongOperation'); } } diff --git a/test/RakutenRws/HttpRequestTest.php b/tests/HttpRequestTest.php similarity index 57% rename from test/RakutenRws/HttpRequestTest.php rename to tests/HttpRequestTest.php index 9984f9c..65e99c0 100644 --- a/test/RakutenRws/HttpRequestTest.php +++ b/tests/HttpRequestTest.php @@ -1,17 +1,22 @@ setProxy('http://example.com'); $this->assertEquals('http://example.com', $client->getProxy()); } public function testTimeout() { - $client = new RakutenRws_HttpClient_BasicHttpClient(); + $client = new BasicHttpClient(); $client->setTimeout(100); $this->assertEquals(100, $client->getTimeout()); } diff --git a/test/RakutenRws/HttpResponseTest.php b/tests/HttpResponseTest.php similarity index 79% rename from test/RakutenRws/HttpResponseTest.php rename to tests/HttpResponseTest.php index 1dee760..0b47510 100644 --- a/test/RakutenRws/HttpResponseTest.php +++ b/tests/HttpResponseTest.php @@ -1,10 +1,14 @@ 'value'), 200,