Skip to content

Commit

Permalink
Changes generated by aa4cbec30e45d359738061e94d8d43a65bb90767
Browse files Browse the repository at this point in the history
This commit was automatically created from gocardless/gocardless-pro-php-template@aa4cbec
by the `push-files` action.

Workflow run: https://github.com/gocardless/gocardless-pro-php-template/actions/runs/10176820043
  • Loading branch information
gocardless-ci-robot[bot] committed Jul 31, 2024
1 parent 72c6ceb commit 411c463
Show file tree
Hide file tree
Showing 31 changed files with 338 additions and 70 deletions.
15 changes: 15 additions & 0 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public function __construct($config)

$this->services['events'] = new Services\EventsService($this->api_client);

$this->services['exports'] = new Services\ExportsService($this->api_client);

$this->services['instalment_schedules'] = new Services\InstalmentSchedulesService($this->api_client);

$this->services['institutions'] = new Services\InstitutionsService($this->api_client);
Expand Down Expand Up @@ -314,6 +316,19 @@ public function events()
return $this->services['events'];
}

/**
* Service for interacting with exports
*
* @return Services\ExportsService
*/
public function exports()
{
if (!isset($this->services['exports'])) {
throw new \Exception('Key exports does not exist in services array');
}
return $this->services['exports'];
}

/**
* Service for interacting with instalment schedule
*
Expand Down
50 changes: 50 additions & 0 deletions lib/Resources/Export.php
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;

}
95 changes: 95 additions & 0 deletions lib/Services/ExportsService.php
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);
}

}
93 changes: 93 additions & 0 deletions tests/Integration/ExportsIntegrationTest.php
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());
}


}
4 changes: 2 additions & 2 deletions tests/fixtures/bank_authorisations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"method": "POST",
"path_template": "/bank_authorisations",
"url_params": {},
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-07-26T16:10:31.340Z","expires_at":"2024-07-26T16:10:31.340Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 8081","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-07-31T08:32:25.607Z","expires_at":"2024-07-31T08:32:25.607Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
},
"get": {
"method": "GET",
"path_template": "/bank_authorisations/:identity",
"url_params": {"identity": "BAU123"},
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-07-26T16:10:31.340Z","expires_at":"2024-07-26T16:10:31.340Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
"body": {"bank_authorisations":{"authorisation_type":"example authorisation_type 7887","authorised_at":"2020-01-01T12:00:00.000Z","created_at":"2024-07-31T08:32:25.607Z","expires_at":"2024-07-31T08:32:25.607Z","id":"BAU123","last_visited_at":"2020-01-01T12:00:00.000Z","links":{"billing_request":"BRQ123","institution":"monzo"},"qr_code_url":"https://pay.gocardless.com/obauth/BAU123/qr_code","redirect_uri":"https://my-website.com/abc/callback","url":"https://pay.gocardless.com/obauth/BAU123"}}
}
}

4 changes: 2 additions & 2 deletions tests/fixtures/billing_request_flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"method": "POST",
"path_template": "/billing_request_flows",
"url_params": {},
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-07-26T16:10:31.345Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-07-26T16:10:31.345Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":true,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":true}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-07-31T08:32:25.611Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-07-31T08:32:25.611Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":false,"lock_customer_details":false,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":false}}
},
"initialise": {
"method": "POST",
"path_template": "/billing_request_flows/:identity/actions/initialise",
"url_params": {"identity": "BRF123"},
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-07-26T16:10:31.345Z","customer_details_captured":true,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-07-26T16:10:31.345Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":false,"lock_currency":true,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":true}}
"body": {"billing_request_flows":{"authorisation_url":"https://monzo.com/abc-123-things","auto_fulfil":true,"created_at":"2024-07-31T08:32:25.611Z","customer_details_captured":false,"exit_uri":"https://my-website.com/abc/callback","expires_at":"2024-07-31T08:32:25.611Z","id":"BRF123","language":"en","links":{"billing_request":"BRQ123"},"lock_bank_account":true,"lock_currency":true,"lock_customer_details":true,"prefilled_bank_account":{"account_type":"savings"},"prefilled_customer":{"address_line1":"221B Baker Street","address_line2":"Marylebone","address_line3":"City of Westminster","city":"London","company_name":"Hamilton Trading Ltd.","country_code":"GB","danish_identity_number":"220550-6218","email":"[email protected]","family_name":"Osborne","given_name":"Frank","postal_code":"NW1 6XE","region":"Greater London","swedish_identity_number":"556564-5404"},"redirect_uri":"https://my-website.com/abc/callback","session_token":"sesh_123","show_redirect_buttons":true,"show_success_redirect_button":true}}
}
}

Loading

0 comments on commit 411c463

Please sign in to comment.