Skip to content

Commit

Permalink
Merge pull request #28 from appwrite/dev
Browse files Browse the repository at this point in the history
Fix msg91 params
  • Loading branch information
christyjacob4 committed Mar 24, 2024
2 parents ccea310 + e53eac0 commit 94bbda5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite PHP SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square&v=1)
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square&v=1)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $messaging = new Messaging($client);
$result = $messaging->createMsg91Provider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
from: '+12065550100', // optional
templateId: '<TEMPLATE_ID>', // optional
senderId: '<SENDER_ID>', // optional
authKey: '<AUTH_KEY>', // optional
enabled: false // optional
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/messaging/update-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $result = $messaging->updateMsg91Provider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // optional
enabled: false, // optional
templateId: '<TEMPLATE_ID>', // optional
senderId: '<SENDER_ID>', // optional
authKey: '<AUTH_KEY>', // optional
from: '<FROM>' // optional
authKey: '<AUTH_KEY>' // optional
);
12 changes: 6 additions & 6 deletions docs/messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ POST https://cloud.appwrite.io/v1/messaging/providers/msg91
| --- | --- | --- | --- |
| 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. | |
| name | string | Provider name. | |
| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | |
| senderId | string | Msg91 Sender ID. | |
| authKey | string | Msg91 Auth Key. | |
| templateId | string | Msg91 template ID | |
| senderId | string | Msg91 sender ID. | |
| authKey | string | Msg91 auth key. | |
| enabled | boolean | Set as enabled. | |

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

## Create Sendgrid provider

Expand Down
4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/11.0.0 ()',
'user-agent' => 'AppwritePHPSDK/11.0.1 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '11.0.0',
'x-sdk-version'=> '11.0.1',
];

/**
Expand Down
13 changes: 10 additions & 3 deletions src/Appwrite/ID.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
namespace Appwrite;

class ID {
public static function unique(): string
public static function unique(int $padding = 7): string
{
return 'unique()';
$uniqid = \uniqid();

if ($padding > 0) {
$bytes = \random_bytes(\max(1, (int)\ceil(($padding / 2)))); // one byte expands to two chars
$uniqid .= \substr(\bin2hex($bytes), 0, $padding);
}

return $uniqid;
}

public static function custom(string $id): string
{
return $id;
}
}
}
18 changes: 9 additions & 9 deletions src/Appwrite/Services/Messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,15 @@ public function updateMailgunProvider(string $providerId, string $name = null, s
*
* @param string $providerId
* @param string $name
* @param string $from
* @param string $templateId
* @param string $senderId
* @param string $authKey
* @param bool $enabled
* @throws AppwriteException
* @return array
*/
public function createMsg91Provider(string $providerId, string $name, string $from = null, string $senderId = null, string $authKey = null, bool $enabled = null): array
public function createMsg91Provider(string $providerId, string $name, string $templateId = null, string $senderId = null, string $authKey = null, bool $enabled = null): array
{
$apiPath = str_replace([], [], '/messaging/providers/msg91');

Expand All @@ -1018,8 +1018,8 @@ public function createMsg91Provider(string $providerId, string $name, string $fr
if (!is_null($name)) {
$apiParams['name'] = $name;
}
if (!is_null($from)) {
$apiParams['from'] = $from;
if (!is_null($templateId)) {
$apiParams['templateId'] = $templateId;
}
if (!is_null($senderId)) {
$apiParams['senderId'] = $senderId;
Expand Down Expand Up @@ -1048,14 +1048,14 @@ public function createMsg91Provider(string $providerId, string $name, string $fr
* @param string $providerId
* @param string $name
* @param bool $enabled
* @param string $templateId
* @param string $senderId
* @param string $authKey
* @param string $from
* @throws AppwriteException
* @return array
*/
public function updateMsg91Provider(string $providerId, string $name = null, bool $enabled = null, string $senderId = null, string $authKey = null, string $from = null): array
public function updateMsg91Provider(string $providerId, string $name = null, bool $enabled = null, string $templateId = null, string $senderId = null, string $authKey = null): array
{
$apiPath = str_replace(['{providerId}'], [$providerId], '/messaging/providers/msg91/{providerId}');

Expand All @@ -1069,15 +1069,15 @@ public function updateMsg91Provider(string $providerId, string $name = null, boo
if (!is_null($enabled)) {
$apiParams['enabled'] = $enabled;
}
if (!is_null($templateId)) {
$apiParams['templateId'] = $templateId;
}
if (!is_null($senderId)) {
$apiParams['senderId'] = $senderId;
}
if (!is_null($authKey)) {
$apiParams['authKey'] = $authKey;
}
if (!is_null($from)) {
$apiParams['from'] = $from;
}
return $this->client->call(
Client::METHOD_PATCH,
$apiPath,
Expand Down

0 comments on commit 94bbda5

Please sign in to comment.