Skip to content

Commit 1b665d1

Browse files
authored
Merge pull request #214 from weakish/changePhoneNumber
feat(User): requestChangePhoneNumber & changePhoneNumber
2 parents 750ccf7 + 8440ad3 commit 1b665d1

11 files changed

+897
-692
lines changed

Changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
0.13.0 Released on 2020-07-15
3+
----
4+
5+
- Add `requestChangePhoneNumber` & `changePhoneNumber` to *verify* mobile number before updating it.
6+
- Add `_messageUpdate` hook.
7+
- Add `setApiTimeout` to specify request timeout.
8+
29
0.12.0 发布日期:2020-04-21
310
----
411

Hacking.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@
2323
make test_engine &
2424
make test
2525
```
26+
27+
Run one single test:
28+
29+
```sh
30+
vendor/bin/phpunit --filter testInitializeWithString test/QueryTest.php
31+
```
2632

27-
* `make doc` to build documentation (should running on PHP < 7.2)
33+
* `make doc` to build documentation.
34+
The make task uses PHP 5.6, to install it on recent versions of macOS,
35+
see https://github.com/eXolnet/homebrew-deprecated/pull/25
2836

2937
* Send a pull request at leancloud/php-sdk
3038

docs/class-LeanCloud.Client.html

Lines changed: 63 additions & 26 deletions
Large diffs are not rendered by default.

docs/class-LeanCloud.User.html

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ <h1>Class User</h1>
171171
<b>Namespace:</b> <a href="namespace-LeanCloud.html">LeanCloud</a><br>
172172

173173

174-
<b>Located at</b> <a href="source-class-LeanCloud.User.html#9-568" title="Go to source code">LeanCloud/User.php</a>
174+
<b>Located at</b> <a href="source-class-LeanCloud.User.html#9-593" title="Go to source code">LeanCloud/User.php</a>
175175
<br>
176176
</div>
177177

@@ -1368,7 +1368,42 @@ <h4>Parameters</h4>
13681368
</div>
13691369
</div></td>
13701370
</tr>
1371-
<tr data-order="signUpOrLoginByMobilePhone" id="_signUpOrLoginByMobilePhone">
1371+
<tr data-order="requestChangePhoneNumber" id="_requestChangePhoneNumber">
1372+
1373+
<td class="attributes"><code>
1374+
public static
1375+
1376+
1377+
1378+
</code>
1379+
</td>
1380+
1381+
<td class="name"><div>
1382+
<a class="anchor" href="#_requestChangePhoneNumber">#</a>
1383+
<code><a href="source-class-LeanCloud.User.html#470-479" title="Go to source code">requestChangePhoneNumber</a>( <span>string <var>$phoneNumber</var></span> )</code>
1384+
1385+
<div class="description short">
1386+
<p>Request mobile phone verify before updating it.</p>
1387+
</div>
1388+
1389+
<div class="description detailed hidden">
1390+
<p>Request mobile phone verify before updating it.</p>
1391+
1392+
1393+
<h4>Parameters</h4>
1394+
<div class="list"><dl>
1395+
<dt><var>$phoneNumber</var></dt>
1396+
<dd></dd>
1397+
</dl></div>
1398+
1399+
1400+
1401+
1402+
1403+
</div>
1404+
</div></td>
1405+
</tr>
1406+
<tr data-order="changePhoneNumber" id="_changePhoneNumber">
13721407

13731408
<td class="attributes"><code>
13741409
public static
@@ -1378,9 +1413,46 @@ <h4>Parameters</h4>
13781413
</code>
13791414
</td>
13801415

1416+
<td class="name"><div>
1417+
<a class="anchor" href="#_changePhoneNumber">#</a>
1418+
<code><a href="source-class-LeanCloud.User.html#481-492" title="Go to source code">changePhoneNumber</a>( <span>string <var>$smsCode</var></span>, <span>string <var>$phoneNumber</var></span> )</code>
1419+
1420+
<div class="description short">
1421+
<p>Update mobile phone number by SMS code.</p>
1422+
</div>
1423+
1424+
<div class="description detailed hidden">
1425+
<p>Update mobile phone number by SMS code.</p>
1426+
1427+
1428+
<h4>Parameters</h4>
1429+
<div class="list"><dl>
1430+
<dt><var>$smsCode</var></dt>
1431+
<dd></dd>
1432+
<dt><var>$phoneNumber</var></dt>
1433+
<dd></dd>
1434+
</dl></div>
1435+
1436+
1437+
1438+
1439+
1440+
</div>
1441+
</div></td>
1442+
</tr>
1443+
<tr data-order="signUpOrLoginByMobilePhone" id="_signUpOrLoginByMobilePhone">
1444+
1445+
<td class="attributes"><code>
1446+
public static
1447+
1448+
<code><a href="class-LeanCloud.User.html">LeanCloud\User</a></code>
1449+
1450+
</code>
1451+
</td>
1452+
13811453
<td class="name"><div>
13821454
<a class="anchor" href="#_signUpOrLoginByMobilePhone">#</a>
1383-
<code><a href="source-class-LeanCloud.User.html#470-485" title="Go to source code">signUpOrLoginByMobilePhone</a>( <span>string <var>$phoneNumber</var></span>, <span>string <var>$smsCode</var></span> )</code>
1455+
<code><a href="source-class-LeanCloud.User.html#494-510" title="Go to source code">signUpOrLoginByMobilePhone</a>( <span>string <var>$phoneNumber</var></span>, <span>string <var>$smsCode</var></span> )</code>
13841456

13851457
<div class="description short">
13861458
<p>Sign up user by mobile phone and SMS code</p>
@@ -1398,6 +1470,10 @@ <h4>Parameters</h4>
13981470
<dd></dd>
13991471
</dl></div>
14001472

1473+
<h4>Returns</h4>
1474+
<div class="list">
1475+
<code><a href="class-LeanCloud.User.html">LeanCloud\User</a></code>
1476+
</div>
14011477

14021478

14031479

@@ -1417,7 +1493,7 @@ <h4>Parameters</h4>
14171493

14181494
<td class="name"><div>
14191495
<a class="anchor" href="#_logInWith">#</a>
1420-
<code><a href="source-class-LeanCloud.User.html#502-519" title="Go to source code">logInWith</a>( <span>string <var>$provider</var></span>, <span>array <var>$authToken</var></span> )</code>
1496+
<code><a href="source-class-LeanCloud.User.html#527-544" title="Go to source code">logInWith</a>( <span>string <var>$provider</var></span>, <span>array <var>$authToken</var></span> )</code>
14211497

14221498
<div class="description short">
14231499
<p>Log-in with 3rd party auth data</p>
@@ -1463,7 +1539,7 @@ <h4>Returns</h4>
14631539

14641540
<td class="name"><div>
14651541
<a class="anchor" href="#_linkWith">#</a>
1466-
<code><a href="source-class-LeanCloud.User.html#521-542" title="Go to source code">linkWith</a>( <span>string <var>$provider</var></span>, <span>array <var>$authToken</var></span> )</code>
1542+
<code><a href="source-class-LeanCloud.User.html#546-567" title="Go to source code">linkWith</a>( <span>string <var>$provider</var></span>, <span>array <var>$authToken</var></span> )</code>
14671543

14681544
<div class="description short">
14691545
<p>Link user with 3rd party provider</p>
@@ -1504,7 +1580,7 @@ <h4>Returns</h4>
15041580

15051581
<td class="name"><div>
15061582
<a class="anchor" href="#_unlinkWith">#</a>
1507-
<code><a href="source-class-LeanCloud.User.html#544-566" title="Go to source code">unlinkWith</a>( <span>string <var>$provider</var></span> )</code>
1583+
<code><a href="source-class-LeanCloud.User.html#569-591" title="Go to source code">unlinkWith</a>( <span>string <var>$provider</var></span> )</code>
15081584

15091585
<div class="description short">
15101586
<p>Unlink user with a provider</p>

docs/source-class-LeanCloud.Client.html

Lines changed: 569 additions & 558 deletions
Large diffs are not rendered by default.

docs/source-class-LeanCloud.Engine.LeanEngine.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ <h3>Exceptions</h3>
564564
</span><span id="427" class="l"> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> dispatchFunc(<span class="php-var">$funcName</span>, <span class="php-var">$body</span>, <span class="php-var">$decodeObj</span>=<span class="php-keyword1">false</span>) {
565565
</span><span id="428" class="l"> <span class="php-comment">// verify hook sign for RTM hooks</span>
566566
</span><span id="429" class="l"> <span class="php-keyword1">if</span> (<span class="php-keyword2">in_array</span>(<span class="php-var">$funcName</span>, <span class="php-keyword1">array</span>(
567-
</span><span id="430" class="l"> <span class="php-quote">'_messageReceived'</span>, <span class="php-quote">'_receiversOffline'</span>, <span class="php-quote">'_messageSent'</span>,
567+
</span><span id="430" class="l"> <span class="php-quote">'_messageReceived'</span>, <span class="php-quote">'_receiversOffline'</span>, <span class="php-quote">'_messageSent'</span>, <span class="php-quote">'_messageUpdate'</span>,
568568
</span><span id="431" class="l"> <span class="php-quote">'_conversationStart'</span>, <span class="php-quote">'_conversationStarted'</span>,
569569
</span><span id="432" class="l"> <span class="php-quote">'_conversationAdd'</span>, <span class="php-quote">'_conversationAdded'</span>, <span class="php-quote">'_conversationRemove'</span>, <span class="php-quote">'_conversationRemoved'</span>, <span class="php-quote">'_conversationUpdate'</span>,
570570
</span><span id="433" class="l"> <span class="php-quote">'_clientOnline'</span>, <span class="php-quote">'_clientOffline'</span>, <span class="php-quote">'_rtmClientSign'</span>

docs/source-class-LeanCloud.User.html

Lines changed: 123 additions & 98 deletions
Large diffs are not rendered by default.

release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version="$1"
99

1010
#### Build new changelog
1111
echo "" >> Changelog.md.0
12-
echo "$version 发布日期:`date +%Y-%m-%d`" >> Changelog.md.0
12+
echo "$version Released on `date +%Y-%m-%d`" >> Changelog.md.0
1313
echo "----" >> Changelog.md.0
1414
git log `git describe --tags --abbrev=0`..HEAD --pretty=%s >> Changelog.md.0
1515

src/LeanCloud/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Client {
2424
/**
2525
* Client version
2626
*/
27-
const VERSION = '0.12.0';
27+
const VERSION = '0.13.0';
2828

2929
/**
3030
* API Version string

src/LeanCloud/User.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,36 @@ public static function verifyMobilePhone($smsCode) {
467467
Client::post("/verifyMobilePhone/{$smsCode}", null);
468468
}
469469

470+
/**
471+
* Request mobile phone verify before updating it.
472+
*
473+
* @param string $phoneNumber
474+
*/
475+
public static function requestChangePhoneNumber($phoneNumber) {
476+
Client::post("/requestChangePhoneNumber", array(
477+
"mobilePhoneNumber" => $phoneNumber
478+
));
479+
}
480+
481+
/**
482+
* Update mobile phone number by SMS code.
483+
*
484+
* @param string $smsCode
485+
* @param string $phoneNumber
486+
*/
487+
public static function changePhoneNumber($smsCode, $phoneNumber) {
488+
Client::post("/changePhoneNumber", array(
489+
"mobilePhoneNumber" => $phoneNumber,
490+
"code" => $smsCode
491+
));
492+
}
493+
470494
/**
471495
* Sign up user by mobile phone and SMS code
472496
*
473497
* @param string $phoneNumber
474498
* @param string $smsCode
499+
* @return User
475500
*/
476501
public static function signUpOrLoginByMobilePhone($phoneNumber, $smsCode) {
477502
$resp = Client::post("/usersByMobilePhone", array(

0 commit comments

Comments
 (0)