Files
cloudflare-php/src/Endpoints/User.php
Darin Randal cca073c809 Code cleanup / Quality of Life updates
Adapter::get, post, put, patch and delete all had non-optional parameters for $headers and $query or $body. These have been made optional. I also re-ordered the parameters as $headers was never used while $query/$body were heavily used. I also condensed and removed some duplicate calls so that every call to Adapter::get/post sends that call to Adapter::request. It could use a magic method to do this but it might make it more difficult to test.
2018-04-12 23:11:04 -04:00

44 lines
862 B
PHP

<?php
/**
* User: junade
* Date: 01/02/2017
* Time: 12:30
*/
namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter;
class User implements API
{
private $adapter;
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
}
public function getUserDetails(): \stdClass
{
$user = $this->adapter->get('user');
$body = json_decode($user->getBody());
return $body->result;
}
public function getUserID(): string
{
return $this->getUserDetails()->id;
}
public function getUserEmail(): string
{
return $this->getUserDetails()->email;
}
public function updateUserDetails(array $details): \stdClass
{
$response = $this->adapter->patch('user', $details);
return json_decode($response->getBody());
}
}