Skip to content

Commit 8449680

Browse files
implement realtime feature
1 parent ad754a7 commit 8449680

File tree

9 files changed

+171
-12
lines changed

9 files changed

+171
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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-0.9.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-0.10.0-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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/releases).**
9+
**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-deno/releases).**
1010

1111
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Deno SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

@@ -90,7 +90,7 @@ try {
9090
```
9191

9292
### Learn more
93-
You can use following resources to learn more and get help
93+
You can use the following resources to learn more and get help
9494
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
9595
- 📜 [Appwrite Docs](https://appwrite.io/docs)
9696
- 💬 [Discord Community](https://appwrite.io/discord)

docs/examples/functions/create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ client
1212
;
1313

1414

15-
let promise = functions.create('[NAME]', [], 'java-11.0');
15+
let promise = functions.create('[NAME]', [], 'dotnet-5.0');
1616

1717
promise.then(function (response) {
1818
console.log(response);

docs/examples/users/update-email.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as sdk from "https://deno.land/x/appwrite/mod.ts";
2+
3+
// Init SDK
4+
let client = new sdk.Client();
5+
6+
let users = new sdk.Users(client);
7+
8+
client
9+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10+
.setProject('5df5acd0d48c2') // Your project ID
11+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12+
;
13+
14+
15+
let promise = users.updateEmail('[USER_ID]', '[email protected]');
16+
17+
promise.then(function (response) {
18+
console.log(response);
19+
}, function (error) {
20+
console.log(error);
21+
});

docs/examples/users/update-name.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as sdk from "https://deno.land/x/appwrite/mod.ts";
2+
3+
// Init SDK
4+
let client = new sdk.Client();
5+
6+
let users = new sdk.Users(client);
7+
8+
client
9+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10+
.setProject('5df5acd0d48c2') // Your project ID
11+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12+
;
13+
14+
15+
let promise = users.updateName('[USER_ID]', '[NAME]');
16+
17+
promise.then(function (response) {
18+
console.log(response);
19+
}, function (error) {
20+
console.log(error);
21+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as sdk from "https://deno.land/x/appwrite/mod.ts";
2+
3+
// Init SDK
4+
let client = new sdk.Client();
5+
6+
let users = new sdk.Users(client);
7+
8+
client
9+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
10+
.setProject('5df5acd0d48c2') // Your project ID
11+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
12+
;
13+
14+
15+
let promise = users.updatePassword('[USER_ID]', 'password');
16+
17+
promise.then(function (response) {
18+
console.log(response);
19+
}, function (error) {
20+
console.log(error);
21+
});

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export class Client {
88
endpoint: string = 'https://appwrite.io/v1';
99
headers: Payload = {
1010
'content-type': '',
11-
'x-sdk-version': 'appwrite:deno:0.3.0',
12-
'X-Appwrite-Response-Format':'0.9.0',
11+
'x-sdk-version': 'appwrite:deno:0.4.0',
12+
'X-Appwrite-Response-Format':'0.10.0',
1313
};
1414

1515
/**

src/services/account.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class Account extends Service {
246246
}
247247

248248
/**
249-
* Complete Password Recovery
249+
* Create Password Recovery (confirmation)
250250
*
251251
* Use this endpoint to complete the user account password reset. Both the
252252
* **userId** and **secret** arguments will be passed as query parameters to
@@ -430,7 +430,7 @@ export class Account extends Service {
430430
}
431431

432432
/**
433-
* Complete Email Verification
433+
* Create Email Verification (confirmation)
434434
*
435435
* Use this endpoint to complete the user email verification process. Use both
436436
* the **userId** and **secret** parameters that were attached to your app URL

src/services/teams.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,17 @@ export class Teams extends Service {
202202
/**
203203
* Create Team Membership
204204
*
205-
* Use this endpoint to invite a new member to join your team. An email with a
206-
* link to join the team will be sent to the new member email address if the
207-
* member doesn't exist in the project it will be created automatically.
205+
* Use this endpoint to invite a new member to join your team. If initiated
206+
* from Client SDK, an email with a link to join the team will be sent to the
207+
* new member's email address if the member doesn't exist in the project it
208+
* will be created automatically. If initiated from server side SDKs, new
209+
* member will automatically be added to the team.
208210
*
209211
* Use the 'URL' parameter to redirect the user from the invitation email back
210212
* to your app. When the user is redirected, use the [Update Team Membership
211213
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
212-
* the user to accept the invitation to the team.
214+
* the user to accept the invitation to the team. While calling from side
215+
* SDKs the redirect url can be empty string.
213216
*
214217
* Please note that in order to avoid a [Redirect
215218
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)

src/services/users.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,37 @@ export class Users extends Service {
126126
}, payload);
127127
}
128128

129+
/**
130+
* Update Email
131+
*
132+
* Update the user email by its unique ID.
133+
*
134+
* @param {string} userId
135+
* @param {string} email
136+
* @throws {AppwriteException}
137+
* @returns {Promise}
138+
*/
139+
async updateEmail<T extends unknown>(userId: string, email: string): Promise<T> {
140+
if (typeof userId === 'undefined') {
141+
throw new AppwriteException('Missing required parameter: "userId"');
142+
}
143+
144+
if (typeof email === 'undefined') {
145+
throw new AppwriteException('Missing required parameter: "email"');
146+
}
147+
148+
let path = '/users/{userId}/email'.replace('{userId}', userId);
149+
let payload: Payload = {};
150+
151+
if (typeof email !== 'undefined') {
152+
payload['email'] = email;
153+
}
154+
155+
return await this.client.call('patch', path, {
156+
'content-type': 'application/json',
157+
}, payload);
158+
}
159+
129160
/**
130161
* Get User Logs
131162
*
@@ -148,6 +179,68 @@ export class Users extends Service {
148179
}, payload);
149180
}
150181

182+
/**
183+
* Update Name
184+
*
185+
* Update the user name by its unique ID.
186+
*
187+
* @param {string} userId
188+
* @param {string} name
189+
* @throws {AppwriteException}
190+
* @returns {Promise}
191+
*/
192+
async updateName<T extends unknown>(userId: string, name: string): Promise<T> {
193+
if (typeof userId === 'undefined') {
194+
throw new AppwriteException('Missing required parameter: "userId"');
195+
}
196+
197+
if (typeof name === 'undefined') {
198+
throw new AppwriteException('Missing required parameter: "name"');
199+
}
200+
201+
let path = '/users/{userId}/name'.replace('{userId}', userId);
202+
let payload: Payload = {};
203+
204+
if (typeof name !== 'undefined') {
205+
payload['name'] = name;
206+
}
207+
208+
return await this.client.call('patch', path, {
209+
'content-type': 'application/json',
210+
}, payload);
211+
}
212+
213+
/**
214+
* Update Password
215+
*
216+
* Update the user password by its unique ID.
217+
*
218+
* @param {string} userId
219+
* @param {string} password
220+
* @throws {AppwriteException}
221+
* @returns {Promise}
222+
*/
223+
async updatePassword<T extends unknown>(userId: string, password: string): Promise<T> {
224+
if (typeof userId === 'undefined') {
225+
throw new AppwriteException('Missing required parameter: "userId"');
226+
}
227+
228+
if (typeof password === 'undefined') {
229+
throw new AppwriteException('Missing required parameter: "password"');
230+
}
231+
232+
let path = '/users/{userId}/password'.replace('{userId}', userId);
233+
let payload: Payload = {};
234+
235+
if (typeof password !== 'undefined') {
236+
payload['password'] = password;
237+
}
238+
239+
return await this.client.call('patch', path, {
240+
'content-type': 'application/json',
241+
}, payload);
242+
}
243+
151244
/**
152245
* Get User Preferences
153246
*

0 commit comments

Comments
 (0)