Skip to content

Commit

Permalink
Merge branch 'release/0.12.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed Nov 8, 2017
2 parents c762f6c + a161a3e commit 4dbb87c
Show file tree
Hide file tree
Showing 14 changed files with 473 additions and 19 deletions.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Steps to reproduce:
1.

## What should happen:
1.

## What happens:
1.

## Logs
- Logs

## Extra info:
- Tested on
19 changes: 14 additions & 5 deletions src/Context/ApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,24 @@ private function dropSessionContext()
*/
public function ensureSessionActive()
{
if (is_null($this->sessionContext)) {
return;
if (!$this->isSessionActive()) {
$this->resetSession();
}
}

/**
* @return bool
*/
public function isSessionActive(): bool
{
if (is_null($this->sessionContext)){
return false;
}

$timeExpiry = $this->sessionContext->getExpiryTime()->getTimestamp();
$timeToExpiry = $timeExpiry - time();

if ($timeExpiry - time() < self::TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS) {
$this->resetSession();
}
return $timeToExpiry > self::TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS;
}

/**
Expand Down
22 changes: 19 additions & 3 deletions src/Http/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Uri;
use phpDocumentor\Reflection\Types\Self_;
use Psr\Http\Message\ResponseInterface;

/**
*/
class ApiClient
{
/**
* Endpoints not requiring active session for the request to succeed.
*/
const URIS_NOT_REQUIRING_ACTIVE_SESSION = [
self::DEVICE_SERVER_URL => true,
self::INSTALLATION_URL => true,
self::SESSION_SERVER_URL => true,
];
const DEVICE_SERVER_URL = 'device-server';
const INSTALLATION_URL = 'installation';
const SESSION_SERVER_URL = 'session-server';

/**
* Error constants.
*/
Expand Down Expand Up @@ -166,7 +179,7 @@ private function request(
array $params,
array $customHeaders
): BunqResponseRaw {
$this->initialize();
$this->initialize($uri);

$response = $this->httpClient->request(
$method,
Expand All @@ -179,9 +192,12 @@ private function request(

/**
*/
private function initialize()
private function initialize(string $uri)
{
$this->apiContext->ensureSessionActive();
if (!isset(self::URIS_NOT_REQUIRING_ACTIVE_SESSION[$uri])) {
$this->apiContext->ensureSessionActive();
}

$this->initializeHttpClient();
}

Expand Down
17 changes: 17 additions & 0 deletions src/Model/Generated/Endpoint/BunqResponseCardGeneratedCvc2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace bunq\Model\Generated\Endpoint;

use bunq\Http\BunqResponse;

/**
*/
class BunqResponseCardGeneratedCvc2 extends BunqResponse
{
/**
* @return CardGeneratedCvc2
*/
public function getValue(): CardGeneratedCvc2
{
return parent::getValue();
}
}
17 changes: 17 additions & 0 deletions src/Model/Generated/Endpoint/BunqResponseCardGeneratedCvc2List.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace bunq\Model\Generated\Endpoint;

use bunq\Http\BunqResponse;

/**
*/
class BunqResponseCardGeneratedCvc2List extends BunqResponse
{
/**
* @return CardGeneratedCvc2[]
*/
public function getValue(): array
{
return parent::getValue();
}
}
25 changes: 25 additions & 0 deletions src/Model/Generated/Endpoint/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class Card extends BunqModel
*/
protected $publicUuid;

/**
* The type of the card. Can be MAESTRO, MASTERCARD.
*
* @var string
*/
protected $type;

/**
* The second line of text on the card
*
Expand Down Expand Up @@ -338,6 +345,24 @@ public function setPublicUuid($publicUuid)
$this->publicUuid = $publicUuid;
}

/**
* The type of the card. Can be MAESTRO, MASTERCARD.
*
* @return string
*/
public function getType()
{
return $this->type;
}

/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}

/**
* The second line of text on the card
*
Expand Down
25 changes: 25 additions & 0 deletions src/Model/Generated/Endpoint/CardDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class CardDebit extends BunqModel
*/
protected $publicUuid;

/**
* The type of the card. Can be MAESTRO, MASTERCARD.
*
* @var string
*/
protected $type;

/**
* The second line of text on the card
*
Expand Down Expand Up @@ -266,6 +273,24 @@ public function setPublicUuid($publicUuid)
$this->publicUuid = $publicUuid;
}

/**
* The type of the card. Can be MAESTRO, MASTERCARD.
*
* @return string
*/
public function getType()
{
return $this->type;
}

/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}

/**
* The second line of text on the card
*
Expand Down
Loading

0 comments on commit 4dbb87c

Please sign in to comment.