appwrite 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +72 -3
- data/appwrite.gemspec +2 -2
- data/docs/examples/account/create-recovery.md +15 -0
- data/docs/examples/account/create-verification.md +15 -0
- data/docs/examples/account/delete-session.md +15 -0
- data/docs/examples/account/delete-sessions.md +15 -0
- data/docs/examples/account/delete.md +15 -0
- data/docs/examples/account/get-logs.md +15 -0
- data/docs/examples/account/get-prefs.md +15 -0
- data/docs/examples/account/get-sessions.md +15 -0
- data/docs/examples/account/get.md +15 -0
- data/docs/examples/account/update-email.md +15 -0
- data/docs/examples/account/update-name.md +15 -0
- data/docs/examples/account/update-password.md +15 -0
- data/docs/examples/account/update-prefs.md +15 -0
- data/docs/examples/account/update-recovery.md +15 -0
- data/docs/examples/account/update-verification.md +15 -0
- data/docs/examples/database/create-document.md +1 -1
- data/docs/examples/database/update-collection.md +1 -1
- data/docs/examples/database/update-document.md +1 -1
- data/docs/examples/functions/create.md +1 -1
- data/docs/examples/storage/create-file.md +1 -1
- data/docs/examples/teams/delete-membership.md +1 -1
- data/docs/examples/teams/update-membership-roles.md +15 -0
- data/docs/examples/teams/update-membership-status.md +15 -0
- data/docs/examples/users/{delete-user.md → delete.md} +1 -1
- data/docs/examples/users/update-status.md +1 -1
- data/lib/appwrite.rb +2 -0
- data/lib/appwrite/client.rb +20 -4
- data/lib/appwrite/exception.rb +14 -0
- data/lib/appwrite/services/account.rb +190 -0
- data/lib/appwrite/services/database.rb +3 -3
- data/lib/appwrite/services/functions.rb +2 -1
- data/lib/appwrite/services/storage.rb +7 -2
- data/lib/appwrite/services/teams.rb +32 -3
- data/lib/appwrite/services/users.rb +1 -1
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60c647c8e3078dfcaf45b0f34cdd816df13d2c8bece8b86c89be41264ea04933
|
4
|
+
data.tar.gz: 85d0f920c5004020948bee06cb900db62f31f15570f0153c9a15fec633169981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b12a4dd2b4ccef9fddfa8e9648cd54398d2d764c63a3e6ffcd90b3aef2812987f471b93b7cc061a3ebd988e32bb7d5eb8f78984e6e383a7a559484c58080fd5
|
7
|
+
data.tar.gz: 6338164ad49b29ccf0c6c642ba97a86206bdfac6395df959b435b4234d7c4304fce32d556fa591d8106a63b8d19cc4c1d695ab556a01979934cf769f8e51fa4f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Appwrite Ruby SDK
|
2
2
|
|
3
|
-
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?
|
4
|
-
![Version](https://img.shields.io/badge/api%20version-0.
|
3
|
+
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square)
|
4
|
+
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
|
5
|
+
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
|
6
|
+
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
|
5
7
|
|
6
|
-
**This SDK is compatible with Appwrite server version 0.
|
8
|
+
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).**
|
7
9
|
|
8
10
|
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.
|
9
11
|
Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
@@ -19,6 +21,73 @@ To install via [Gem](https://rubygems.org/):
|
|
19
21
|
gem install appwrite --save
|
20
22
|
```
|
21
23
|
|
24
|
+
|
25
|
+
## Getting Started
|
26
|
+
|
27
|
+
### Init your SDK
|
28
|
+
Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'appwrite'
|
32
|
+
|
33
|
+
client = Appwrite::Client.new()
|
34
|
+
|
35
|
+
client
|
36
|
+
.set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint
|
37
|
+
.set_project(ENV["APPWRITE_PROJECT"]) # Your project ID
|
38
|
+
.set_key(ENV["APPWRITE_SECRET"]) # Your secret API key
|
39
|
+
.setSelfSigned() # Use only on dev mode with a self-signed SSL cert
|
40
|
+
;
|
41
|
+
```
|
42
|
+
|
43
|
+
### Make Your First Request
|
44
|
+
Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
users = Appwrite::Users.new(client);
|
48
|
+
|
49
|
+
result = users.create(email: 'email@example.com', password: 'password');
|
50
|
+
```
|
51
|
+
|
52
|
+
### Full Example
|
53
|
+
```ruby
|
54
|
+
require 'appwrite'
|
55
|
+
|
56
|
+
client = Appwrite::Client.new()
|
57
|
+
|
58
|
+
client
|
59
|
+
.set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint
|
60
|
+
.set_project(ENV["APPWRITE_PROJECT"]) # Your project ID
|
61
|
+
.set_key(ENV["APPWRITE_SECRET"]) # Your secret API key
|
62
|
+
.setSelfSigned() # Use only on dev mode with a self-signed SSL cert
|
63
|
+
;
|
64
|
+
|
65
|
+
users = Appwrite::Users.new(client);
|
66
|
+
|
67
|
+
result = users.create(email: 'email@example.com', password: 'password');
|
68
|
+
```
|
69
|
+
|
70
|
+
### Error Handling
|
71
|
+
The Appwrite Ruby SDK raises `Appwrite::Exception` object with `message`, `code` and `response` properties. You can handle any errors by catching `Appwrite::Exception` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
users = Appwrite::Users.new(client);
|
75
|
+
|
76
|
+
begin
|
77
|
+
result = users.create(email: 'email@example.com', password: 'password');
|
78
|
+
rescue Appwrite::Exception => error
|
79
|
+
puts error.message
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
### Learn more
|
84
|
+
You can use followng resources to learn more and get help
|
85
|
+
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
|
86
|
+
- 📜 [Appwrite Docs](https://appwrite.io/docs)
|
87
|
+
- 💬 [Discord Community](https://appwrite.io/discord)
|
88
|
+
- 🚂 [Appwrite Ruby Playground](https://github.com/appwrite/playground-for-ruby)
|
89
|
+
|
90
|
+
|
22
91
|
## Contribution
|
23
92
|
|
24
93
|
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
|
data/appwrite.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'appwrite'
|
4
|
-
s.version = '2.0
|
4
|
+
s.version = '2.1.0'
|
5
5
|
s.summary = "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API"
|
6
6
|
s.author = 'Appwrite Team'
|
7
7
|
s.homepage = 'https://appwrite.io/support'
|
8
8
|
s.email = 'team@appwrite.io'
|
9
9
|
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
10
10
|
|
11
|
-
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.create_recovery(email: 'email@example.com', url: 'https://example.com');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.create_verification(url: 'https://example.com');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.delete_session(session_id: '[SESSION_ID]');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.delete_sessions();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.delete();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.get_logs();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.get_prefs();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.get_sessions();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.get();
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_email(email: 'email@example.com', password: 'password');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_name(name: '[NAME]');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_password(password: 'password');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_prefs(prefs: {});
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_recovery(user_id: '[USER_ID]', secret: '[SECRET]', password: 'password', password_again: 'password');
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
account = Appwrite::Account.new(client);
|
12
|
+
|
13
|
+
response = account.update_verification(user_id: '[USER_ID]', secret: '[SECRET]');
|
14
|
+
|
15
|
+
puts response
|
@@ -10,6 +10,6 @@ client
|
|
10
10
|
|
11
11
|
database = Appwrite::Database.new(client);
|
12
12
|
|
13
|
-
response = database.create_document(collection_id: '[COLLECTION_ID]', data: {}
|
13
|
+
response = database.create_document(collection_id: '[COLLECTION_ID]', data: {});
|
14
14
|
|
15
15
|
puts response
|
@@ -10,6 +10,6 @@ client
|
|
10
10
|
|
11
11
|
database = Appwrite::Database.new(client);
|
12
12
|
|
13
|
-
response = database.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]'
|
13
|
+
response = database.update_collection(collection_id: '[COLLECTION_ID]', name: '[NAME]');
|
14
14
|
|
15
15
|
puts response
|
@@ -10,6 +10,6 @@ client
|
|
10
10
|
|
11
11
|
database = Appwrite::Database.new(client);
|
12
12
|
|
13
|
-
response = database.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {}
|
13
|
+
response = database.update_document(collection_id: '[COLLECTION_ID]', document_id: '[DOCUMENT_ID]', data: {});
|
14
14
|
|
15
15
|
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
9
|
+
;
|
10
|
+
|
11
|
+
teams = Appwrite::Teams.new(client);
|
12
|
+
|
13
|
+
response = teams.update_membership_roles(team_id: '[TEAM_ID]', membership_id: '[MEMBERSHIP_ID]', roles: []);
|
14
|
+
|
15
|
+
puts response
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'appwrite'
|
2
|
+
|
3
|
+
client = Appwrite::Client.new()
|
4
|
+
|
5
|
+
client
|
6
|
+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
|
7
|
+
.set_project('5df5acd0d48c2') # Your project ID
|
8
|
+
.set_j_w_t('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
|
9
|
+
;
|
10
|
+
|
11
|
+
teams = Appwrite::Teams.new(client);
|
12
|
+
|
13
|
+
response = teams.update_membership_status(team_id: '[TEAM_ID]', membership_id: '[MEMBERSHIP_ID]', user_id: '[USER_ID]', secret: '[SECRET]');
|
14
|
+
|
15
|
+
puts response
|
data/lib/appwrite.rb
CHANGED
@@ -4,7 +4,9 @@ require 'json'
|
|
4
4
|
require 'mime/types'
|
5
5
|
require_relative 'appwrite/client'
|
6
6
|
require_relative 'appwrite/service'
|
7
|
+
require_relative 'appwrite/exception'
|
7
8
|
require_relative 'appwrite/file'
|
9
|
+
require_relative 'appwrite/services/account'
|
8
10
|
require_relative 'appwrite/services/avatars'
|
9
11
|
require_relative 'appwrite/services/database'
|
10
12
|
require_relative 'appwrite/services/functions'
|
data/lib/appwrite/client.rb
CHANGED
@@ -20,8 +20,8 @@ module Appwrite
|
|
20
20
|
@headers = {
|
21
21
|
'content-type' => '',
|
22
22
|
'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION,
|
23
|
-
'x-sdk-version' => 'appwrite:ruby:2.
|
24
|
-
|
23
|
+
'x-sdk-version' => 'appwrite:ruby:2.1.0',
|
24
|
+
'X-Appwrite-Response-Format' => '0.8.0'
|
25
25
|
}
|
26
26
|
@endpoint = 'https://appwrite.io/v1';
|
27
27
|
end
|
@@ -38,6 +38,12 @@ module Appwrite
|
|
38
38
|
return self
|
39
39
|
end
|
40
40
|
|
41
|
+
def set_j_w_t(value)
|
42
|
+
add_header('x-appwrite-jwt', value)
|
43
|
+
|
44
|
+
return self
|
45
|
+
end
|
46
|
+
|
41
47
|
def set_locale(value)
|
42
48
|
add_header('x-appwrite-locale', value)
|
43
49
|
|
@@ -89,7 +95,7 @@ module Appwrite
|
|
89
95
|
begin
|
90
96
|
response = http.send_request(method.upcase, uri.request_uri, payload, headers)
|
91
97
|
rescue => error
|
92
|
-
raise
|
98
|
+
raise Appwrite::Exception.new(error.message)
|
93
99
|
end
|
94
100
|
|
95
101
|
# Handle Redirects
|
@@ -99,8 +105,18 @@ module Appwrite
|
|
99
105
|
|
100
106
|
return fetch(method, uri, headers, {}, limit - 1)
|
101
107
|
end
|
108
|
+
|
109
|
+
begin
|
110
|
+
res = JSON.parse(response.body);
|
111
|
+
rescue JSON::ParserError => e
|
112
|
+
raise Appwrite::Exception.new(response.body, response.code, nil)
|
113
|
+
end
|
114
|
+
|
115
|
+
if(response.code.to_i >= 400)
|
116
|
+
raise Appwrite::Exception.new(res['message'], res['status'], res)
|
117
|
+
end
|
102
118
|
|
103
|
-
return
|
119
|
+
return res;
|
104
120
|
end
|
105
121
|
|
106
122
|
def encodeFormData(value, key=nil)
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Appwrite
|
2
|
+
class Account < Service
|
3
|
+
|
4
|
+
def get()
|
5
|
+
path = '/account'
|
6
|
+
|
7
|
+
params = {
|
8
|
+
}
|
9
|
+
|
10
|
+
return @client.call('get', path, {
|
11
|
+
'content-type' => 'application/json',
|
12
|
+
}, params);
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete()
|
16
|
+
path = '/account'
|
17
|
+
|
18
|
+
params = {
|
19
|
+
}
|
20
|
+
|
21
|
+
return @client.call('delete', path, {
|
22
|
+
'content-type' => 'application/json',
|
23
|
+
}, params);
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_email(email:, password:)
|
27
|
+
path = '/account/email'
|
28
|
+
|
29
|
+
params = {
|
30
|
+
'email': email,
|
31
|
+
'password': password
|
32
|
+
}
|
33
|
+
|
34
|
+
return @client.call('patch', path, {
|
35
|
+
'content-type' => 'application/json',
|
36
|
+
}, params);
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_logs()
|
40
|
+
path = '/account/logs'
|
41
|
+
|
42
|
+
params = {
|
43
|
+
}
|
44
|
+
|
45
|
+
return @client.call('get', path, {
|
46
|
+
'content-type' => 'application/json',
|
47
|
+
}, params);
|
48
|
+
end
|
49
|
+
|
50
|
+
def update_name(name:)
|
51
|
+
path = '/account/name'
|
52
|
+
|
53
|
+
params = {
|
54
|
+
'name': name
|
55
|
+
}
|
56
|
+
|
57
|
+
return @client.call('patch', path, {
|
58
|
+
'content-type' => 'application/json',
|
59
|
+
}, params);
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_password(password:, old_password: '')
|
63
|
+
path = '/account/password'
|
64
|
+
|
65
|
+
params = {
|
66
|
+
'password': password,
|
67
|
+
'oldPassword': old_password
|
68
|
+
}
|
69
|
+
|
70
|
+
return @client.call('patch', path, {
|
71
|
+
'content-type' => 'application/json',
|
72
|
+
}, params);
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_prefs()
|
76
|
+
path = '/account/prefs'
|
77
|
+
|
78
|
+
params = {
|
79
|
+
}
|
80
|
+
|
81
|
+
return @client.call('get', path, {
|
82
|
+
'content-type' => 'application/json',
|
83
|
+
}, params);
|
84
|
+
end
|
85
|
+
|
86
|
+
def update_prefs(prefs:)
|
87
|
+
path = '/account/prefs'
|
88
|
+
|
89
|
+
params = {
|
90
|
+
'prefs': prefs
|
91
|
+
}
|
92
|
+
|
93
|
+
return @client.call('patch', path, {
|
94
|
+
'content-type' => 'application/json',
|
95
|
+
}, params);
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_recovery(email:, url:)
|
99
|
+
path = '/account/recovery'
|
100
|
+
|
101
|
+
params = {
|
102
|
+
'email': email,
|
103
|
+
'url': url
|
104
|
+
}
|
105
|
+
|
106
|
+
return @client.call('post', path, {
|
107
|
+
'content-type' => 'application/json',
|
108
|
+
}, params);
|
109
|
+
end
|
110
|
+
|
111
|
+
def update_recovery(user_id:, secret:, password:, password_again:)
|
112
|
+
path = '/account/recovery'
|
113
|
+
|
114
|
+
params = {
|
115
|
+
'userId': user_id,
|
116
|
+
'secret': secret,
|
117
|
+
'password': password,
|
118
|
+
'passwordAgain': password_again
|
119
|
+
}
|
120
|
+
|
121
|
+
return @client.call('put', path, {
|
122
|
+
'content-type' => 'application/json',
|
123
|
+
}, params);
|
124
|
+
end
|
125
|
+
|
126
|
+
def get_sessions()
|
127
|
+
path = '/account/sessions'
|
128
|
+
|
129
|
+
params = {
|
130
|
+
}
|
131
|
+
|
132
|
+
return @client.call('get', path, {
|
133
|
+
'content-type' => 'application/json',
|
134
|
+
}, params);
|
135
|
+
end
|
136
|
+
|
137
|
+
def delete_sessions()
|
138
|
+
path = '/account/sessions'
|
139
|
+
|
140
|
+
params = {
|
141
|
+
}
|
142
|
+
|
143
|
+
return @client.call('delete', path, {
|
144
|
+
'content-type' => 'application/json',
|
145
|
+
}, params);
|
146
|
+
end
|
147
|
+
|
148
|
+
def delete_session(session_id:)
|
149
|
+
path = '/account/sessions/{sessionId}'
|
150
|
+
.gsub('{sessionId}', session_id)
|
151
|
+
|
152
|
+
params = {
|
153
|
+
}
|
154
|
+
|
155
|
+
return @client.call('delete', path, {
|
156
|
+
'content-type' => 'application/json',
|
157
|
+
}, params);
|
158
|
+
end
|
159
|
+
|
160
|
+
def create_verification(url:)
|
161
|
+
path = '/account/verification'
|
162
|
+
|
163
|
+
params = {
|
164
|
+
'url': url
|
165
|
+
}
|
166
|
+
|
167
|
+
return @client.call('post', path, {
|
168
|
+
'content-type' => 'application/json',
|
169
|
+
}, params);
|
170
|
+
end
|
171
|
+
|
172
|
+
def update_verification(user_id:, secret:)
|
173
|
+
path = '/account/verification'
|
174
|
+
|
175
|
+
params = {
|
176
|
+
'userId': user_id,
|
177
|
+
'secret': secret
|
178
|
+
}
|
179
|
+
|
180
|
+
return @client.call('put', path, {
|
181
|
+
'content-type' => 'application/json',
|
182
|
+
}, params);
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
protected
|
187
|
+
|
188
|
+
private
|
189
|
+
end
|
190
|
+
end
|
@@ -43,7 +43,7 @@ module Appwrite
|
|
43
43
|
}, params);
|
44
44
|
end
|
45
45
|
|
46
|
-
def update_collection(collection_id:, name:, read
|
46
|
+
def update_collection(collection_id:, name:, read: [], write: [], rules: [])
|
47
47
|
path = '/database/collections/{collectionId}'
|
48
48
|
.gsub('{collectionId}', collection_id)
|
49
49
|
|
@@ -90,7 +90,7 @@ module Appwrite
|
|
90
90
|
}, params);
|
91
91
|
end
|
92
92
|
|
93
|
-
def create_document(collection_id:, data:, read
|
93
|
+
def create_document(collection_id:, data:, read: [], write: [], parent_document: '', parent_property: '', parent_property_type: 'assign')
|
94
94
|
path = '/database/collections/{collectionId}/documents'
|
95
95
|
.gsub('{collectionId}', collection_id)
|
96
96
|
|
@@ -121,7 +121,7 @@ module Appwrite
|
|
121
121
|
}, params);
|
122
122
|
end
|
123
123
|
|
124
|
-
def update_document(collection_id:, document_id:, data:, read
|
124
|
+
def update_document(collection_id:, document_id:, data:, read: [], write: [])
|
125
125
|
path = '/database/collections/{collectionId}/documents/{documentId}'
|
126
126
|
.gsub('{collectionId}', collection_id)
|
127
127
|
.gsub('{documentId}', document_id)
|
@@ -92,11 +92,12 @@ module Appwrite
|
|
92
92
|
}, params);
|
93
93
|
end
|
94
94
|
|
95
|
-
def create_execution(function_id:)
|
95
|
+
def create_execution(function_id:, data: '')
|
96
96
|
path = '/functions/{functionId}/executions'
|
97
97
|
.gsub('{functionId}', function_id)
|
98
98
|
|
99
99
|
params = {
|
100
|
+
'data': data
|
100
101
|
}
|
101
102
|
|
102
103
|
return @client.call('post', path, {
|
@@ -16,7 +16,7 @@ module Appwrite
|
|
16
16
|
}, params);
|
17
17
|
end
|
18
18
|
|
19
|
-
def create_file(file:, read
|
19
|
+
def create_file(file:, read: [], write: [])
|
20
20
|
path = '/storage/files'
|
21
21
|
|
22
22
|
params = {
|
@@ -80,7 +80,7 @@ module Appwrite
|
|
80
80
|
}, params);
|
81
81
|
end
|
82
82
|
|
83
|
-
def get_file_preview(file_id:, width: 0, height: 0, quality: 100, background: '', output: '')
|
83
|
+
def get_file_preview(file_id:, width: 0, height: 0, quality: 100, border_width: 0, border_color: '', border_radius: 0, opacity: 1, rotation: 0, background: '', output: '')
|
84
84
|
path = '/storage/files/{fileId}/preview'
|
85
85
|
.gsub('{fileId}', file_id)
|
86
86
|
|
@@ -88,6 +88,11 @@ module Appwrite
|
|
88
88
|
'width': width,
|
89
89
|
'height': height,
|
90
90
|
'quality': quality,
|
91
|
+
'borderWidth': border_width,
|
92
|
+
'borderColor': border_color,
|
93
|
+
'borderRadius': border_radius,
|
94
|
+
'opacity': opacity,
|
95
|
+
'rotation': rotation,
|
91
96
|
'background': background,
|
92
97
|
'output': output
|
93
98
|
}
|
@@ -98,10 +98,24 @@ module Appwrite
|
|
98
98
|
}, params);
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
102
|
-
path = '/teams/{teamId}/memberships/{
|
101
|
+
def update_membership_roles(team_id:, membership_id:, roles:)
|
102
|
+
path = '/teams/{teamId}/memberships/{membershipId}'
|
103
103
|
.gsub('{teamId}', team_id)
|
104
|
-
.gsub('{
|
104
|
+
.gsub('{membershipId}', membership_id)
|
105
|
+
|
106
|
+
params = {
|
107
|
+
'roles': roles
|
108
|
+
}
|
109
|
+
|
110
|
+
return @client.call('patch', path, {
|
111
|
+
'content-type' => 'application/json',
|
112
|
+
}, params);
|
113
|
+
end
|
114
|
+
|
115
|
+
def delete_membership(team_id:, membership_id:)
|
116
|
+
path = '/teams/{teamId}/memberships/{membershipId}'
|
117
|
+
.gsub('{teamId}', team_id)
|
118
|
+
.gsub('{membershipId}', membership_id)
|
105
119
|
|
106
120
|
params = {
|
107
121
|
}
|
@@ -111,6 +125,21 @@ module Appwrite
|
|
111
125
|
}, params);
|
112
126
|
end
|
113
127
|
|
128
|
+
def update_membership_status(team_id:, membership_id:, user_id:, secret:)
|
129
|
+
path = '/teams/{teamId}/memberships/{membershipId}/status'
|
130
|
+
.gsub('{teamId}', team_id)
|
131
|
+
.gsub('{membershipId}', membership_id)
|
132
|
+
|
133
|
+
params = {
|
134
|
+
'userId': user_id,
|
135
|
+
'secret': secret
|
136
|
+
}
|
137
|
+
|
138
|
+
return @client.call('patch', path, {
|
139
|
+
'content-type' => 'application/json',
|
140
|
+
}, params);
|
141
|
+
end
|
142
|
+
|
114
143
|
|
115
144
|
protected
|
116
145
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appwrite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Appwrite Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: team@appwrite.io
|
@@ -22,6 +22,21 @@ files:
|
|
22
22
|
- LICENSE
|
23
23
|
- README.md
|
24
24
|
- appwrite.gemspec
|
25
|
+
- docs/examples/account/create-recovery.md
|
26
|
+
- docs/examples/account/create-verification.md
|
27
|
+
- docs/examples/account/delete-session.md
|
28
|
+
- docs/examples/account/delete-sessions.md
|
29
|
+
- docs/examples/account/delete.md
|
30
|
+
- docs/examples/account/get-logs.md
|
31
|
+
- docs/examples/account/get-prefs.md
|
32
|
+
- docs/examples/account/get-sessions.md
|
33
|
+
- docs/examples/account/get.md
|
34
|
+
- docs/examples/account/update-email.md
|
35
|
+
- docs/examples/account/update-name.md
|
36
|
+
- docs/examples/account/update-password.md
|
37
|
+
- docs/examples/account/update-prefs.md
|
38
|
+
- docs/examples/account/update-recovery.md
|
39
|
+
- docs/examples/account/update-verification.md
|
25
40
|
- docs/examples/avatars/get-browser.md
|
26
41
|
- docs/examples/avatars/get-credit-card.md
|
27
42
|
- docs/examples/avatars/get-favicon.md
|
@@ -86,11 +101,13 @@ files:
|
|
86
101
|
- docs/examples/teams/get-memberships.md
|
87
102
|
- docs/examples/teams/get.md
|
88
103
|
- docs/examples/teams/list.md
|
104
|
+
- docs/examples/teams/update-membership-roles.md
|
105
|
+
- docs/examples/teams/update-membership-status.md
|
89
106
|
- docs/examples/teams/update.md
|
90
107
|
- docs/examples/users/create.md
|
91
108
|
- docs/examples/users/delete-session.md
|
92
109
|
- docs/examples/users/delete-sessions.md
|
93
|
-
- docs/examples/users/delete
|
110
|
+
- docs/examples/users/delete.md
|
94
111
|
- docs/examples/users/get-logs.md
|
95
112
|
- docs/examples/users/get-prefs.md
|
96
113
|
- docs/examples/users/get-sessions.md
|
@@ -100,8 +117,10 @@ files:
|
|
100
117
|
- docs/examples/users/update-status.md
|
101
118
|
- lib/appwrite.rb
|
102
119
|
- lib/appwrite/client.rb
|
120
|
+
- lib/appwrite/exception.rb
|
103
121
|
- lib/appwrite/file.rb
|
104
122
|
- lib/appwrite/service.rb
|
123
|
+
- lib/appwrite/services/account.rb
|
105
124
|
- lib/appwrite/services/avatars.rb
|
106
125
|
- lib/appwrite/services/database.rb
|
107
126
|
- lib/appwrite/services/functions.rb
|