Fix user registration

This commit is contained in:
René Preuß
2019-12-02 15:26:43 +01:00
parent 918bcd4644
commit 553167d108
4 changed files with 12 additions and 8 deletions

View File

@@ -90,8 +90,9 @@ class BitinflowAccounts
} }
/** /**
* @internal only for internal and debug purposes.
* @param string $baseUrl * @param string $baseUrl
*
* @internal only for internal and debug purposes.
*/ */
public static function setBaseUrl(string $baseUrl): void public static function setBaseUrl(string $baseUrl): void
{ {
@@ -398,13 +399,13 @@ class BitinflowAccounts
{ {
$headers = [ $headers = [
'Client-ID' => $this->getClientId(), 'Client-ID' => $this->getClientId(),
'Accept' => 'application/json',
]; ];
if ($this->token) { if ($this->token) {
$headers['Authorization'] = 'Bearer ' . $this->token; $headers['Authorization'] = 'Bearer ' . $this->token;
} }
if ($json) { if ($json) {
$headers['Content-Type'] = 'application/json'; $headers['Content-Type'] = 'application/json';
$headers['Accept'] = 'application/json';
} }
return $headers; return $headers;

View File

@@ -6,7 +6,7 @@ namespace GhostZero\BitinflowAccounts;
use Exception; use Exception;
use GhostZero\BitinflowAccounts\Helpers\Paginator; use GhostZero\BitinflowAccounts\Helpers\Paginator;
use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface;
use stdClass; use stdClass;
@@ -60,7 +60,7 @@ class Result
/** /**
* Original Guzzle HTTP Response. * Original Guzzle HTTP Response.
* @var Response|null * @var ResponseInterface|null
*/ */
public $response; public $response;
@@ -73,11 +73,11 @@ class Result
/** /**
* Constructor, * Constructor,
* *
* @param Response|null $response HTTP response * @param ResponseInterface|null $response HTTP response
* @param Exception|mixed $exception Exception, if present * @param Exception|mixed $exception Exception, if present
* @param null|Paginator $paginator Paginator, 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->response = $response;
$this->success = $exception === null; $this->success = $exception === null;

View File

@@ -30,6 +30,6 @@ trait UsersTrait
*/ */
public function createUser(array $parameters): Result public function createUser(array $parameters): Result
{ {
return $this->post('users', $parameters); return $this->post('v2/users', $parameters);
} }
} }

View File

@@ -17,6 +17,7 @@ class ApiUsersTest extends ApiTestCase
{ {
$this->getClient()->withToken($this->getToken()); $this->getClient()->withToken($this->getToken());
$this->registerResult($result = $this->getClient()->getAuthedUser()); $this->registerResult($result = $this->getClient()->getAuthedUser());
$this->assertTrue($result->success());
$this->assertEquals('rene@preuss.io', $result->data()->email); $this->assertEquals('rene@preuss.io', $result->data()->email);
} }
@@ -29,7 +30,9 @@ class ApiUsersTest extends ApiTestCase
'first_name' => 'René', 'first_name' => 'René',
'last_name' => 'Preuß', 'last_name' => 'Preuß',
'email' => $testEmailAddress, 'email' => $testEmailAddress,
'terms_accepted_at' => now()->toDateTimeString(), 'password' => 'Password1',
'password_confirmation' => 'Password1',
'tos' => true,
])); ]));
$this->assertEquals($testEmailAddress, $result->data()->email); $this->assertEquals($testEmailAddress, $result->data()->email);
} }