Skip to content

Commit

Permalink
Merge pull request #124 from bunq/refresh_user_context_bunq/sdk_php#122
Browse files Browse the repository at this point in the history
Refresh user context #122
  • Loading branch information
OGKevin authored Apr 6, 2018
2 parents a188cf4 + 98e12a4 commit 585d394
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Context/UserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace bunq\Context;

use bunq\Exception\BunqException;
use bunq\Model\Core\BunqModel;
use bunq\Model\Core\SessionServer;
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
use bunq\Model\Generated\Endpoint\User;
Expand Down Expand Up @@ -53,12 +54,18 @@ class UserContext
*/
public function __construct(int $userId)
{
$userObject = User::listing()->getValue()[self::INDEX_FIRST]->getReferencedObject();

$this->setUser($userObject);
$this->setUser($this->getUserObject());
$this->userId = $userId;
}

/**
* @return BunqModel
*/
private function getUserObject(): BunqModel
{
return User::listing()->getValue()[self::INDEX_FIRST]->getReferencedObject();
}

/**
* @param $user
*
Expand Down Expand Up @@ -163,4 +170,11 @@ public function getPrimaryMonetaryAccount(): MonetaryAccountBank
return $this->primaryMonetaryAccount;
}

/**
*/
public function refreshUserContext()
{
$this->setUser($this->getUserObject());
$this->initMainMonetaryAccount();
}
}

0 comments on commit 585d394

Please sign in to comment.