mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-15 22:45:52 +00:00
change namespace and cleanup code
This commit is contained in:
50
src/Accounts/Traits/UsersTrait.php
Normal file
50
src/Accounts/Traits/UsersTrait.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Bitinflow\Accounts\Traits;
|
||||
|
||||
use Bitinflow\Accounts\ApiOperations\Get;
|
||||
use Bitinflow\Accounts\Result;
|
||||
|
||||
trait UsersTrait
|
||||
{
|
||||
|
||||
use Get;
|
||||
|
||||
/**
|
||||
* Get currently authed user with Bearer Token
|
||||
*
|
||||
* @return Result Result object
|
||||
*/
|
||||
public function getAuthedUser(): Result
|
||||
{
|
||||
return $this->get('users/me');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new user on behalf of the current user.
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function createUser(array $parameters): Result
|
||||
{
|
||||
return $this->post('v2/users', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given email exists.
|
||||
*
|
||||
* @param string $email
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function isEmailExisting(string $email): Result
|
||||
{
|
||||
return $this->post('v2/users/check-email', [
|
||||
'email' => $email,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user