Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Rakuten PHP SDK PSR-4. #23

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 5.3
- 5.4
- 5.5
- 5.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.5 or earlier versions have reached EoL. those versions should be removed from supported versions of this package, I think.

- 7.0
- hhvm

matrix:
allow_failures:
- php: hhvm

sudo: false

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update --prefer-dist --no-interaction --prefer-stable

script: vendor/bin/phpunit
4 changes: 0 additions & 4 deletions autoload.php

This file was deleted.

29 changes: 23 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,41 @@
"license": "MIT",
"authors": [
{
"name": "Shogo Kawahara",
"email": "shogo.a.kawahara@mail.rakuten.com"
"name": "Andrew Miller",
"email": "andrew.miller@rakuten.com"
}
],
"require": {
"php": ">=5.2.3",
"php": ">=5.3.19",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.5 or earlier versions have reached EoL. the version range should be >= 5.6.0.

"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"pear-pear.php.net/HTTP_Client": "*"
},
"suggest": {
"ext-curl": "*",
"pear-pear/HTTP_Client": "*"
"pear-pear.php.net/HTTP_Client": "*"
},
"autoload": {
"psr-0": {"RakutenRws_": "lib/"}
"psr-4": {
"RakutenRws\\": "lib/RakutenRws/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Rws is short for Rakuten Web Service, RakutenRws is verbose.
RakutenWebService or RWS looks better to me. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Rakuten\WebService\ to keep things under a single Rakuten namespace?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

}
},
"autoload-dev": {
"psr-4": {
"RakutenRws\\": "test/RakutenRws/"
}
},
"repositories": [
{
"type": "pear",
"url": "https://pear.php.net"
}
],
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "2.0.x-dev"
}
}
}
4 changes: 3 additions & 1 deletion lib/RakutenRws/Api/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api;

/**
* The interface of API
*
* @package RakutenRws
* @subpackage Api
*/
interface RakutenRws_Api_ApiInterface
interface ApiInterface
{
public function getAvailableVersions();
public function getOperationName();
Expand Down
11 changes: 8 additions & 3 deletions lib/RakutenRws/Api/AppRakutenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api;

use RakutenRws\Exception;
use RakutenRws\ApiResponse\AppRakutenResponse;

/**
* API for app.rakuten.co.jp
*
* @package RakutenRws
* @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';

Expand Down Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions lib/RakutenRws/Api/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api;

use LogicException;
use RakutenRws\Client;
use RakutenRws\Exception;

/**
* API base class
*
* @package RakutenRws
* @subpackage Api
*/
abstract class RakutenRws_Api_Base implements RakutenRws_Api_ApiInterface
abstract class Base implements ApiInterface
{
protected
$version = null,
Expand All @@ -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;
Expand All @@ -38,7 +44,7 @@ public function getAvailableVersions()

public function getOperationName()
{
$className = explode('_', get_class($this));
$className = explode('\\', get_class($this));
return end($className);
}

Expand All @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/AuctionGenreIdSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* AuctionGenreIdSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_AuctionGenreIdSearch extends RakutenRws_Api_AppRakutenApi
class AuctionGenreIdSearch extends AppRakutenApi
{
protected
$isRequiredAccessToken = false,
Expand Down
11 changes: 8 additions & 3 deletions lib/RakutenRws/Api/Definition/AuctionGenreKeywordSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Exception;
use RakutenRws\Api\AppRakutenApi;

/**
* AuctionGenreKeywordSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_AuctionGenreKeywordSearch extends RakutenRws_Api_AppRakutenApi
class AuctionGenreKeywordSearch extends AppRakutenApi
{
protected
$isRequiredAccessToken = false,
Expand All @@ -40,7 +45,7 @@ public function execute($parameter)
if ($appresponse->isOk()) {
$data = $appresponse->getData();
if (!isset($data['auctionGenreList'])) {
throw new RakutenRws_Exception();
throw new Exception();
}

$appresponse->setIterator($data['auctionGenreList']);
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/AuctionItemCodeSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* AuctionItemCodeSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_AuctionItemCodeSearch extends RakutenRws_Api_AppRakutenApi
class AuctionItemCodeSearch extends AppRakutenApi
{
protected
$isRequiredAccessToken = false,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/AuctionItemSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* AuctionItemSearch2
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_AuctionItemSearch extends RakutenRws_Api_AppRakutenApi
class AuctionItemSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksBookSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksBookSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksBookSearch extends RakutenRws_Api_AppRakutenApi
class BooksBookSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksCDSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksCDSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksCDSearch extends RakutenRws_Api_AppRakutenApi
class BooksCDSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksDVDSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksDVDSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksDVDSearch extends RakutenRws_Api_AppRakutenApi
class BooksDVDSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksForeignBookSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksForeignBooksSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksForeignBookSearch extends RakutenRws_Api_AppRakutenApi
class BooksForeignBookSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksGameSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksGameSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksGameSearch extends RakutenRws_Api_AppRakutenApi
class BooksGameSearch extends AppRakutenApi
{
protected
$autoSetIterator = true,
Expand Down
8 changes: 6 additions & 2 deletions lib/RakutenRws/Api/Definition/BooksGenreSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* file that was distributed with source code.
*/

namespace RakutenRws\Api\Definition;

use RakutenRws\Api\AppRakutenApi;

/**
* BooksGenreSearch
*
* @package RakutenRws
* @subpackage Api_Definition
* @subpackage Api\Definition
*/
class RakutenRws_Api_Definition_BooksGenreSearch extends RakutenRws_Api_AppRakutenApi
class BooksGenreSearch extends AppRakutenApi
{
protected
$isRequiredAccessToken = false,
Expand Down
Loading