Skip to content

Commit

Permalink
Crankshaft[BU000001EE1CZ5] Client - PHP @ 2015-07-06 16:32:32 +0000
Browse files Browse the repository at this point in the history
9ad83f4 Pete Hamilton <[email protected]>
Handle nested arrays of non-objects

----------------

60a9bcc Pete Hamilton <[email protected]>
Use latest schema version

----------------

5c38c76 Pete Hamilton <[email protected]>
Updated Makefile

----------------
  • Loading branch information
Crankshaft Robot committed Jul 6, 2015
1 parent 8f70880 commit 5425ad4
Show file tree
Hide file tree
Showing 29 changed files with 121 additions and 254 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add this repository to the contents of your `composer.json`:
```javascript
{
"require": {
"gocardless/gocardless-pro-php": "0.2.0"
"gocardless/gocardless-pro-php": "0.3.0"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"squizlabs/php_codesniffer": "~2.0",
"phpdocumentor/phpdocumentor": "2.*"
},
"version": "0.2.0",
"version": "0.3.0",
"autoload": {
"psr-4": {
"GoCardlessPro\\" : "lib/GoCardlessPro"
Expand Down
17 changes: 2 additions & 15 deletions lib/GoCardlessPro/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,6 @@ public function events()
return $this->events;
}

/**
* Helpers
*
* @return Services\Helper
*/
public function helpers()
{
if (!isset($this->helpers)) {
$this->helpers = new Services\HelpersService($this->http_client);
}
return $this->helpers;
}

/**
* Mandates
*
Expand Down Expand Up @@ -336,10 +323,10 @@ public function refunds()
* - The first payment must be
* charged within 1 year.
* - When neither `month` nor `day_of_month` are
* present, the subscription will recur from the `start_at` based on the
* present, the subscription will recur from the `start_date` based on the
* `interval_unit`.
* - If `month` or `day_of_month` are present, the
* recurrence rules will be applied from the `start_at`, and the following
* recurrence rules will be applied from the `start_date`, and the following
* validations apply:
*
* | interval_unit | month
Expand Down
4 changes: 2 additions & 2 deletions lib/GoCardlessPro/Core/CurlWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/0.2.0';
$uagent[] = 'gocardless-pro-php/0.3.0';
$uagent[] = 'php/' . phpversion();
$uagent[] = 'curl/' . $curlinfo['version'];
$uagent[] = 'os/' . $curlinfo['host'];
$uagent[] = 'schema-version/2015-04-29';
$uagent[] = 'schema-version/2015-07-06';
return implode(' ', $uagent);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/GoCardlessPro/Core/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function __construct($token, $baseUrl, $options = array())
$this->headers['accept'] = 'application/json';

// Config Headers
$this->headers['GoCardless-Version'] = '2015-04-29';
$this->headers['GoCardless-Version'] = '2015-04-29';
$this->headers['GoCardless-Version'] = '2015-07-06';
$this->headers['GoCardless-Version'] = '2015-07-06';

}

Expand Down
28 changes: 0 additions & 28 deletions lib/GoCardlessPro/Resources/Helper.php

This file was deleted.

24 changes: 12 additions & 12 deletions lib/GoCardlessPro/Resources/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
* - The first payment must be charged within 1
* year.
* - When neither `month` nor `day_of_month` are present, the
* subscription will recur from the `start_at` based on the `interval_unit`.
* * - If `month` or `day_of_month` are present, the recurrence rules will be
* applied from the `start_at`, and the following validations apply:
* subscription will recur from the `start_date` based on the `interval_unit`.
* * - If `month` or `day_of_month` are present, the recurrence rules will be
* applied from the `start_date`, and the following validations apply:
*
* |
* interval_unit | month |
*
* | interval_unit | month |
* day_of_month |
* | :-------------- |
* :--------------------------------------------- |
Expand Down Expand Up @@ -95,8 +95,8 @@ public function amount()
}

/**
* An alternative way to set `end_at`. The total number of payments that
* should be taken by this subscription. This will set `end_at`
* An alternative way to set `end_date`. The total number of payments that
* should be taken by this subscription. This will set `end_date`
* automatically.
*
* @return int
Expand Down Expand Up @@ -163,9 +163,9 @@ public function day_of_month()
*
* @return string
*/
public function end_at()
public function end_date()
{
$field = 'end_at';
$field = 'end_date';
if (!property_exists($this->data, $field)) {
return null;
}
Expand Down Expand Up @@ -301,9 +301,9 @@ public function payment_reference()
*
* @return string
*/
public function start_at()
public function start_date()
{
$field = 'start_at';
$field = 'start_date';
if (!property_exists($this->data, $field)) {
return null;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/GoCardlessPro/Resources/Wrapper/NestedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public function raw()
{
$arrayOut = $this->data;
foreach ($arrayOut as $key => $data_element) {
$arrayOut[$key] = $data_element->raw();
if (is_object($data_element) && (($data_element instanceof NestedArray) || ($data_element instanceof NestedObject))) {
$arrayOut[$key] = $data_element->raw();
} else {
$arrayOut[$key] = $data_element;
}
}
return $arrayOut;
}
Expand Down
113 changes: 0 additions & 113 deletions lib/GoCardlessPro/Services/HelpersService.php

This file was deleted.

11 changes: 0 additions & 11 deletions lib/GoCardlessPro/Services/MandatesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ public function do_list($params = array(), $headers = array())
* Get a single mandate
*
* Retrieves the details of an existing mandate.
*
* If you
* specify `Accept: application/pdf` on a request to this endpoint it will
* return a PDF complying to the relevant scheme rules, which you can
* present to your customer.
*
* PDF mandates can be retrieved in
* Dutch, English, French, German, Italian, Portuguese and Spanish by
* specifying the [ISO
* 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes#Partial_ISO_639_table)
* language code as an `Accept-Language` header.
*
* Example URL: /mandates/:identity
*
Expand Down
4 changes: 2 additions & 2 deletions lib/GoCardlessPro/Services/SubscriptionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
* - The first payment must be charged
* within 1 year.
* - When neither `month` nor `day_of_month` are present,
* the subscription will recur from the `start_at` based on the
* the subscription will recur from the `start_date` based on the
* `interval_unit`.
* - If `month` or `day_of_month` are present, the
* recurrence rules will be applied from the `start_at`, and the following
* recurrence rules will be applied from the `start_date`, and the following
* validations apply:
*
* | interval_unit | month
Expand Down
2 changes: 1 addition & 1 deletion tests/GoCardlessPro/Core/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testIncludedDefaultHeaders()
{
$defaultHeaders = $this->http_client->headers();
// Config Headers
$this->assertEquals('2015-04-29', $defaultHeaders['GoCardless-Version']);
$this->assertEquals('2015-07-06', $defaultHeaders['GoCardless-Version']);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ public function testResourceExists()
$obj = new \GoCardlessPro\Resources\BankDetailsLookup(null);
$this->assertNotNull($obj);
}

public function testBankDetailsLookupsCreate()
{
$fixture = $this->stubResponse('create');

$func_array = array_values((array) $fixture->url_params);
$resourceService = $this->client->bank_details_lookups();
$response = call_user_func_array(array($resourceService, 'create'), $func_array);

$body = $fixture->body->bank_details_lookups;


$this->assertInstanceOf('\GoCardlessPro\Resources\BankDetailsLookup', $response);

$this->matchDeepResponse($body->available_debit_schemes, $response->available_debit_schemes());
$this->matchDeepResponse($body->bank_name, $response->bank_name());


$this->assertTrue($this->hasCheckedCurl);
}
}
21 changes: 0 additions & 21 deletions tests/GoCardlessPro/Integration/HelperIntegrationTest.php

This file was deleted.

20 changes: 20 additions & 0 deletions tests/GoCardlessPro/Integration/MandatePdfIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ public function testResourceExists()
$obj = new \GoCardlessPro\Resources\MandatePdf(null);
$this->assertNotNull($obj);
}

public function testMandatePdfsCreate()
{
$fixture = $this->stubResponse('create');

$func_array = array_values((array) $fixture->url_params);
$resourceService = $this->client->mandate_pdfs();
$response = call_user_func_array(array($resourceService, 'create'), $func_array);

$body = $fixture->body->mandate_pdfs;


$this->assertInstanceOf('\GoCardlessPro\Resources\MandatePdf', $response);

$this->matchDeepResponse($body->expires_at, $response->expires_at());
$this->matchDeepResponse($body->url, $response->url());


$this->assertTrue($this->hasCheckedCurl);
}
}
Loading

0 comments on commit 5425ad4

Please sign in to comment.