Skip to content

Commit

Permalink
Merge pull request #15 from auth0/1.x.x-dev
Browse files Browse the repository at this point in the history
Updates the changed endpoints (tickets)
  • Loading branch information
glena committed Jun 2, 2015
2 parents 45f7718 + dde1770 commit 8c4a943
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/API/ApiUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,16 @@ public static function deleteMultifactorProvider($domain, $token, $user_id, $mul

public static function createEmailVerificationTicket($domain, $token, $user_id, $result_url = null) {

$body = array('user_id' => $user_id);
if ($result_url !== null) {
$body['result_url'] = $result_url;
}

$request = self::getApiV2Client($domain)->post()
->users($user_id)
->tickets()
->email_verification()
->withHeader(new AuthorizationBearer($token));
->addPath('email-verification')
->withHeader(new AuthorizationBearer($token))
->withBody(json_encode($body));

if ($result_url) {
$body = json_encode(array(
Expand All @@ -151,6 +156,7 @@ public static function createEmailVerificationTicket($domain, $token, $user_id,
public static function createPasswordChangeTicket($domain, $token, $user_id, $new_password, $result_url = null) {

$body = array(
'user_id' => $user_id,
'new_password' => $new_password
);

Expand All @@ -159,9 +165,8 @@ public static function createPasswordChangeTicket($domain, $token, $user_id, $ne
}

return self::getApiV2Client($domain)->post()
->users($user_id)
->tickets()
->email_verification()
->addPath('password-change')
->withHeader(new AuthorizationBearer($token))
->withBody(json_encode($body))
->call();
Expand Down
14 changes: 12 additions & 2 deletions src/API/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ public function __construct( $config ) {

public function __call($name, $arguments) {

$this->path[] = $name;
$argument = null;

if (count($arguments) > 0) {
$this->path[] = $arguments[0];
$argument = $arguments[0];
}

$this->addPath($name, $argument);

return $this;
}

public function addPath($name, $argument = null) {
$this->path[] = $name;
if ($argument !== null) {
$this->path[] = $argument;
}
return $this;
}

Expand Down

0 comments on commit 8c4a943

Please sign in to comment.