Updated SDKs
This commit is contained in:
parent
53a1cda21c
commit
31207a1ed0
|
@ -1,7 +1,9 @@
|
|||
# Appwrite SDK for Dart
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
|
||||
|
||||
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
|
||||
|
||||
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
|
|
@ -15,26 +15,12 @@ class Account extends Service {
|
|||
|
||||
return await this.client.call('get', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to allow a new user to register an account in your
|
||||
/// project. Use the success and failure URLs to redirect users back to your
|
||||
/// application after signup completes.
|
||||
///
|
||||
/// If registration completes successfully user will be sent with a
|
||||
/// confirmation email in order to confirm he is the owner of the account email
|
||||
/// address. Use the confirmation parameter to redirect the user from the
|
||||
/// confirmation email back to your app. When the user is redirected, use the
|
||||
/// /auth/confirm endpoint to complete the account confirmation.
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
/// the only valid redirect URLs are the ones from domains you have set when
|
||||
/// adding your platforms in the console interface.
|
||||
///
|
||||
/// When accessing this route using Javascript from the browser, success and
|
||||
/// failure parameter URLs are required. Appwrite server will respond with a
|
||||
/// 301 redirect status code and will set the user session cookie. This
|
||||
/// behavior is enforced because modern browsers are limiting 3rd party cookies
|
||||
/// in XHR of fetch requests to protect user privacy.
|
||||
/// Use this endpoint to allow a new user to register a new account in your
|
||||
/// project. After the user registration completes successfully, you can use
|
||||
/// the [/account/verfication](/docs/account#createVerification) route to start
|
||||
/// verifying the user email address. To allow your new user to login to his
|
||||
/// new account, you need to create a new [account
|
||||
/// session](/docs/account#createSession).
|
||||
Future<Response> create({email, password, name = null}) async {
|
||||
String path = '/account';
|
||||
|
||||
|
@ -105,7 +91,7 @@ class Account extends Service {
|
|||
|
||||
return await this.client.call('patch', path: path, params: params);
|
||||
}
|
||||
/// Get currently logged in user preferences key-value object.
|
||||
/// Get currently logged in user preferences as a key-value object.
|
||||
Future<Response> getPrefs() async {
|
||||
String path = '/account/prefs';
|
||||
|
||||
|
@ -129,7 +115,8 @@ class Account extends Service {
|
|||
/// When the user clicks the confirmation link he is redirected back to your
|
||||
/// app password reset URL with the secret key and email address values
|
||||
/// attached to the URL query string. Use the query string params to submit a
|
||||
/// request to the /auth/password/reset endpoint to complete the process.
|
||||
/// request to the [PUT /account/recovery](/docs/account#updateRecovery)
|
||||
/// endpoint to complete the process.
|
||||
Future<Response> createRecovery({email, url}) async {
|
||||
String path = '/account/recovery';
|
||||
|
||||
|
@ -142,8 +129,8 @@ class Account extends Service {
|
|||
}
|
||||
/// Use this endpoint to complete the user account password reset. Both the
|
||||
/// **userId** and **secret** arguments will be passed as query parameters to
|
||||
/// the redirect URL you have provided when sending your request to the
|
||||
/// /auth/recovery endpoint.
|
||||
/// the redirect URL you have provided when sending your request to the [POST
|
||||
/// /account/recovery](/docs/account#createRecovery) endpoint.
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
|
@ -172,19 +159,7 @@ class Account extends Service {
|
|||
return await this.client.call('get', path: path, params: params);
|
||||
}
|
||||
/// Allow the user to login into his account by providing a valid email and
|
||||
/// password combination. Use the success and failure arguments to provide a
|
||||
/// redirect URL's back to your app when login is completed.
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
/// the only valid redirect URLs are the ones from domains you have set when
|
||||
/// adding your platforms in the console interface.
|
||||
///
|
||||
/// When accessing this route using Javascript from the browser, success and
|
||||
/// failure parameter URLs are required. Appwrite server will respond with a
|
||||
/// 301 redirect status code and will set the user session cookie. This
|
||||
/// behavior is enforced because modern browsers are limiting 3rd party cookies
|
||||
/// in XHR of fetch requests to protect user privacy.
|
||||
/// password combination. This route will create a new session for the user.
|
||||
Future<Response> createSession({email, password}) async {
|
||||
String path = '/account/sessions';
|
||||
|
||||
|
@ -205,17 +180,6 @@ class Account extends Service {
|
|||
|
||||
return await this.client.call('delete', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to log out the currently logged in user from his account.
|
||||
/// When successful this endpoint will delete the user session and remove the
|
||||
/// session secret cookie from the user client.
|
||||
Future<Response> deleteCurrentSession() async {
|
||||
String path = '/account/sessions/current';
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
return await this.client.call('delete', path: path, params: params);
|
||||
}
|
||||
/// Allow the user to login to his account using the OAuth provider of his
|
||||
/// choice. Each OAuth provider should be enabled from the Appwrite console
|
||||
/// first. Use the success and failure arguments to provide a redirect URL's
|
||||
|
@ -233,25 +197,46 @@ class Account extends Service {
|
|||
/// Use this endpoint to log out the currently logged in user from all his
|
||||
/// account sessions across all his different devices. When using the option id
|
||||
/// argument, only the session unique ID provider will be deleted.
|
||||
Future<Response> deleteSession({id}) async {
|
||||
String path = '/account/sessions/{id}'.replaceAll(RegExp('{id}'), id);
|
||||
Future<Response> deleteSession({sessionUid}) async {
|
||||
String path = '/account/sessions/{sessionUid}'.replaceAll(RegExp('{sessionUid}'), sessionUid);
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
return await this.client.call('delete', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to send a verification message to your user email address
|
||||
/// to confirm they are the valid owners of that address. Both the **userId**
|
||||
/// and **secret** arguments will be passed as query parameters to the URL you
|
||||
/// have provider to be attached to the verification email. The provided URL
|
||||
/// should redirect the user back for your app and allow you to complete the
|
||||
/// verification process by verifying both the **userId** and **secret**
|
||||
/// parameters. Learn more about how to [complete the verification
|
||||
/// process](/docs/account#updateAccountVerification).
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
/// the only valid redirect URLs are the ones from domains you have set when
|
||||
/// adding your platforms in the console interface.
|
||||
Future<Response> createVerification({url}) async {
|
||||
String path = '/account/verification';
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
'url': url,
|
||||
};
|
||||
|
||||
return await this.client.call('post', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to complete the user email verification process. Use both
|
||||
/// the **userId** and **secret** parameters that were attached to your app URL
|
||||
/// to verify the user email ownership. If confirmed this route will return a
|
||||
/// 200 status code.
|
||||
Future<Response> updateVerification({userId, secret, passwordB}) async {
|
||||
Future<Response> updateVerification({userId, secret}) async {
|
||||
String path = '/account/verification';
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
'userId': userId,
|
||||
'secret': secret,
|
||||
'password-b': passwordB,
|
||||
};
|
||||
|
||||
return await this.client.call('put', path: path, params: params);
|
||||
|
|
|
@ -6,68 +6,6 @@ class Database extends Service {
|
|||
|
||||
Database(Client client): super(client);
|
||||
|
||||
/// Get a list of all the user collections. You can use the query params to
|
||||
/// filter your results. On admin mode, this endpoint will return a list of all
|
||||
/// of the project collections. [Learn more about different API
|
||||
/// modes](/docs/admin).
|
||||
Future<Response> listCollections({search = null, limit = 25, offset = null, orderType = 'ASC'}) async {
|
||||
String path = '/database/collections';
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType,
|
||||
};
|
||||
|
||||
return await this.client.call('get', path: path, params: params);
|
||||
}
|
||||
/// Create a new Collection.
|
||||
Future<Response> createCollection({name, read, write, rules}) async {
|
||||
String path = '/database/collections';
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'rules': rules,
|
||||
};
|
||||
|
||||
return await this.client.call('post', path: path, params: params);
|
||||
}
|
||||
/// Get collection by its unique ID. This endpoint response returns a JSON
|
||||
/// object with the collection metadata.
|
||||
Future<Response> getCollection({collectionId}) async {
|
||||
String path = '/database/collections/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
return await this.client.call('get', path: path, params: params);
|
||||
}
|
||||
/// Update collection by its unique ID.
|
||||
Future<Response> updateCollection({collectionId, name, read, write, rules = const []}) async {
|
||||
String path = '/database/collections/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'read': read,
|
||||
'write': write,
|
||||
'rules': rules,
|
||||
};
|
||||
|
||||
return await this.client.call('put', path: path, params: params);
|
||||
}
|
||||
/// Delete a collection by its unique ID. Only users with write permissions
|
||||
/// have access to delete this resource.
|
||||
Future<Response> deleteCollection({collectionId}) async {
|
||||
String path = '/database/collections/{collectionId}'.replaceAll(RegExp('{collectionId}'), collectionId);
|
||||
|
||||
Map<String, dynamic> params = {
|
||||
};
|
||||
|
||||
return await this.client.call('delete', path: path, params: params);
|
||||
}
|
||||
/// Get a list of all the user documents. You can use the query params to
|
||||
/// filter your results. On admin mode, this endpoint will return a list of all
|
||||
/// of the project documents. [Learn more about different API
|
||||
|
|
|
@ -76,14 +76,14 @@ class Teams extends Service {
|
|||
|
||||
return await this.client.call('get', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to invite a new member to your team. An email with a link
|
||||
/// to join the team will be sent to the new member email address. If member
|
||||
/// doesn't exists in the project it will be automatically created.
|
||||
/// Use this endpoint to invite a new member to join your team. An email with a
|
||||
/// link to join the team will be sent to the new member email address if the
|
||||
/// member doesn't exist in the project it will be created automatically.
|
||||
///
|
||||
/// Use the 'url' parameter to redirect the user from the invitation email back
|
||||
/// Use the 'URL' parameter to redirect the user from the invitation email back
|
||||
/// to your app. When the user is redirected, use the [Update Team Membership
|
||||
/// Status](/docs/teams#updateTeamMembershipStatus) endpoint to finally join
|
||||
/// the user to the team.
|
||||
/// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to
|
||||
/// accept the invitation to the team.
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
|
@ -112,21 +112,9 @@ class Teams extends Service {
|
|||
|
||||
return await this.client.call('delete', path: path, params: params);
|
||||
}
|
||||
/// Use this endpoint to let user accept an invitation to join a team after he
|
||||
/// is being redirect back to your app from the invitation email. Use the
|
||||
/// success and failure URL's to redirect users back to your application after
|
||||
/// the request completes.
|
||||
///
|
||||
/// Please note that in order to avoid a [Redirect
|
||||
/// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
/// the only valid redirect URL's are the once from domains you have set when
|
||||
/// added your platforms in the console interface.
|
||||
///
|
||||
/// When not using the success or failure redirect arguments this endpoint will
|
||||
/// result with a 200 status code on success and with 401 status error on
|
||||
/// failure. This behavior was applied to help the web clients deal with
|
||||
/// browsers who don't allow to set 3rd party HTTP cookies needed for saving
|
||||
/// the account session key.
|
||||
/// Use this endpoint to allow a user to accept an invitation to join a team
|
||||
/// after he is being redirected back to your app from the invitation email he
|
||||
/// was sent.
|
||||
Future<Response> updateMembershipStatus({teamId, inviteId, userId, secret}) async {
|
||||
String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Appwrite SDK for Go
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
|
||||
|
||||
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, O
|
|||
}
|
||||
|
||||
// CreateDocument create a new Document.
|
||||
func (srv *Database) CreateDocument(CollectionId string, Data string, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) {
|
||||
func (srv *Database) CreateDocument(CollectionId string, Data object, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) {
|
||||
r := strings.NewReplacer("{collectionId}", CollectionId)
|
||||
path := r.Replace("/database/collections/{collectionId}/documents")
|
||||
|
||||
|
@ -140,7 +140,7 @@ func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[st
|
|||
}
|
||||
|
||||
// UpdateDocument
|
||||
func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) {
|
||||
func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data object, Read []interface{}, Write []interface{}) (map[string]interface{}, error) {
|
||||
r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId)
|
||||
path := r.Replace("/database/collections/{collectionId}/documents/{documentId}")
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ func main() {
|
|||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.CreateDocument("[COLLECTION_ID]", "{}", [], [], "[PARENT_DOCUMENT]", "", "assign")
|
||||
var response, error := service.CreateDocument("[COLLECTION_ID]", , [], [], "[PARENT_DOCUMENT]", "", "assign")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
|
|
|
@ -15,7 +15,7 @@ func main() {
|
|||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", "{}", [], [])
|
||||
var response, error := service.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", , [], [])
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.Create(file, [], [])
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.Delete("[FILE_ID]")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.GetDownload("[FILE_ID]")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.GetPreview("[FILE_ID]", 0, 0, 0, "", "jpg")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.GetView("[FILE_ID]", "pdf")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.Get("[FILE_ID]")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.List("[SEARCH]", 0, 0, "ASC")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("")
|
||||
client.SetKey("")
|
||||
|
||||
var service := appwrite.Storage{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.Update("[FILE_ID]", [], [])
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -15,7 +15,7 @@ func main() {
|
|||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.UpdatePrefs("[USER_ID]", "")
|
||||
var response, error := service.UpdatePrefs("[USER_ID]", )
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
|
|
|
@ -98,15 +98,15 @@ func (srv *Teams) GetMemberships(TeamId string) (map[string]interface{}, error)
|
|||
return srv.client.Call("GET", path, nil, params)
|
||||
}
|
||||
|
||||
// CreateMembership use this endpoint to invite a new member to your team. An
|
||||
// email with a link to join the team will be sent to the new member email
|
||||
// address. If member doesn't exists in the project it will be automatically
|
||||
// created.
|
||||
// CreateMembership use this endpoint to invite a new member to join your
|
||||
// team. An email with a link to join the team will be sent to the new member
|
||||
// email address if the member doesn't exist in the project it will be created
|
||||
// automatically.
|
||||
//
|
||||
// Use the 'url' parameter to redirect the user from the invitation email back
|
||||
// Use the 'URL' parameter to redirect the user from the invitation email back
|
||||
// to your app. When the user is redirected, use the [Update Team Membership
|
||||
// Status](/docs/teams#updateTeamMembershipStatus) endpoint to finally join
|
||||
// the user to the team.
|
||||
// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to
|
||||
// accept the invitation to the team.
|
||||
//
|
||||
// Please note that in order to avoid a [Redirect
|
||||
// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
|
|
|
@ -80,7 +80,7 @@ func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error) {
|
|||
|
||||
// UpdatePrefs update user preferences by its unique ID. You can pass only the
|
||||
// specific settings you wish to update.
|
||||
func (srv *Users) UpdatePrefs(UserId string, Prefs string) (map[string]interface{}, error) {
|
||||
func (srv *Users) UpdatePrefs(UserId string, Prefs object) (map[string]interface{}, error) {
|
||||
r := strings.NewReplacer("{userId}", UserId)
|
||||
path := r.Replace("/users/{userId}/prefs")
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Appwrite SDK for JavaScript
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
|
||||
|
||||
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.createOAuthSession('bitbucket', 'https://example.com', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.createRecovery('email@example.com', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.createSession('email@example.com', 'password');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -2,7 +2,6 @@ let sdk = new Appwrite();
|
|||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.account.createVerification('https://example.com');
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.create('email@example.com', 'password');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.account.deleteCurrentSession();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -4,7 +4,7 @@ sdk
|
|||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.account.deleteSession('[ID]');
|
||||
let promise = sdk.account.deleteSession('[SESSION_UID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -4,7 +4,7 @@ sdk
|
|||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.account.updatePrefs('');
|
||||
let promise = sdk.account.updatePrefs({});
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.updateRecovery('[USER_ID]', '[SECRET]', 'password', 'password');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.account.updateVerification('[USER_ID]', '[SECRET]', 'password');
|
||||
let promise = sdk.account.updateVerification('[USER_ID]', '[SECRET]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.createCollection('[NAME]', [], [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -4,7 +4,7 @@ sdk
|
|||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.createDocument('[COLLECTION_ID]', '{}', [], []);
|
||||
let promise = sdk.database.createDocument('[COLLECTION_ID]', {}, [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.deleteCollection('[COLLECTION_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.getCollection('[COLLECTION_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.listCollections();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.updateCollection('[COLLECTION_ID]', '[NAME]', [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -4,7 +4,7 @@ sdk
|
|||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', '{}', [], []);
|
||||
let promise = sdk.database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createKey('[PROJECT_ID]', '[NAME]', []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createPlatform('[PROJECT_ID]', 'web', '[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createTask('[PROJECT_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.create('[NAME]', '[TEAM_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.deleteKey('[PROJECT_ID]', '[KEY_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.deletePlatform('[PROJECT_ID]', '[PLATFORM_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.deleteTask('[PROJECT_ID]', '[TASK_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.deleteWebhook('[PROJECT_ID]', '[WEBHOOK_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.delete('[PROJECT_ID]', '[PASSWORD]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.getKey('[PROJECT_ID]', '[KEY_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.getPlatform('[PROJECT_ID]', '[PLATFORM_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.getTask('[PROJECT_ID]', '[TASK_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.getUsage('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.getWebhook('[PROJECT_ID]', '[WEBHOOK_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.get('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.listKeys('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.listPlatforms('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.listTasks('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.listWebhooks('[PROJECT_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.list();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateKey('[PROJECT_ID]', '[KEY_ID]', '[NAME]', []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateOAuth('[PROJECT_ID]', 'bitbucket');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updatePlatform('[PROJECT_ID]', '[PLATFORM_ID]', '[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.projects.update('[PROJECT_ID]', '[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.create(document.getElementById('uploader').files[0], [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.delete('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.getDownload('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.getPreview('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.getView('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.get('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.list();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
;
|
||||
|
||||
let promise = sdk.storage.update('[FILE_ID]', [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,8 +1,5 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
;
|
||||
|
||||
let promise = sdk.teams.updateMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]');
|
||||
|
||||
promise.then(function (response) {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.create('email@example.com', 'password');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.deleteSession('[USER_ID]', '[SESSION_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.deleteSessions('[USER_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.getLogs('[USER_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.getPrefs('[USER_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.getSessions('[USER_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.get('[USER_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.list();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.updatePrefs('[USER_ID]', '');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,14 +0,0 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = sdk.users.updateStatus('[USER_ID]', '1');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -321,26 +321,12 @@
|
|||
/**
|
||||
* Create Account
|
||||
*
|
||||
* Use this endpoint to allow a new user to register an account in your
|
||||
* project. Use the success and failure URLs to redirect users back to your
|
||||
* application after signup completes.
|
||||
*
|
||||
* If registration completes successfully user will be sent with a
|
||||
* confirmation email in order to confirm he is the owner of the account email
|
||||
* address. Use the confirmation parameter to redirect the user from the
|
||||
* confirmation email back to your app. When the user is redirected, use the
|
||||
* /auth/confirm endpoint to complete the account confirmation.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URLs are the ones from domains you have set when
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* When accessing this route using Javascript from the browser, success and
|
||||
* failure parameter URLs are required. Appwrite server will respond with a
|
||||
* 301 redirect status code and will set the user session cookie. This
|
||||
* behavior is enforced because modern browsers are limiting 3rd party cookies
|
||||
* in XHR of fetch requests to protect user privacy.
|
||||
* Use this endpoint to allow a new user to register a new account in your
|
||||
* project. After the user registration completes successfully, you can use
|
||||
* the [/account/verfication](/docs/account#createVerification) route to start
|
||||
* verifying the user email address. To allow your new user to login to his
|
||||
* new account, you need to create a new [account
|
||||
* session](/docs/account#createSession).
|
||||
*
|
||||
* @param {string} email
|
||||
* @param {string} password
|
||||
|
@ -531,7 +517,7 @@
|
|||
/**
|
||||
* Get Account Preferences
|
||||
*
|
||||
* Get currently logged in user preferences key-value object.
|
||||
* Get currently logged in user preferences as a key-value object.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
|
@ -553,7 +539,7 @@
|
|||
* Update currently logged in user account preferences. You can pass only the
|
||||
* specific settings you wish to update.
|
||||
*
|
||||
* @param {string} prefs
|
||||
* @param {object} prefs
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
|
@ -577,13 +563,14 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Password Recovery
|
||||
* Create Password Recovery
|
||||
*
|
||||
* Sends the user an email with a temporary secret key for password reset.
|
||||
* When the user clicks the confirmation link he is redirected back to your
|
||||
* app password reset URL with the secret key and email address values
|
||||
* attached to the URL query string. Use the query string params to submit a
|
||||
* request to the /auth/password/reset endpoint to complete the process.
|
||||
* request to the [PUT /account/recovery](/docs/account#updateRecovery)
|
||||
* endpoint to complete the process.
|
||||
*
|
||||
* @param {string} email
|
||||
* @param {string} url
|
||||
|
@ -618,12 +605,12 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Password Reset
|
||||
* Complete Password Recovery
|
||||
*
|
||||
* Use this endpoint to complete the user account password reset. Both the
|
||||
* **userId** and **secret** arguments will be passed as query parameters to
|
||||
* the redirect URL you have provided when sending your request to the
|
||||
* /auth/recovery endpoint.
|
||||
* the redirect URL you have provided when sending your request to the [POST
|
||||
* /account/recovery](/docs/account#createRecovery) endpoint.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
|
@ -704,19 +691,7 @@
|
|||
* Create Account Session
|
||||
*
|
||||
* Allow the user to login into his account by providing a valid email and
|
||||
* password combination. Use the success and failure arguments to provide a
|
||||
* redirect URL's back to your app when login is completed.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URLs are the ones from domains you have set when
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* When accessing this route using Javascript from the browser, success and
|
||||
* failure parameter URLs are required. Appwrite server will respond with a
|
||||
* 301 redirect status code and will set the user session cookie. This
|
||||
* behavior is enforced because modern browsers are limiting 3rd party cookies
|
||||
* in XHR of fetch requests to protect user privacy.
|
||||
* password combination. This route will create a new session for the user.
|
||||
*
|
||||
* @param {string} email
|
||||
* @param {string} password
|
||||
|
@ -770,27 +745,6 @@
|
|||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete Current Account Session
|
||||
*
|
||||
* Use this endpoint to log out the currently logged in user from his account.
|
||||
* When successful this endpoint will delete the user session and remove the
|
||||
* session secret cookie from the user client.
|
||||
*
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
deleteCurrentSession: function() {
|
||||
let path = '/account/sessions/current';
|
||||
|
||||
let payload = {};
|
||||
|
||||
return http
|
||||
.delete(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create Account Session with OAuth
|
||||
*
|
||||
|
@ -843,16 +797,16 @@
|
|||
* account sessions across all his different devices. When using the option id
|
||||
* argument, only the session unique ID provider will be deleted.
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {string} sessionUid
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
deleteSession: function(id) {
|
||||
if(id === undefined) {
|
||||
throw new Error('Missing required parameter: "id"');
|
||||
deleteSession: function(sessionUid) {
|
||||
if(sessionUid === undefined) {
|
||||
throw new Error('Missing required parameter: "sessionUid"');
|
||||
}
|
||||
|
||||
let path = '/account/sessions/{id}'.replace(new RegExp('{id}', 'g'), id);
|
||||
let path = '/account/sessions/{sessionUid}'.replace(new RegExp('{sessionUid}', 'g'), sessionUid);
|
||||
|
||||
let payload = {};
|
||||
|
||||
|
@ -863,7 +817,47 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Updated Verification
|
||||
* Create Email Verification
|
||||
*
|
||||
* Use this endpoint to send a verification message to your user email address
|
||||
* to confirm they are the valid owners of that address. Both the **userId**
|
||||
* and **secret** arguments will be passed as query parameters to the URL you
|
||||
* have provider to be attached to the verification email. The provided URL
|
||||
* should redirect the user back for your app and allow you to complete the
|
||||
* verification process by verifying both the **userId** and **secret**
|
||||
* parameters. Learn more about how to [complete the verification
|
||||
* process](/docs/account#updateAccountVerification).
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URLs are the ones from domains you have set when
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* @param {string} url
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
createVerification: function(url) {
|
||||
if(url === undefined) {
|
||||
throw new Error('Missing required parameter: "url"');
|
||||
}
|
||||
|
||||
let path = '/account/verification';
|
||||
|
||||
let payload = {};
|
||||
|
||||
if(url) {
|
||||
payload['url'] = url;
|
||||
}
|
||||
|
||||
return http
|
||||
.post(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Complete Email Verification
|
||||
*
|
||||
* Use this endpoint to complete the user email verification process. Use both
|
||||
* the **userId** and **secret** parameters that were attached to your app URL
|
||||
|
@ -872,11 +866,10 @@
|
|||
*
|
||||
* @param {string} userId
|
||||
* @param {string} secret
|
||||
* @param {string} passwordB
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateVerification: function(userId, secret, passwordB) {
|
||||
updateVerification: function(userId, secret) {
|
||||
if(userId === undefined) {
|
||||
throw new Error('Missing required parameter: "userId"');
|
||||
}
|
||||
|
@ -885,10 +878,6 @@
|
|||
throw new Error('Missing required parameter: "secret"');
|
||||
}
|
||||
|
||||
if(passwordB === undefined) {
|
||||
throw new Error('Missing required parameter: "passwordB"');
|
||||
}
|
||||
|
||||
let path = '/account/verification';
|
||||
|
||||
let payload = {};
|
||||
|
@ -901,10 +890,6 @@
|
|||
payload['secret'] = secret;
|
||||
}
|
||||
|
||||
if(passwordB) {
|
||||
payload['password-b'] = passwordB;
|
||||
}
|
||||
|
||||
return http
|
||||
.put(path, {
|
||||
'content-type': 'application/json',
|
||||
|
@ -1156,209 +1141,6 @@
|
|||
|
||||
let database = {
|
||||
|
||||
/**
|
||||
* List Collections
|
||||
*
|
||||
* Get a list of all the user collections. You can use the query params to
|
||||
* filter your results. On admin mode, this endpoint will return a list of all
|
||||
* of the project collections. [Learn more about different API
|
||||
* modes](/docs/admin).
|
||||
*
|
||||
* @param {string} search
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @param {string} orderType
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
listCollections: function(search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||
let path = '/database/collections';
|
||||
|
||||
let payload = {};
|
||||
|
||||
if(search) {
|
||||
payload['search'] = search;
|
||||
}
|
||||
|
||||
if(limit) {
|
||||
payload['limit'] = limit;
|
||||
}
|
||||
|
||||
if(offset) {
|
||||
payload['offset'] = offset;
|
||||
}
|
||||
|
||||
if(orderType) {
|
||||
payload['orderType'] = orderType;
|
||||
}
|
||||
|
||||
return http
|
||||
.get(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create Collection
|
||||
*
|
||||
* Create a new Collection.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {array} rules
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
createCollection: function(name, read, write, rules) {
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(read === undefined) {
|
||||
throw new Error('Missing required parameter: "read"');
|
||||
}
|
||||
|
||||
if(write === undefined) {
|
||||
throw new Error('Missing required parameter: "write"');
|
||||
}
|
||||
|
||||
if(rules === undefined) {
|
||||
throw new Error('Missing required parameter: "rules"');
|
||||
}
|
||||
|
||||
let path = '/database/collections';
|
||||
|
||||
let payload = {};
|
||||
|
||||
if(name) {
|
||||
payload['name'] = name;
|
||||
}
|
||||
|
||||
if(read) {
|
||||
payload['read'] = read;
|
||||
}
|
||||
|
||||
if(write) {
|
||||
payload['write'] = write;
|
||||
}
|
||||
|
||||
if(rules) {
|
||||
payload['rules'] = rules;
|
||||
}
|
||||
|
||||
return http
|
||||
.post(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* Get collection by its unique ID. This endpoint response returns a JSON
|
||||
* object with the collection metadata.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
getCollection: function(collectionId) {
|
||||
if(collectionId === undefined) {
|
||||
throw new Error('Missing required parameter: "collectionId"');
|
||||
}
|
||||
|
||||
let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId);
|
||||
|
||||
let payload = {};
|
||||
|
||||
return http
|
||||
.get(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Collection
|
||||
*
|
||||
* Update collection by its unique ID.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @param {string} name
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {array} rules
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateCollection: function(collectionId, name, read, write, rules = []) {
|
||||
if(collectionId === undefined) {
|
||||
throw new Error('Missing required parameter: "collectionId"');
|
||||
}
|
||||
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(read === undefined) {
|
||||
throw new Error('Missing required parameter: "read"');
|
||||
}
|
||||
|
||||
if(write === undefined) {
|
||||
throw new Error('Missing required parameter: "write"');
|
||||
}
|
||||
|
||||
let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId);
|
||||
|
||||
let payload = {};
|
||||
|
||||
if(name) {
|
||||
payload['name'] = name;
|
||||
}
|
||||
|
||||
if(read) {
|
||||
payload['read'] = read;
|
||||
}
|
||||
|
||||
if(write) {
|
||||
payload['write'] = write;
|
||||
}
|
||||
|
||||
if(rules) {
|
||||
payload['rules'] = rules;
|
||||
}
|
||||
|
||||
return http
|
||||
.put(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete Collection
|
||||
*
|
||||
* Delete a collection by its unique ID. Only users with write permissions
|
||||
* have access to delete this resource.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
deleteCollection: function(collectionId) {
|
||||
if(collectionId === undefined) {
|
||||
throw new Error('Missing required parameter: "collectionId"');
|
||||
}
|
||||
|
||||
let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId);
|
||||
|
||||
let payload = {};
|
||||
|
||||
return http
|
||||
.delete(path, {
|
||||
'content-type': 'application/json',
|
||||
}, payload);
|
||||
},
|
||||
|
||||
/**
|
||||
* List Documents
|
||||
*
|
||||
|
@ -1437,7 +1219,7 @@
|
|||
* Create a new Document.
|
||||
*
|
||||
* @param {string} collectionId
|
||||
* @param {string} data
|
||||
* @param {object} data
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @param {string} parentDocument
|
||||
|
@ -1533,7 +1315,7 @@
|
|||
*
|
||||
* @param {string} collectionId
|
||||
* @param {string} documentId
|
||||
* @param {string} data
|
||||
* @param {object} data
|
||||
* @param {array} read
|
||||
* @param {array} write
|
||||
* @throws {Error}
|
||||
|
@ -2226,14 +2008,14 @@
|
|||
/**
|
||||
* Create Team Membership
|
||||
*
|
||||
* Use this endpoint to invite a new member to your team. An email with a link
|
||||
* to join the team will be sent to the new member email address. If member
|
||||
* doesn't exists in the project it will be automatically created.
|
||||
* Use this endpoint to invite a new member to join your team. An email with a
|
||||
* link to join the team will be sent to the new member email address if the
|
||||
* member doesn't exist in the project it will be created automatically.
|
||||
*
|
||||
* Use the 'url' parameter to redirect the user from the invitation email back
|
||||
* Use the 'URL' parameter to redirect the user from the invitation email back
|
||||
* to your app. When the user is redirected, use the [Update Team Membership
|
||||
* Status](/docs/teams#updateTeamMembershipStatus) endpoint to finally join
|
||||
* the user to the team.
|
||||
* Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to
|
||||
* accept the invitation to the team.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
|
@ -2325,21 +2107,9 @@
|
|||
/**
|
||||
* Update Team Membership Status
|
||||
*
|
||||
* Use this endpoint to let user accept an invitation to join a team after he
|
||||
* is being redirect back to your app from the invitation email. Use the
|
||||
* success and failure URL's to redirect users back to your application after
|
||||
* the request completes.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URL's are the once from domains you have set when
|
||||
* added your platforms in the console interface.
|
||||
*
|
||||
* When not using the success or failure redirect arguments this endpoint will
|
||||
* result with a 200 status code on success and with 401 status error on
|
||||
* failure. This behavior was applied to help the web clients deal with
|
||||
* browsers who don't allow to set 3rd party HTTP cookies needed for saving
|
||||
* the account session key.
|
||||
* Use this endpoint to allow a user to accept an invitation to join a team
|
||||
* after he is being redirected back to your app from the invitation email he
|
||||
* was sent.
|
||||
*
|
||||
* @param {string} teamId
|
||||
* @param {string} inviteId
|
||||
|
|
34
app/sdks/javascript/src/sdk.min.js
vendored
34
app/sdks/javascript/src/sdk.min.js
vendored
|
@ -44,18 +44,18 @@ return http.put(path,{'content-type':'application/json',},payload)},getSessions:
|
|||
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
||||
let path='/account/sessions';let payload={};if(email){payload.email=email}
|
||||
if(password){payload.password=password}
|
||||
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},deleteCurrentSession:function(){let path='/account/sessions/current';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuthSession:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
||||
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuthSession:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
||||
if(success===undefined){throw new Error('Missing required parameter: "success"')}
|
||||
if(failure===undefined){throw new Error('Missing required parameter: "failure"')}
|
||||
let path='/account/sessions/oauth/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success}
|
||||
if(failure){payload.failure=failure}
|
||||
return http.get(path,{'content-type':'application/json',},payload)},deleteSession:function(id){if(id===undefined){throw new Error('Missing required parameter: "id"')}
|
||||
let path='/account/sessions/{id}'.replace(new RegExp('{id}','g'),id);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateVerification:function(userId,secret,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
return http.get(path,{'content-type':'application/json',},payload)},deleteSession:function(sessionUid){if(sessionUid===undefined){throw new Error('Missing required parameter: "sessionUid"')}
|
||||
let path='/account/sessions/{sessionUid}'.replace(new RegExp('{sessionUid}','g'),sessionUid);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createVerification:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')}
|
||||
let path='/account/verification';let payload={};if(url){payload.url=url}
|
||||
return http.post(path,{'content-type':'application/json',},payload)},updateVerification:function(userId,secret){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||
if(secret===undefined){throw new Error('Missing required parameter: "secret"')}
|
||||
if(passwordB===undefined){throw new Error('Missing required parameter: "passwordB"')}
|
||||
let path='/account/verification';let payload={};if(userId){payload.userId=userId}
|
||||
if(secret){payload.secret=secret}
|
||||
if(passwordB){payload['password-b']=passwordB}
|
||||
return http.put(path,{'content-type':'application/json',},payload)}};let avatars={getBrowser:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')}
|
||||
let path='/avatars/browsers/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width}
|
||||
if(height){payload.height=height}
|
||||
|
@ -79,29 +79,7 @@ let path='/avatars/qr';let payload={};if(text){payload.text=text}
|
|||
if(size){payload.size=size}
|
||||
if(margin){payload.margin=margin}
|
||||
if(download){payload.download=download}
|
||||
return http.get(path,{'content-type':'application/json',},payload)}};let database={listCollections:function(search='',limit=25,offset=0,orderType='ASC'){let path='/database/collections';let payload={};if(search){payload.search=search}
|
||||
if(limit){payload.limit=limit}
|
||||
if(offset){payload.offset=offset}
|
||||
if(orderType){payload.orderType=orderType}
|
||||
return http.get(path,{'content-type':'application/json',},payload)},createCollection:function(name,read,write,rules){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
if(read===undefined){throw new Error('Missing required parameter: "read"')}
|
||||
if(write===undefined){throw new Error('Missing required parameter: "write"')}
|
||||
if(rules===undefined){throw new Error('Missing required parameter: "rules"')}
|
||||
let path='/database/collections';let payload={};if(name){payload.name=name}
|
||||
if(read){payload.read=read}
|
||||
if(write){payload.write=write}
|
||||
if(rules){payload.rules=rules}
|
||||
return http.post(path,{'content-type':'application/json',},payload)},getCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},updateCollection:function(collectionId,name,read,write,rules=[]){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
if(read===undefined){throw new Error('Missing required parameter: "read"')}
|
||||
if(write===undefined){throw new Error('Missing required parameter: "write"')}
|
||||
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(name){payload.name=name}
|
||||
if(read){payload.read=read}
|
||||
if(write){payload.write=write}
|
||||
if(rules){payload.rules=rules}
|
||||
return http.put(path,{'content-type':'application/json',},payload)},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
return http.get(path,{'content-type':'application/json',},payload)}};let database={listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||
let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload.filters=filters}
|
||||
if(offset){payload.offset=offset}
|
||||
if(limit){payload.limit=limit}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Appwrite SDK for NodeJS
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.4.0-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
|
||||
|
||||
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = database.createDocument('[COLLECTION_ID]', '{}', [], []);
|
||||
let promise = database.createDocument('[COLLECTION_ID]', {}, [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', '{}', [], []);
|
||||
let promise = database.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {}, [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.createFile(document.getElementById('uploader').files[0], [], []);
|
||||
let promise = storage.createFile(fs.createReadStream(__dirname + '/file.png')), [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.create(document.getElementById('uploader').files[0], [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.delete('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.getDownload('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.getPreview('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.getView('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.get('[FILE_ID]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.list();
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let storage = new sdk.Storage(client);
|
||||
|
||||
client
|
||||
.setProject('')
|
||||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = storage.update('[FILE_ID]', [], []);
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('')
|
||||
;
|
||||
|
||||
let promise = users.updatePrefs('[USER_ID]', '');
|
||||
let promise = users.updatePrefs('[USER_ID]', {});
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -99,23 +99,49 @@ class Client {
|
|||
return this;
|
||||
}
|
||||
|
||||
call(method, path = '', headers = {}, params = {}) {
|
||||
async call(method, path = '', headers = {}, params = {}) {
|
||||
if(this.selfSigned) { // Allow self signed requests
|
||||
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||
}
|
||||
|
||||
headers = Object.assign(this.headers, headers);
|
||||
|
||||
|
||||
let contentType = headers['content-type'].toLowerCase();
|
||||
let options = {
|
||||
method: method.toUpperCase(),
|
||||
uri: this.endpoint + path,
|
||||
qs: (method.toUpperCase() === 'GET') ? params : {},
|
||||
headers: headers,
|
||||
body: (method.toUpperCase() === 'GET') ? '' : params,
|
||||
json: (headers['content-type'].toLowerCase().startsWith('application/json')),
|
||||
body: (method.toUpperCase() === 'GET' || contentType.startsWith('multipart/form-data')) ? null : params,
|
||||
json: (contentType.startsWith('application/json')),
|
||||
formData: (contentType.startsWith('multipart/form-data')) ? this.flatten(params) : null,
|
||||
};
|
||||
|
||||
return request(options);
|
||||
let response = await request(options);
|
||||
|
||||
if(contentType.startsWith('multipart/form-data')) {
|
||||
response = JSON.parse(response);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
flatten(data, prefix = '') {
|
||||
let output = {};
|
||||
|
||||
for (const key in data) {
|
||||
let value = data[key];
|
||||
let finalKey = prefix ? prefix + '[' + key +']' : key;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed
|
||||
}
|
||||
else {
|
||||
output[finalKey] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ class Database extends Service {
|
|||
* Create a new Document.
|
||||
*
|
||||
* @param string collectionId
|
||||
* @param string data
|
||||
* @param object data
|
||||
* @param array read
|
||||
* @param array write
|
||||
* @param string parentDocument
|
||||
|
@ -221,7 +221,7 @@ class Database extends Service {
|
|||
*
|
||||
* @param string collectionId
|
||||
* @param string documentId
|
||||
* @param string data
|
||||
* @param object data
|
||||
* @param array read
|
||||
* @param array write
|
||||
* @throws Exception
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue