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

[WIP] v3.0.0 Overview Design (for brainstorming only, all inputs are welcomed) #117

Closed
wants to merge 4 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
33 changes: 8 additions & 25 deletions lib/Account.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
<?php
namespace Omise;

use Omise\Res\OmiseApiResource;

class Account extends OmiseApiResource
class Account extends \Omise\ApiResource
{
const ENDPOINT = 'account';
const OBJECT_NAME = 'account';

/**
* Retrieves an account.
*
* @param string $publickey
* @param string $secretkey
* Retrieves Omise account info.
*
* @return OmiseAccount
* @return Omise\Account
*/
public static function retrieve($publickey = null, $secretkey = null)
public static function retrieve()
{
return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
return parent::resourceRetrieve();
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_reload()
* @see Omise\ApiResource::resourceReload()
*/
public function reload()
{
parent::g_reload(self::getUrl());
}

/**
* @param string $id
*
* @return string
*/
private static function getUrl($id = '')
{
return \Omise\ApiRequestor::OMISE_API_URL . self::ENDPOINT . '/' . $id;
parent::resourceReload();
}
}
33 changes: 8 additions & 25 deletions lib/Balance.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
<?php
namespace Omise;

use Omise\Res\OmiseApiResource;

class Balance extends OmiseApiResource
class Balance extends \Omise\ApiResource
{
const ENDPOINT = 'balance';
const OBJECT_NAME = 'balance';

/**
* Retrieves a current balance in the account.
*
* @param string $publickey
* @param string $secretkey
* Retrieves a current balance in the given account.
*
* @return OmiseBalance
* @return Omise\Balance
*/
public static function retrieve($publickey = null, $secretkey = null)
public static function retrieve()
{
return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
return parent::resourceRetrieve();
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_reload()
* @see Omise\ApiResource::resourceReload()
*/
public function reload()
{
parent::g_reload(self::getUrl());
}

/**
* @param string $id
*
* @return string
*/
private static function getUrl($id = '')
{
return \Omise\ApiRequestor::OMISE_API_URL . self::ENDPOINT . '/' . $id;
parent::resourceReload();
}
}
41 changes: 13 additions & 28 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
namespace Omise;

use Omise\Res\OmiseApiResource;
use Omise\ApiResource;

class Capabilities extends OmiseApiResource
class Capabilities extends ApiResource
{
const ENDPOINT = 'capability';
const OBJECT_NAME = 'capability';

/**
* @var array of the filterable keys.
Expand All @@ -14,9 +14,9 @@ class Capabilities extends OmiseApiResource
'backend' => ['currency', 'type', 'chargeAmount']
];

protected function __construct($publickey = null, $secretkey = null)
public function __construct()
{
parent::__construct($publickey, $secretkey);
parent::__construct();
$this->setupFilterShortcuts();
}

Expand Down Expand Up @@ -44,31 +44,26 @@ protected function setupFilterShortcuts()
/**
* Retrieves capabilities.
*
* @param string $publickey
* @param string $secretkey
*
* @return OmiseCapabilities
* @return Omise\Capabilities
*/
public static function retrieve($publickey = null, $secretkey = null)
public static function retrieve()
{
return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
return parent::resourceRetrieve();
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_reload()
* @see Omise\ApiResource::resourceReload()
*/
public function reload()
{
parent::g_reload(self::getUrl());
parent::resourceReload();
}

/**
* Retrieves array of payment backends. Optionally pass in as many filter functions as you want
* (muliple arguments, or a single array)
*
* @param [func1,fun2,...] OR func1, func2,...
* @param [func1,fun2,...] OR func1, func2,...
*
* @return array
*/
Expand Down Expand Up @@ -170,18 +165,8 @@ private static function argsToVariadic($argArray)
/**
* @return string
*/
private static function getUrl()
{
return \Omise\ApiRequestor::OMISE_API_URL . self::ENDPOINT;
}

/**
* Returns the public key.
*
* @return string
*/
protected function getResourceKey()
protected function credential()
{
return $this->_publickey;
return 'pkey_test_5fcnkn4378pmguq5zpy';
}
}
22 changes: 6 additions & 16 deletions lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,41 @@ class Card extends OmiseApiResource
*
* @param array $array
* @param string $customerID
* @param string $publickey
* @param string $secretkey
*/
public function __construct($array, $customerID, $publickey = null, $secretkey = null)
public function __construct($array, $customerID)
{
parent::__construct($publickey, $secretkey);
parent::__construct();

$this->_customerID = $customerID;
$this->refresh($array);
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_reload()
* @see Omise\Res\OmiseApiResource::g_reload()
*/
public function reload()
{
parent::g_reload($this->getUrl($this['id']));
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_update()
* @see Omise\Res\OmiseApiResource::g_update()
*/
public function update($params)
{
parent::g_update($this->getUrl($this['id']), $params);
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::g_destroy()
* @see Omise\Res\OmiseApiResource::g_destroy()
*/
public function destroy()
{
parent::g_destroy($this->getUrl($this['id']));
}

/**
* (non-PHPdoc)
*
* @see OmiseApiResource::isDestroyed()
* @see Omise\Res\OmiseApiResource::isDestroyed()
*/
public function isDestroyed()
{
Expand Down
10 changes: 4 additions & 6 deletions lib/CardList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ class CardList extends OmiseApiResource
/**
* @param array $cards
* @param string $customerID
* @param string $publickey
* @param string $secretkey
*/
public function __construct($cards, $customerID, $publickey = null, $secretkey = null)
public function __construct($cards, $customerID)
{
parent::__construct($publickey, $secretkey);
parent::__construct();
$this->_customerID = $customerID;
$this->refresh($cards);
}
Expand All @@ -28,13 +26,13 @@ public function __construct($cards, $customerID, $publickey = null, $secretkey =
*
* @param string $id
*
* @return OmiseCard
* @return Omise\Card
*/
public function retrieve($id)
{
$result = $this->apiRequestor->get($this->getUrl($id), self::getResourceKey());

return new Card($result, $this->_customerID, $this->_publickey, $this->_secretkey);
return new Card($result, $this->_customerID);
}


Expand Down
Loading