-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from gocardless/template-changes
Changes from gocardless/gocardless-pro-php-template
- Loading branch information
Showing
37 changed files
with
367 additions
and
83 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
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
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,50 @@ | ||
<?php | ||
/** | ||
* WARNING: Do not edit by hand, this file was generated by Crank: | ||
* | ||
* https://github.com/gocardless/crank | ||
*/ | ||
|
||
namespace GoCardlessPro\Resources; | ||
|
||
/** | ||
* A thin wrapper around a export, providing access to its | ||
* attributes | ||
* | ||
* @property-read $created_at | ||
* @property-read $currency | ||
* @property-read $download_url | ||
* @property-read $export_type | ||
* @property-read $id | ||
*/ | ||
class Export extends BaseResource | ||
{ | ||
protected $model_name = "Export"; | ||
|
||
/** | ||
* Fixed [timestamp](#api-usage-time-zones--dates), recording when this | ||
* resource was created. | ||
*/ | ||
protected $created_at; | ||
|
||
/** | ||
* The currency of the export (if applicable) | ||
*/ | ||
protected $currency; | ||
|
||
/** | ||
* Download url for the export file. Subject to expiry. | ||
*/ | ||
protected $download_url; | ||
|
||
/** | ||
* The type of the export | ||
*/ | ||
protected $export_type; | ||
|
||
/** | ||
* Unique identifier, beginning with "EX". | ||
*/ | ||
protected $id; | ||
|
||
} |
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,95 @@ | ||
<?php | ||
/** | ||
* WARNING: Do not edit by hand, this file was generated by Crank: | ||
* | ||
* https://github.com/gocardless/crank | ||
*/ | ||
|
||
namespace GoCardlessPro\Services; | ||
|
||
use \GoCardlessPro\Core\Paginator; | ||
use \GoCardlessPro\Core\Util; | ||
use \GoCardlessPro\Core\ListResponse; | ||
use \GoCardlessPro\Resources\Export; | ||
use \GoCardlessPro\Core\Exception\InvalidStateException; | ||
|
||
|
||
/** | ||
* Service that provides access to the Export | ||
* endpoints of the API | ||
* | ||
* @method get() | ||
* @method list() | ||
*/ | ||
class ExportsService extends BaseService | ||
{ | ||
|
||
protected $envelope_key = 'exports'; | ||
protected $resource_class = '\GoCardlessPro\Resources\Export'; | ||
|
||
|
||
/** | ||
* Get a single export | ||
* | ||
* Example URL: /exports/:identity | ||
* | ||
* @param string $identity Unique identifier, beginning with "EX". | ||
* @param string[mixed] $params An associative array for any params | ||
* @return Export | ||
**/ | ||
public function get($identity, $params = array()) | ||
{ | ||
$path = Util::subUrl( | ||
'/exports/:identity', | ||
array( | ||
|
||
'identity' => $identity | ||
) | ||
); | ||
if(isset($params['params'])) { $params['query'] = $params['params']; | ||
unset($params['params']); | ||
} | ||
|
||
|
||
$response = $this->api_client->get($path, $params); | ||
|
||
|
||
return $this->getResourceForResponse($response); | ||
} | ||
|
||
/** | ||
* List exports | ||
* | ||
* Example URL: /exports | ||
* | ||
* @param string[mixed] $params An associative array for any params | ||
* @return ListResponse | ||
**/ | ||
protected function _doList($params = array()) | ||
{ | ||
$path = "/exports"; | ||
if(isset($params['params'])) { $params['query'] = $params['params']; | ||
unset($params['params']); | ||
} | ||
|
||
|
||
$response = $this->api_client->get($path, $params); | ||
|
||
|
||
return $this->getResourceForResponse($response); | ||
} | ||
|
||
/** | ||
* List exports | ||
* | ||
* Example URL: /exports | ||
* | ||
* @param string[mixed] $params | ||
* @return Paginator | ||
**/ | ||
public function all($params = array()) | ||
{ | ||
return new Paginator($this, $params); | ||
} | ||
|
||
} |
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,93 @@ | ||
<?php | ||
// | ||
// WARNING: Do not edit by hand, this file was generated by Crank: | ||
// https://github.com/gocardless/crank | ||
// | ||
|
||
namespace GoCardlessPro\Integration; | ||
|
||
class ExportsIntegrationTest extends IntegrationTestBase | ||
{ | ||
public function testResourceModelExists() | ||
{ | ||
$obj = new \GoCardlessPro\Resources\Export(array()); | ||
$this->assertNotNull($obj); | ||
} | ||
|
||
public function testExportsGet() | ||
{ | ||
$fixture = $this->loadJsonFixture('exports')->get; | ||
$this->stub_request($fixture); | ||
|
||
$service = $this->client->exports(); | ||
$response = call_user_func_array(array($service, 'get'), (array)$fixture->url_params); | ||
|
||
$body = $fixture->body->exports; | ||
|
||
$this->assertInstanceOf('\GoCardlessPro\Resources\Export', $response); | ||
|
||
$this->assertEquals($body->created_at, $response->created_at); | ||
$this->assertEquals($body->currency, $response->currency); | ||
$this->assertEquals($body->download_url, $response->download_url); | ||
$this->assertEquals($body->export_type, $response->export_type); | ||
$this->assertEquals($body->id, $response->id); | ||
|
||
|
||
$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture); | ||
$dispatchedRequest = $this->history[0]['request']; | ||
$this->assertMatchesRegularExpression($expectedPathRegex, $dispatchedRequest->getUri()->getPath()); | ||
} | ||
|
||
|
||
public function testExportsList() | ||
{ | ||
$fixture = $this->loadJsonFixture('exports')->list; | ||
$this->stub_request($fixture); | ||
|
||
$service = $this->client->exports(); | ||
$response = call_user_func_array(array($service, 'list'), (array)$fixture->url_params); | ||
|
||
$body = $fixture->body->exports; | ||
|
||
$records = $response->records; | ||
$this->assertInstanceOf('\GoCardlessPro\Core\ListResponse', $response); | ||
$this->assertInstanceOf('\GoCardlessPro\Resources\Export', $records[0]); | ||
if (!is_null($fixture->body) && property_exists($fixture->body, 'meta') && !is_null($fixture->body->meta)) { | ||
$this->assertEquals($fixture->body->meta->cursors->before, $response->before); | ||
$this->assertEquals($fixture->body->meta->cursors->after, $response->after); | ||
} | ||
|
||
|
||
|
||
foreach (range(0, count($body) - 1) as $num) { | ||
$record = $records[$num]; | ||
|
||
if (isset($body[$num]->created_at)) { | ||
$this->assertEquals($body[$num]->created_at, $record->created_at); | ||
} | ||
|
||
if (isset($body[$num]->currency)) { | ||
$this->assertEquals($body[$num]->currency, $record->currency); | ||
} | ||
|
||
if (isset($body[$num]->download_url)) { | ||
$this->assertEquals($body[$num]->download_url, $record->download_url); | ||
} | ||
|
||
if (isset($body[$num]->export_type)) { | ||
$this->assertEquals($body[$num]->export_type, $record->export_type); | ||
} | ||
|
||
if (isset($body[$num]->id)) { | ||
$this->assertEquals($body[$num]->id, $record->id); | ||
} | ||
|
||
} | ||
|
||
$expectedPathRegex = $this->extract_resource_fixture_path_regex($fixture); | ||
$dispatchedRequest = $this->history[0]['request']; | ||
$this->assertMatchesRegularExpression($expectedPathRegex, $dispatchedRequest->getUri()->getPath()); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.