Skip to content

Commit

Permalink
Refactor about options
Browse files Browse the repository at this point in the history
  • Loading branch information
shimonhaga committed Dec 15, 2022
1 parent cfd6016 commit 2f9fecc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"minimum-stability": "dev",
"prefer-stable": true,
"version": "0.0.10",
"version": "0.0.11",
"license": "MIT",
"authors": [
{
Expand Down
4 changes: 2 additions & 2 deletions src/Communicator/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class Request
{
private Options $_options;
private RequestOptions $_options;
private Client $_client;

public function __construct(?Options $options = new Options)
public function __construct(?RequestOptions $options = new RequestOptions)
{
$this->_options = $options;
$this->_client = new Client();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Shimoning\ColorMeShopApi\Communicator;

class Options
class RequestOptions
{
private float $_timeout = 0;
private float $_connectTimeout = 0;
Expand Down
13 changes: 5 additions & 8 deletions src/Services/OAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
namespace Shimoning\ColorMeShopApi\Services;

use Shimoning\ColorMeShopApi\Communicator\Request;
use Shimoning\ColorMeShopApi\Communicator\Options as RequestOption;
use Shimoning\ColorMeShopApi\Entities\OAuth\Options;
use Shimoning\ColorMeShopApi\Communicator\RequestOptions;
use Shimoning\ColorMeShopApi\Entities\OAuth\Options as OAuthOptions;
use Shimoning\ColorMeShopApi\Entities\OAuth\AccessToken;
use Shimoning\ColorMeShopApi\Values\Scopes;

class OAuth
{
private Options $_options;
private OAuthOptions $_options;

/**
* @param Options $options
*/
public function __construct(Options $options)
public function __construct(OAuthOptions $options)
{
$this->_options = $options;
}
Expand Down Expand Up @@ -44,7 +41,7 @@ public function getOAuthUrl(Scopes $scopes): string
*/
public function exchangeCode2Token(string $code): AccessToken|bool
{
$response = (new Request(new RequestOption(['form' => true])))->post(
$response = (new Request(new RequestOptions(['form' => true])))->post(
$this->_options->getEndpointUri() . '/token',
[
'client_id' => $this->_options->getClientId(),
Expand Down
14 changes: 7 additions & 7 deletions src/Services/Sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use DateTimeInterface;
use Shimoning\ColorMeShopApi\Communicator\Request;
use Shimoning\ColorMeShopApi\Communicator\Options as RequestOption;
use Shimoning\ColorMeShopApi\Communicator\RequestOptions;
use Shimoning\ColorMeShopApi\Communicator\Errors;
use Shimoning\ColorMeShopApi\Entities\Sales\SearchParameters;
use Shimoning\ColorMeShopApi\Entities\Sales\Sale;
Expand Down Expand Up @@ -34,7 +34,7 @@ public function page(
SearchParameters $searchParameters,
?string $accessToken = null,
): Page|Errors {
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
])))->get(
'https://api.shop-pro.jp/v1/sales',
Expand All @@ -59,7 +59,7 @@ public function page(
*/
public function one(int|string $id, ?string $accessToken = null): Sale|Errors
{
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
])))->get(
'https://api.shop-pro.jp/v1/sales/' . $id,
Expand All @@ -82,7 +82,7 @@ public function stat(
DateTimeInterface $dateTime,
?string $accessToken = null,
): Stat|Errors {
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
])))->get(
'https://api.shop-pro.jp/v1/sales/stat?',
Expand All @@ -107,7 +107,7 @@ public function update(
SaleUpdater $updater,
?string $accessToken = null,
): Sale|Errors {
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
'json' => true,
])))->put(
Expand Down Expand Up @@ -135,7 +135,7 @@ public function cancel(
?bool $restock = false,
?string $accessToken = null,
): Sale|Errors {
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
'json' => true,
])))->put(
Expand Down Expand Up @@ -163,7 +163,7 @@ public function sendMail(
MailType $mailType,
?string $accessToken = null,
): bool|Errors {
$response = (new Request(new RequestOption([
$response = (new Request(new RequestOptions([
'authorization' => $accessToken ?? $this->_accessToken,
'json' => true,
])))->post(
Expand Down

0 comments on commit 2f9fecc

Please sign in to comment.