Skip to content

Commit

Permalink
Merge pull request #26 from auth0/1.x.x-dev
Browse files Browse the repository at this point in the history
v1.0.7
  • Loading branch information
glena committed Jul 17, 2015
2 parents 301f983 + 517422b commit 9630ca1
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 13 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Modify your `composer.json` to add the following dependencies and run `composer
{
"require": {
"auth0/auth0-php": "~1.0",
"adoy/oauth2": "dev-master",
"firebase/php-jwt" : "dev-master"
"adoy/oauth2": "dev-master"
}
}
~~~
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"guzzlehttp/guzzle": "~5.0",
"ext-json": "*",
"adoy/oauth2": "dev-master",
"firebase/php-jwt" : "dev-master"
"firebase/php-jwt" : "~2.2"
},
"require-dev": {
"phpunit/phpunit": "4.6.*"
Expand All @@ -30,4 +30,4 @@
}
},
"license": "MIT"
}
}
1 change: 0 additions & 1 deletion examples/basic-api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"description": "Basic sample for securing an API",
"require": {
"bramus/router": "dev-master",
"firebase/php-jwt": "dev-master",
"adoy/oauth2": "dev-master",
"vlucas/phpdotenv": "1.1.1",
"auth0/auth0-php": "~1.0"
Expand Down
1 change: 0 additions & 1 deletion examples/basic-oauth/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "auth0/basic-webapp-sample",
"description": "Basic sample for securing a WebApp with Auth0",
"require": {
"firebase/php-jwt": "dev-master",
"adoy/oauth2": "dev-master",
"vlucas/phpdotenv": "1.1.1",
"auth0/auth0-php": "~1.0"
Expand Down
1 change: 0 additions & 1 deletion examples/basic-webapp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "auth0/basic-webapp-sample",
"description": "Basic sample for securing a WebApp with Auth0",
"require": {
"firebase/php-jwt": "dev-master",
"adoy/oauth2": "dev-master",
"vlucas/phpdotenv": "1.1.1",
"auth0/auth0-php": "~1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/API/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Auth0\SDK\API\Header\Header;

class ApiClient {
const API_VERSION = "1.0.3";

const API_VERSION = "1.0.7";

protected static $infoHeadersDataEnabled = true;
protected static $infoHeadersData;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function __call($name, $arguments) {
'method' => $name,
'path' => array( $this->basePath ),
));

return $builder->withHeaders($this->headers);
}

Expand Down
95 changes: 95 additions & 0 deletions src/API/ApiClients.php
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;
}

}
99 changes: 99 additions & 0 deletions src/API/ApiConnections.php
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;
}

}
99 changes: 99 additions & 0 deletions src/API/ApiRules.php
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;
}

}
3 changes: 2 additions & 1 deletion src/API/ApiUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ protected static function getApiV2Client($domain) {

$apiDomain = "https://$domain";

return new ApiClient(array(
$client = new ApiClient(array(
'domain' => $apiDomain,
'basePath' => '/api/v2',
));
return $client;
}

public static function get($domain, $token, $user_id) {
Expand Down
Loading

0 comments on commit 9630ca1

Please sign in to comment.