-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a draft commit and should not be merged without properly rebase.
- Loading branch information
Showing
43 changed files
with
1,115 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +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. | ||
* Retrieves Omise account info. | ||
* | ||
* @return Omise\Account | ||
*/ | ||
public static function retrieve() | ||
{ | ||
return parent::g_retrieve(get_class(), self::getUrl()); | ||
return parent::resourceRetrieve(); | ||
} | ||
|
||
/** | ||
* @see Omise\Res\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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +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. | ||
* Retrieves a current balance in the given account. | ||
* | ||
* @return Omise\Balance | ||
*/ | ||
public static function retrieve() | ||
{ | ||
return parent::g_retrieve(get_class(), self::getUrl()); | ||
return parent::resourceRetrieve(); | ||
} | ||
|
||
/** | ||
* @see Omise\Res\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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
namespace Omise; | ||
|
||
use Omise\Resource; | ||
|
||
class Collection implements \Countable | ||
{ | ||
/** | ||
* @var string Of a collection name. | ||
*/ | ||
protected $collection; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $attributes = array(); | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $items = array(); | ||
|
||
public function __construct($items) | ||
{ | ||
$this->mapAttribute($items); | ||
|
||
foreach ($items['data'] as $key => $value) { | ||
$this->items[$key] = Resource::newObject($value['object'], $value); | ||
} | ||
|
||
$this->collection = $this->first()['object']; | ||
} | ||
|
||
/** | ||
* @return Omise\Object In a first position of an array ($items). | ||
*/ | ||
public function first() | ||
{ | ||
return $this->items[0]; | ||
} | ||
|
||
/** | ||
* @implements \Countable | ||
* | ||
* @return int | ||
*/ | ||
public function count() | ||
{ | ||
return $this->attributes['total']; | ||
} | ||
|
||
protected function mapAttribute($items) | ||
{ | ||
$this->attributes = array( | ||
'from' => $items['from'], | ||
'to' => $items['to'], | ||
'offset' => $items['offset'], | ||
'limit' => $items['limit'], | ||
'total' => $items['total'], | ||
'order' => $items['order'], | ||
'location' => $items['location'], | ||
); | ||
} | ||
} |
Oops, something went wrong.