Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
feat: create group
Browse files Browse the repository at this point in the history
  • Loading branch information
Kresna Satya committed Apr 3, 2022
1 parent 508c41b commit b5970d4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,58 @@ public function findById($id)
return $result;
}

public function store($data)
{
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "{$this->getAdminRealmUrl()}/groups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$this->getToken(),
'Content-Type: application/json'
),
));

$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

return array($response, $httpcode);
}

public function delete($id)
{
$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "{$this->getAdminRealmUrl()}/groups/{$id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$this->getToken(),
'Content-Type: application/json'
),
));

$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

return array($response, $httpcode);
}

public function getRawAvailableRoles($group_id, $client_id)
{
$curl = curl_init();
Expand Down

0 comments on commit b5970d4

Please sign in to comment.