Skip to content

Commit 63b9538

Browse files
Merge pull request #19 from appwrite/dev
Fix msg91 params
2 parents 5ba5de3 + 144716a commit 63b9538

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

README.md

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

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
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
@@ -10,7 +10,7 @@ const messaging = new Messaging(client);
1010
const response = await messaging.createMsg91Provider(
1111
'<PROVIDER_ID>', // providerId
1212
'<NAME>', // name
13-
'+12065550100', // from (optional)
13+
'<TEMPLATE_ID>', // templateId (optional)
1414
'<SENDER_ID>', // senderId (optional)
1515
'<AUTH_KEY>', // authKey (optional)
1616
false // enabled (optional)

docs/examples/messaging/update-msg91provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const response = await messaging.updateMsg91Provider(
1111
'<PROVIDER_ID>', // providerId
1212
'<NAME>', // name (optional)
1313
false, // enabled (optional)
14+
'<TEMPLATE_ID>', // templateId (optional)
1415
'<SENDER_ID>', // senderId (optional)
15-
'<AUTH_KEY>', // authKey (optional)
16-
'<FROM>' // from (optional)
16+
'<AUTH_KEY>' // authKey (optional)
1717
);

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export class Client {
1111
endpoint: string = 'https://cloud.appwrite.io/v1';
1212
headers: Payload = {
1313
'content-type': '',
14-
'user-agent' : `AppwriteDenoSDK/10.0.0 (${Deno.build.os}; ${Deno.build.arch})`,
14+
'user-agent' : `AppwriteDenoSDK/10.0.1 (${Deno.build.os}; ${Deno.build.arch})`,
1515
'x-sdk-name': 'Deno',
1616
'x-sdk-platform': 'server',
1717
'x-sdk-language': 'deno',
18-
'x-sdk-version': '10.0.0',
18+
'x-sdk-version': '10.0.1',
1919
'X-Appwrite-Response-Format':'1.5.0',
2020
};
2121

src/id.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
export class ID {
2+
// Generate an hex ID based on timestamp
3+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
4+
static #hexTimestamp(): string {
5+
const now = new Date();
6+
const sec = Math.floor(now.getTime() / 1000);
7+
const msec = now.getMilliseconds();
8+
9+
// Convert to hexadecimal
10+
const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
11+
return hexTimestamp;
12+
}
13+
214
public static custom(id: string): string {
315
return id
416
}
5-
6-
public static unique(): string {
7-
return 'unique()'
17+
18+
// Generate a unique ID with padding to have a longer ID
19+
public static unique(padding: number = 7): string {
20+
const baseId = ID.#hexTimestamp();
21+
let randomPadding = '';
22+
23+
for (let i = 0; i < padding; i++) {
24+
const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
25+
randomPadding += randomHexDigit;
26+
}
27+
28+
return baseId + randomPadding;
829
}
9-
}
30+
}

src/services/messaging.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -994,14 +994,14 @@ export class Messaging extends Service {
994994
*
995995
* @param {string} providerId
996996
* @param {string} name
997-
* @param {string} from
997+
* @param {string} templateId
998998
* @param {string} senderId
999999
* @param {string} authKey
10001000
* @param {boolean} enabled
10011001
* @throws {AppwriteException}
10021002
* @returns {Promise}
10031003
*/
1004-
async createMsg91Provider(providerId: string, name: string, from?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
1004+
async createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider> {
10051005
if (typeof providerId === 'undefined') {
10061006
throw new AppwriteException('Missing required parameter: "providerId"');
10071007
}
@@ -1019,8 +1019,8 @@ export class Messaging extends Service {
10191019
if (typeof name !== 'undefined') {
10201020
payload['name'] = name;
10211021
}
1022-
if (typeof from !== 'undefined') {
1023-
payload['from'] = from;
1022+
if (typeof templateId !== 'undefined') {
1023+
payload['templateId'] = templateId;
10241024
}
10251025
if (typeof senderId !== 'undefined') {
10261026
payload['senderId'] = senderId;
@@ -1049,13 +1049,13 @@ export class Messaging extends Service {
10491049
* @param {string} providerId
10501050
* @param {string} name
10511051
* @param {boolean} enabled
1052+
* @param {string} templateId
10521053
* @param {string} senderId
10531054
* @param {string} authKey
1054-
* @param {string} from
10551055
* @throws {AppwriteException}
10561056
* @returns {Promise}
10571057
*/
1058-
async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, senderId?: string, authKey?: string, from?: string): Promise<Models.Provider> {
1058+
async updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider> {
10591059
if (typeof providerId === 'undefined') {
10601060
throw new AppwriteException('Missing required parameter: "providerId"');
10611061
}
@@ -1069,15 +1069,15 @@ export class Messaging extends Service {
10691069
if (typeof enabled !== 'undefined') {
10701070
payload['enabled'] = enabled;
10711071
}
1072+
if (typeof templateId !== 'undefined') {
1073+
payload['templateId'] = templateId;
1074+
}
10721075
if (typeof senderId !== 'undefined') {
10731076
payload['senderId'] = senderId;
10741077
}
10751078
if (typeof authKey !== 'undefined') {
10761079
payload['authKey'] = authKey;
10771080
}
1078-
if (typeof from !== 'undefined') {
1079-
payload['from'] = from;
1080-
}
10811081
return await this.client.call(
10821082
'patch',
10831083
apiPath,

0 commit comments

Comments
 (0)