Add Account Member Creation (#192)

We can now create account members threough the SDK
This commit is contained in:
Phil Young
2021-10-01 01:19:15 +01:00
committed by GitHub
parent 7f72427fa1
commit bf796b9ec8
3 changed files with 140 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Cloudflare\API\Endpoints;
use Cloudflare\API\Adapter\Adapter;
use Cloudflare\API\Traits\BodyAccessorTrait;
class AccountMembers implements API
{
use BodyAccessorTrait;
/**
* @var Adapter
*/
private $adapter;
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
}
public function addAccountMember(string $accountId, string $email, array $roles): \stdClass
{
$options = [
'email' => $email,
'roles' => $roles,
];
$account = $this->adapter->post('accounts/' . $accountId . '/members', $options);
$this->body = json_decode($account->getBody());
return $this->body->result;
}
}