-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from auth0/1.x.x-dev
v1.0.7
- Loading branch information
Showing
12 changed files
with
306 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace Auth0\SDK\API; | ||
|
||
use Auth0\SDK\API\ApiClient; | ||
use Auth0\SDK\API\Header\Authorization\AuthorizationBearer; | ||
use Auth0\SDK\API\Header\ContentType; | ||
|
||
class ApiClients { | ||
|
||
protected static function getApiV2Client($domain) { | ||
|
||
$apiDomain = "https://$domain"; | ||
|
||
$client = new ApiClient(array( | ||
'domain' => $apiDomain, | ||
'basePath' => '/api/v2', | ||
)); | ||
return $client; | ||
} | ||
|
||
public static function getAll($domain, $token, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->clients() | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function get($domain, $token, $id, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->clients($id) | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function delete($domain, $token, $id) { | ||
|
||
$request = self::getApiV2Client($domain)->delete() | ||
->clients($id) | ||
->withHeader(new AuthorizationBearer($token)) | ||
->call(); | ||
} | ||
|
||
public static function create($domain, $token, $data) { | ||
|
||
$info = self::getApiV2Client($domain, $token)->post() | ||
->clients() | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function update($domain, $token, $data) { | ||
|
||
$info = self::getApiV2Client($domain)->patch() | ||
->clients() | ||
->withHeader(new AuthorizationBearer($token)) | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace Auth0\SDK\API; | ||
|
||
use Auth0\SDK\API\ApiClient; | ||
use Auth0\SDK\API\Header\Authorization\AuthorizationBearer; | ||
use Auth0\SDK\API\Header\ContentType; | ||
|
||
class ApiConnection { | ||
|
||
protected static function getApiV2Client($domain) { | ||
|
||
$apiDomain = "https://$domain"; | ||
|
||
$client = new ApiClient(array( | ||
'domain' => $apiDomain, | ||
'basePath' => '/api/v2', | ||
)); | ||
return $client; | ||
} | ||
|
||
public static function getAll($domain, $token, $strategy = null, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->connections() | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($strategy !== null) { | ||
$request->withParam('strategy', $strategy); | ||
} | ||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function get($domain, $token, $id, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->connections($id) | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function delete($domain, $token, $id) { | ||
|
||
$request = self::getApiV2Client($domain)->delete() | ||
->connections($id) | ||
->withHeader(new AuthorizationBearer($token)) | ||
->call(); | ||
} | ||
|
||
public static function create($domain, $token, $data) { | ||
|
||
$info = self::getApiV2Client($domain)->post() | ||
->connections() | ||
->withHeader(new AuthorizationBearer($token)) | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function update($domain, $token, $id, $data) { | ||
|
||
$info = self::getApiV2Client($domain)->patch() | ||
->connections($id) | ||
->withHeader(new AuthorizationBearer($token)) | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace Auth0\SDK\API; | ||
|
||
use Auth0\SDK\API\ApiClient; | ||
use Auth0\SDK\API\Header\Authorization\AuthorizationBearer; | ||
use Auth0\SDK\API\Header\ContentType; | ||
|
||
class ApiRules { | ||
|
||
protected static function getApiV2Client($domain) { | ||
|
||
$apiDomain = "https://$domain"; | ||
|
||
$client = new ApiClient(array( | ||
'domain' => $apiDomain, | ||
'basePath' => '/api/v2', | ||
)); | ||
return $client; | ||
} | ||
|
||
public static function getAll($domain, $token, $enabled = null, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->rules() | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($enabled !== null) { | ||
$request->withParam('enabled', $enabled); | ||
} | ||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function get($domain, $token, $id, $fields = null, $include_fields = null) { | ||
|
||
$request = self::getApiV2Client($domain)->get() | ||
->rules($id) | ||
->withHeader(new AuthorizationBearer($token)); | ||
|
||
if ($fields !== null) { | ||
if (is_array($fields)) { | ||
$fields = implode(',', $fields); | ||
} | ||
$request->withParam('fields', $fields); | ||
} | ||
if ($include_fields !== null) { | ||
$request->withParam('include_fields', $include_fields); | ||
} | ||
|
||
$info = $request->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function delete($domain, $token, $id) { | ||
|
||
$request = self::getApiV2Client($domain)->delete() | ||
->rules($id) | ||
->withHeader(new AuthorizationBearer($token)) | ||
->call(); | ||
} | ||
|
||
public static function create($domain, $token, $data) { | ||
|
||
$info = self::getApiV2Client($domain)->post() | ||
->rules() | ||
->withHeader(new AuthorizationBearer($token)) | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
public static function update($domain, $token, $id, $data) { | ||
|
||
$info = self::getApiV2Client($domain)->patch() | ||
->rules($id) | ||
->withHeader(new AuthorizationBearer($token)) | ||
->withHeader(new ContentType('application/json')) | ||
->withBody(json_encode($data)) | ||
->call(); | ||
|
||
return $info; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.