From 553167d108efe7503638a7513558373432ed12ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Preu=C3=9F?= Date: Mon, 2 Dec 2019 15:26:43 +0100 Subject: [PATCH] Fix user registration --- src/GhostZero/BitinflowAccounts/BitinflowAccounts.php | 5 +++-- src/GhostZero/BitinflowAccounts/Result.php | 8 ++++---- src/GhostZero/BitinflowAccounts/Traits/UsersTrait.php | 2 +- tests/GhostZero/BitinflowAccounts/ApiUsersTest.php | 5 ++++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/GhostZero/BitinflowAccounts/BitinflowAccounts.php b/src/GhostZero/BitinflowAccounts/BitinflowAccounts.php index 035bf0f..4954378 100644 --- a/src/GhostZero/BitinflowAccounts/BitinflowAccounts.php +++ b/src/GhostZero/BitinflowAccounts/BitinflowAccounts.php @@ -90,8 +90,9 @@ class BitinflowAccounts } /** - * @internal only for internal and debug purposes. * @param string $baseUrl + * + * @internal only for internal and debug purposes. */ public static function setBaseUrl(string $baseUrl): void { @@ -398,13 +399,13 @@ class BitinflowAccounts { $headers = [ 'Client-ID' => $this->getClientId(), + 'Accept' => 'application/json', ]; if ($this->token) { $headers['Authorization'] = 'Bearer ' . $this->token; } if ($json) { $headers['Content-Type'] = 'application/json'; - $headers['Accept'] = 'application/json'; } return $headers; diff --git a/src/GhostZero/BitinflowAccounts/Result.php b/src/GhostZero/BitinflowAccounts/Result.php index 37ed4d6..42c4679 100644 --- a/src/GhostZero/BitinflowAccounts/Result.php +++ b/src/GhostZero/BitinflowAccounts/Result.php @@ -6,7 +6,7 @@ namespace GhostZero\BitinflowAccounts; use Exception; use GhostZero\BitinflowAccounts\Helpers\Paginator; -use GuzzleHttp\Psr7\Response; +use Psr\Http\Message\ResponseInterface; use stdClass; @@ -60,7 +60,7 @@ class Result /** * Original Guzzle HTTP Response. - * @var Response|null + * @var ResponseInterface|null */ public $response; @@ -73,11 +73,11 @@ class Result /** * Constructor, * - * @param Response|null $response HTTP response + * @param ResponseInterface|null $response HTTP response * @param Exception|mixed $exception Exception, if present * @param null|Paginator $paginator Paginator, if present */ - public function __construct(?Response $response, Exception $exception = null, Paginator $paginator = null) + public function __construct(?ResponseInterface $response, Exception $exception = null, Paginator $paginator = null) { $this->response = $response; $this->success = $exception === null; diff --git a/src/GhostZero/BitinflowAccounts/Traits/UsersTrait.php b/src/GhostZero/BitinflowAccounts/Traits/UsersTrait.php index 56ddcb4..4556a8f 100644 --- a/src/GhostZero/BitinflowAccounts/Traits/UsersTrait.php +++ b/src/GhostZero/BitinflowAccounts/Traits/UsersTrait.php @@ -30,6 +30,6 @@ trait UsersTrait */ public function createUser(array $parameters): Result { - return $this->post('users', $parameters); + return $this->post('v2/users', $parameters); } } \ No newline at end of file diff --git a/tests/GhostZero/BitinflowAccounts/ApiUsersTest.php b/tests/GhostZero/BitinflowAccounts/ApiUsersTest.php index ff8a9ea..865fa50 100644 --- a/tests/GhostZero/BitinflowAccounts/ApiUsersTest.php +++ b/tests/GhostZero/BitinflowAccounts/ApiUsersTest.php @@ -17,6 +17,7 @@ class ApiUsersTest extends ApiTestCase { $this->getClient()->withToken($this->getToken()); $this->registerResult($result = $this->getClient()->getAuthedUser()); + $this->assertTrue($result->success()); $this->assertEquals('rene@preuss.io', $result->data()->email); } @@ -29,7 +30,9 @@ class ApiUsersTest extends ApiTestCase 'first_name' => 'René', 'last_name' => 'Preuß', 'email' => $testEmailAddress, - 'terms_accepted_at' => now()->toDateTimeString(), + 'password' => 'Password1', + 'password_confirmation' => 'Password1', + 'tos' => true, ])); $this->assertEquals($testEmailAddress, $result->data()->email); }