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

Changes from gocardless/gocardless-pro-php-template #190

Merged
merged 14 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
21527a2
Changes generated by da47f93c8f7c6727449bb4c10ef1585f13b6d0b6
gocardless-ci-robot[bot] May 30, 2024
146fa89
Changes generated by b3495bc9d2f6dc762e72d4fb2c20458772367a4f
gocardless-ci-robot[bot] May 30, 2024
025be15
Changes generated by 668f6f6068dcf3e1234b0834f39c370a11fb3888
gocardless-ci-robot[bot] Jun 5, 2024
d7b06b7
Changes generated by 4c8ee1fb21af18eedb462337614f9f551a13bd0c
gocardless-ci-robot[bot] Jun 10, 2024
dee1a77
Changes generated by c4e38dff6b14f33a766b66f253919d6bf93ca531
gocardless-ci-robot[bot] Jun 25, 2024
efcf299
Changes generated by 98efbc4ace29ee6fa008cd0f7e31145f29e05648
gocardless-ci-robot[bot] Jun 27, 2024
c6205d6
Changes generated by 52253f0d71614992e11b52e025ef682beb40c012
gocardless-ci-robot[bot] Jul 12, 2024
c9dccd8
Changes generated by 3db66f8876ea00b71ed7818f8e61872a9a984dbe
gocardless-ci-robot[bot] Jul 17, 2024
f18fa96
Changes generated by b1fabf6d7e49ab4588c6b726b8dc0ecbf69431a5
gocardless-ci-robot[bot] Jul 18, 2024
fb30d58
Changes generated by 2e92f201f55a17cf6100e6d145186a0ca57e2f99
gocardless-ci-robot[bot] Jul 23, 2024
72c6ceb
Changes generated by 2948b36d38b64b1992024967dd9db6cfa1aef4f6
gocardless-ci-robot[bot] Jul 26, 2024
411c463
Changes generated by aa4cbec30e45d359738061e94d8d43a65bb90767
gocardless-ci-robot[bot] Jul 31, 2024
18f3bdb
Changes generated by 9e29f374f322cb42e13232df3654665b41803595
gocardless-ci-robot[bot] Aug 2, 2024
c48d9a9
Changes generated by 693b95aa81539b3ac79ba4c6cc18ecbac9660cee
gocardless-ci-robot[bot] Aug 5, 2024
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gocardless/gocardless-pro",
"description": "GoCardless Pro PHP Client Library",
"version": "5.9.0",
"version": "5.10.0",
"keywords": [
"gocardless",
"direct debit",
Expand Down
19 changes: 17 additions & 2 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($config)
'Content-Type' => 'application/json',
'Authorization' => "Bearer " . $access_token,
'GoCardless-Client-Library' => 'gocardless-pro-php',
'GoCardless-Client-Version' => '5.9.0',
'GoCardless-Client-Version' => '5.10.0',
'User-Agent' => $this->getUserAgent()
),
'http_errors' => false,
Expand Down 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 Expand Up @@ -649,7 +664,7 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/5.9.0';
$uagent[] = 'gocardless-pro-php/5.10.0';
$uagent[] = 'schema-version/2015-07-06';
if (defined('\GuzzleHttp\Client::MAJOR_VERSION')) {
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::MAJOR_VERSION;
Expand Down
10 changes: 5 additions & 5 deletions lib/Resources/BillingRequestTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class BillingRequestTemplate extends BaseResource
/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency
* code. `GBP` and `EUR` supported; `GBP` with your customers in the UK and
* for `EUR` with your customers in Germany only.
* for `EUR` with your customers in supported Eurozone countries only.
*/
protected $payment_request_currency;

Expand All @@ -147,10 +147,10 @@ class BillingRequestTemplate extends BaseResource
/**
* (Optional) A scheme used for Open Banking payments. Currently
* `faster_payments` is supported in the UK (GBP) and `sepa_credit_transfer`
* and `sepa_instant_credit_transfer` are supported in Germany (EUR). In
* Germany, `sepa_credit_transfer` is used as the default. Please be aware
* that `sepa_instant_credit_transfer` may incur an additional fee for your
* customer.
* and `sepa_instant_credit_transfer` are supported in supported Eurozone
* countries (EUR). For Eurozone countries, `sepa_credit_transfer` is used
* as the default. Please be aware that `sepa_instant_credit_transfer` may
* incur an additional fee for your customer.
*/
protected $payment_request_scheme;

Expand Down
8 changes: 3 additions & 5 deletions lib/Resources/CustomerBankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class CustomerBankAccount extends BaseResource
protected $model_name = "CustomerBankAccount";

/**
* Name of the account holder, as known by the bank. Usually this is the
* same as the name stored with the linked
* [creditor](#core-endpoints-creditors). This field will be transliterated,
* upcased and truncated to 18 characters. This field is required unless the
* request includes a [customer bank account
* Name of the account holder, as known by the bank. This field will be
* transliterated, upcased and truncated to 18 characters. This field is
* required unless the request includes a [customer bank account
* token](#javascript-flow-customer-bank-account-tokens).
*/
protected $account_holder_name;
Expand Down
1 change: 1 addition & 0 deletions lib/Resources/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Event extends BaseResource
* <ul>
* <li>`billing_requests`</li>
* <li>`creditors`</li>
* <li>`exports`</li>
* <li>`instalment_schedules`</li>
* <li>`mandates`</li>
* <li>`payer_authorisations`</li>
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;

}
6 changes: 6 additions & 0 deletions lib/Resources/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @property-read $metadata
* @property-read $month
* @property-read $name
* @property-read $parent_plan_paused
* @property-read $payment_reference
* @property-read $retry_if_possible
* @property-read $start_date
Expand Down Expand Up @@ -135,6 +136,11 @@ class Subscription extends BaseResource
*/
protected $name;

/**
* Whether the parent plan of this subscription is paused.
*/
protected $parent_plan_paused;

/**
* An optional payment reference. This will be set as the reference on each
* payment
Expand Down
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());
}


}
Loading
Loading