Skip to content

Commit ba665ec

Browse files
Merge pull request #77 from appwrite/dev
Fix msg91 params
2 parents b1039ac + 2ebdcfe commit ba665ec

File tree

8 files changed

+43
-23
lines changed

8 files changed

+43
-23
lines changed

README.md

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

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.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 sdk.Messaging(client);
1010
const result = 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 result = 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
);

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4926,14 +4926,14 @@ declare module "node-appwrite" {
49264926
*
49274927
* @param {string} providerId
49284928
* @param {string} name
4929-
* @param {string} from
4929+
* @param {string} templateId
49304930
* @param {string} senderId
49314931
* @param {string} authKey
49324932
* @param {boolean} enabled
49334933
* @throws {AppwriteException}
49344934
* @returns {Promise}
49354935
*/
4936-
createMsg91Provider(providerId: string, name: string, from?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>;
4936+
createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>;
49374937
/**
49384938
* Update Msg91 provider
49394939
*
@@ -4942,13 +4942,13 @@ declare module "node-appwrite" {
49424942
* @param {string} providerId
49434943
* @param {string} name
49444944
* @param {boolean} enabled
4945+
* @param {string} templateId
49454946
* @param {string} senderId
49464947
* @param {string} authKey
4947-
* @param {string} from
49484948
* @throws {AppwriteException}
49494949
* @returns {Promise}
49504950
*/
4951-
updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, senderId?: string, authKey?: string, from?: string): Promise<Models.Provider>;
4951+
updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>;
49524952
/**
49534953
* Create Sendgrid provider
49544954
*

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class Client {
1212
this.headers = {
1313
'accept-encoding': '*',
1414
'content-type': '',
15-
'user-agent' : `AppwriteNodeJSSDK/12.0.0 (${os.type()}; ${os.version()}; ${os.arch()})`,
15+
'user-agent' : `AppwriteNodeJSSDK/12.0.1 (${os.type()}; ${os.version()}; ${os.arch()})`,
1616
'x-sdk-name': 'Node.js',
1717
'x-sdk-platform': 'server',
1818
'x-sdk-language': 'nodejs',
19-
'x-sdk-version': '12.0.0',
19+
'x-sdk-version': '12.0.1',
2020
'X-Appwrite-Response-Format' : '1.5.0',
2121
};
2222
this.selfSigned = false;

lib/id.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
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 = () => {
5+
const now = new Date();
6+
const sec = Math.floor(now.getTime() / 1000);
7+
const msec = now.getMilliseconds();
28

3-
static unique = () => {
4-
return 'unique()'
9+
// Convert to hexadecimal
10+
const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
11+
return hexTimestamp;
12+
}
13+
14+
// Generate a unique ID with padding to have a longer ID
15+
static unique = (padding = 7) => {
16+
const baseId = ID.#hexTimestamp();
17+
let randomPadding = '';
18+
19+
for (let i = 0; i < padding; i++) {
20+
const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
21+
randomPadding += randomHexDigit;
22+
}
23+
24+
return baseId + randomPadding;
525
}
626

727
static custom = (id) => {

lib/services/messaging.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,14 +1005,14 @@ class Messaging extends Service {
10051005
*
10061006
* @param {string} providerId
10071007
* @param {string} name
1008-
* @param {string} from
1008+
* @param {string} templateId
10091009
* @param {string} senderId
10101010
* @param {string} authKey
10111011
* @param {boolean} enabled
10121012
* @throws {AppwriteException}
10131013
* @returns {Promise}
10141014
*/
1015-
async createMsg91Provider(providerId, name, from, senderId, authKey, enabled) {
1015+
async createMsg91Provider(providerId, name, templateId, senderId, authKey, enabled) {
10161016
const apiPath = '/messaging/providers/msg91';
10171017
let payload = {};
10181018
if (typeof providerId === 'undefined') {
@@ -1032,8 +1032,8 @@ class Messaging extends Service {
10321032
payload['name'] = name;
10331033
}
10341034

1035-
if (typeof from !== 'undefined') {
1036-
payload['from'] = from;
1035+
if (typeof templateId !== 'undefined') {
1036+
payload['templateId'] = templateId;
10371037
}
10381038

10391039
if (typeof senderId !== 'undefined') {
@@ -1061,13 +1061,13 @@ class Messaging extends Service {
10611061
* @param {string} providerId
10621062
* @param {string} name
10631063
* @param {boolean} enabled
1064+
* @param {string} templateId
10641065
* @param {string} senderId
10651066
* @param {string} authKey
1066-
* @param {string} from
10671067
* @throws {AppwriteException}
10681068
* @returns {Promise}
10691069
*/
1070-
async updateMsg91Provider(providerId, name, enabled, senderId, authKey, from) {
1070+
async updateMsg91Provider(providerId, name, enabled, templateId, senderId, authKey) {
10711071
const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId);
10721072
let payload = {};
10731073
if (typeof providerId === 'undefined') {
@@ -1083,6 +1083,10 @@ class Messaging extends Service {
10831083
payload['enabled'] = enabled;
10841084
}
10851085

1086+
if (typeof templateId !== 'undefined') {
1087+
payload['templateId'] = templateId;
1088+
}
1089+
10861090
if (typeof senderId !== 'undefined') {
10871091
payload['senderId'] = senderId;
10881092
}
@@ -1091,10 +1095,6 @@ class Messaging extends Service {
10911095
payload['authKey'] = authKey;
10921096
}
10931097

1094-
if (typeof from !== 'undefined') {
1095-
payload['from'] = from;
1096-
}
1097-
10981098
return await this.client.call('patch', apiPath, {
10991099
'content-type': 'application/json',
11001100
}, payload);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "12.0.0",
5+
"version": "12.0.1",
66
"license": "BSD-3-Clause",
77
"main": "./index.js",
88
"types": "./index.d.ts",

0 commit comments

Comments
 (0)