Skip to content

Commit 94bbda5

Browse files
Merge pull request #28 from appwrite/dev
Fix msg91 params
2 parents ccea310 + e53eac0 commit 94bbda5

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite PHP SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
4-
![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square&v=1)
4+
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square&v=1)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

docs/examples/messaging/create-msg91provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $messaging = new Messaging($client);
1313
$result = $messaging->createMsg91Provider(
1414
providerId: '<PROVIDER_ID>',
1515
name: '<NAME>',
16-
from: '+12065550100', // optional
16+
templateId: '<TEMPLATE_ID>', // optional
1717
senderId: '<SENDER_ID>', // optional
1818
authKey: '<AUTH_KEY>', // optional
1919
enabled: false // optional

docs/examples/messaging/update-msg91provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $result = $messaging->updateMsg91Provider(
1414
providerId: '<PROVIDER_ID>',
1515
name: '<NAME>', // optional
1616
enabled: false, // optional
17+
templateId: '<TEMPLATE_ID>', // optional
1718
senderId: '<SENDER_ID>', // optional
18-
authKey: '<AUTH_KEY>', // optional
19-
from: '<FROM>' // optional
19+
authKey: '<AUTH_KEY>' // optional
2020
);

docs/messaging.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ POST https://cloud.appwrite.io/v1/messaging/providers/msg91
375375
| --- | --- | --- | --- |
376376
| providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | |
377377
| name | string | Provider name. | |
378-
| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | |
379-
| senderId | string | Msg91 Sender ID. | |
380-
| authKey | string | Msg91 Auth Key. | |
378+
| templateId | string | Msg91 template ID | |
379+
| senderId | string | Msg91 sender ID. | |
380+
| authKey | string | Msg91 auth key. | |
381381
| enabled | boolean | Set as enabled. | |
382382

383383
## Update Msg91 provider
@@ -395,9 +395,9 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/msg91/{providerId}
395395
| providerId | string | **Required** Provider ID. | |
396396
| name | string | Provider name. | |
397397
| enabled | boolean | Set as enabled. | |
398-
| senderId | string | Msg91 Sender ID. | |
399-
| authKey | string | Msg91 Auth Key. | |
400-
| from | string | Sender number. | |
398+
| templateId | string | Msg91 template ID. | |
399+
| senderId | string | Msg91 sender ID. | |
400+
| authKey | string | Msg91 auth key. | |
401401

402402
## Create Sendgrid provider
403403

src/Appwrite/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class Client
3737
*/
3838
protected $headers = [
3939
'content-type' => '',
40-
'user-agent' => 'AppwritePHPSDK/11.0.0 ()',
40+
'user-agent' => 'AppwritePHPSDK/11.0.1 ()',
4141
'x-sdk-name'=> 'PHP',
4242
'x-sdk-platform'=> 'server',
4343
'x-sdk-language'=> 'php',
44-
'x-sdk-version'=> '11.0.0',
44+
'x-sdk-version'=> '11.0.1',
4545
];
4646

4747
/**

src/Appwrite/ID.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
namespace Appwrite;
44

55
class ID {
6-
public static function unique(): string
6+
public static function unique(int $padding = 7): string
77
{
8-
return 'unique()';
8+
$uniqid = \uniqid();
9+
10+
if ($padding > 0) {
11+
$bytes = \random_bytes(\max(1, (int)\ceil(($padding / 2)))); // one byte expands to two chars
12+
$uniqid .= \substr(\bin2hex($bytes), 0, $padding);
13+
}
14+
15+
return $uniqid;
916
}
1017

1118
public static function custom(string $id): string
1219
{
1320
return $id;
1421
}
15-
}
22+
}

src/Appwrite/Services/Messaging.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -993,15 +993,15 @@ public function updateMailgunProvider(string $providerId, string $name = null, s
993993
*
994994
* @param string $providerId
995995
* @param string $name
996-
* @param string $from
996+
* @param string $templateId
997997
* @param string $senderId
998998
* @param string $authKey
999999
* @param bool $enabled
10001000
* @throws AppwriteException
10011001
* @return array
10021002
10031003
*/
1004-
public function createMsg91Provider(string $providerId, string $name, string $from = null, string $senderId = null, string $authKey = null, bool $enabled = null): array
1004+
public function createMsg91Provider(string $providerId, string $name, string $templateId = null, string $senderId = null, string $authKey = null, bool $enabled = null): array
10051005
{
10061006
$apiPath = str_replace([], [], '/messaging/providers/msg91');
10071007

@@ -1018,8 +1018,8 @@ public function createMsg91Provider(string $providerId, string $name, string $fr
10181018
if (!is_null($name)) {
10191019
$apiParams['name'] = $name;
10201020
}
1021-
if (!is_null($from)) {
1022-
$apiParams['from'] = $from;
1021+
if (!is_null($templateId)) {
1022+
$apiParams['templateId'] = $templateId;
10231023
}
10241024
if (!is_null($senderId)) {
10251025
$apiParams['senderId'] = $senderId;
@@ -1048,14 +1048,14 @@ public function createMsg91Provider(string $providerId, string $name, string $fr
10481048
* @param string $providerId
10491049
* @param string $name
10501050
* @param bool $enabled
1051+
* @param string $templateId
10511052
* @param string $senderId
10521053
* @param string $authKey
1053-
* @param string $from
10541054
* @throws AppwriteException
10551055
* @return array
10561056
10571057
*/
1058-
public function updateMsg91Provider(string $providerId, string $name = null, bool $enabled = null, string $senderId = null, string $authKey = null, string $from = null): array
1058+
public function updateMsg91Provider(string $providerId, string $name = null, bool $enabled = null, string $templateId = null, string $senderId = null, string $authKey = null): array
10591059
{
10601060
$apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/msg91/{providerId}');
10611061

@@ -1069,15 +1069,15 @@ public function updateMsg91Provider(string $providerId, string $name = null, boo
10691069
if (!is_null($enabled)) {
10701070
$apiParams['enabled'] = $enabled;
10711071
}
1072+
if (!is_null($templateId)) {
1073+
$apiParams['templateId'] = $templateId;
1074+
}
10721075
if (!is_null($senderId)) {
10731076
$apiParams['senderId'] = $senderId;
10741077
}
10751078
if (!is_null($authKey)) {
10761079
$apiParams['authKey'] = $authKey;
10771080
}
1078-
if (!is_null($from)) {
1079-
$apiParams['from'] = $from;
1080-
}
10811081
return $this->client->call(
10821082
Client::METHOD_PATCH,
10831083
$apiPath,

0 commit comments

Comments
 (0)