From dde1770951189f8165639eab15dfe0ed1f147864 Mon Sep 17 00:00:00 2001 From: German Lena Date: Tue, 2 Jun 2015 11:52:34 -0300 Subject: [PATCH] Updates the changed endpoints (tickets) --- src/API/ApiUsers.php | 15 ++++++++++----- src/API/RequestBuilder.php | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/API/ApiUsers.php b/src/API/ApiUsers.php index 10724658..a3e98d90 100644 --- a/src/API/ApiUsers.php +++ b/src/API/ApiUsers.php @@ -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( @@ -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 ); @@ -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(); diff --git a/src/API/RequestBuilder.php b/src/API/RequestBuilder.php index f0a562cd..9015401f 100644 --- a/src/API/RequestBuilder.php +++ b/src/API/RequestBuilder.php @@ -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; }