appwrite 1.0.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +16 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +1 -0
- data/LICENSE +1 -1
- data/README.md +80 -7
- 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/avatars/get-browser.md +15 -0
- data/docs/examples/avatars/get-credit-card.md +15 -0
- data/docs/examples/avatars/get-favicon.md +15 -0
- data/docs/examples/avatars/get-flag.md +15 -0
- data/docs/examples/avatars/get-image.md +15 -0
- data/docs/examples/avatars/get-initials.md +15 -0
- data/docs/examples/avatars/get-q-r.md +15 -0
- data/docs/examples/database/create-collection.md +15 -0
- data/docs/examples/database/create-document.md +15 -0
- data/docs/examples/database/delete-collection.md +15 -0
- data/docs/examples/database/delete-document.md +15 -0
- data/docs/examples/database/get-collection.md +15 -0
- data/docs/examples/database/get-document.md +15 -0
- data/docs/examples/database/list-collections.md +15 -0
- data/docs/examples/database/list-documents.md +15 -0
- data/docs/examples/database/update-collection.md +15 -0
- data/docs/examples/database/update-document.md +15 -0
- data/docs/examples/functions/create-execution.md +15 -0
- data/docs/examples/functions/create-tag.md +15 -0
- data/docs/examples/functions/create.md +15 -0
- data/docs/examples/functions/delete-tag.md +15 -0
- data/docs/examples/functions/delete.md +15 -0
- data/docs/examples/functions/get-execution.md +15 -0
- data/docs/examples/functions/get-tag.md +15 -0
- data/docs/examples/functions/get.md +15 -0
- data/docs/examples/functions/list-executions.md +15 -0
- data/docs/examples/functions/list-tags.md +15 -0
- data/docs/examples/functions/list.md +15 -0
- data/docs/examples/functions/update-tag.md +15 -0
- data/docs/examples/functions/update.md +15 -0
- data/docs/examples/health/get-anti-virus.md +15 -0
- data/docs/examples/health/get-cache.md +15 -0
- data/docs/examples/health/get-d-b.md +15 -0
- data/docs/examples/health/get-queue-certificates.md +15 -0
- data/docs/examples/health/get-queue-functions.md +15 -0
- data/docs/examples/health/get-queue-logs.md +15 -0
- data/docs/examples/health/get-queue-tasks.md +15 -0
- data/docs/examples/health/get-queue-usage.md +15 -0
- data/docs/examples/health/get-queue-webhooks.md +15 -0
- data/docs/examples/health/get-storage-local.md +15 -0
- data/docs/examples/health/get-time.md +15 -0
- data/docs/examples/health/get.md +15 -0
- data/docs/examples/locale/get-continents.md +15 -0
- data/docs/examples/locale/get-countries-e-u.md +15 -0
- data/docs/examples/locale/get-countries-phones.md +15 -0
- data/docs/examples/locale/get-countries.md +15 -0
- data/docs/examples/locale/get-currencies.md +15 -0
- data/docs/examples/locale/get-languages.md +15 -0
- data/docs/examples/locale/get.md +15 -0
- data/docs/examples/storage/create-file.md +15 -0
- data/docs/examples/storage/delete-file.md +15 -0
- data/docs/examples/storage/get-file-download.md +15 -0
- data/docs/examples/storage/get-file-preview.md +15 -0
- data/docs/examples/storage/get-file-view.md +15 -0
- data/docs/examples/storage/get-file.md +15 -0
- data/docs/examples/storage/list-files.md +15 -0
- data/docs/examples/storage/update-file.md +15 -0
- data/docs/examples/teams/create-membership.md +15 -0
- data/docs/examples/teams/create.md +15 -0
- data/docs/examples/teams/delete-membership.md +15 -0
- data/docs/examples/teams/delete.md +15 -0
- data/docs/examples/teams/get-memberships.md +15 -0
- data/docs/examples/teams/get.md +15 -0
- data/docs/examples/teams/list.md +15 -0
- data/docs/examples/teams/update-membership-roles.md +15 -0
- data/docs/examples/teams/update-membership-status.md +15 -0
- data/docs/examples/teams/update.md +15 -0
- data/docs/examples/users/create.md +15 -0
- data/docs/examples/users/delete-session.md +15 -0
- data/docs/examples/users/delete-sessions.md +15 -0
- data/docs/examples/users/delete.md +15 -0
- data/docs/examples/users/get-logs.md +15 -0
- data/docs/examples/users/get-prefs.md +15 -0
- data/docs/examples/users/get-sessions.md +15 -0
- data/docs/examples/users/get.md +15 -0
- data/docs/examples/users/list.md +15 -0
- data/docs/examples/users/update-prefs.md +15 -0
- data/docs/examples/users/update-status.md +15 -0
- data/lib/appwrite.rb +6 -0
- data/lib/appwrite/client.rb +43 -8
- data/lib/appwrite/exception.rb +14 -0
- data/lib/appwrite/file.rb +23 -0
- data/lib/appwrite/services/account.rb +190 -0
- data/lib/appwrite/services/avatars.rb +17 -1
- data/lib/appwrite/services/database.rb +20 -22
- data/lib/appwrite/services/functions.rb +195 -0
- data/lib/appwrite/services/health.rb +141 -0
- data/lib/appwrite/services/locale.rb +11 -0
- data/lib/appwrite/services/storage.rb +14 -10
- data/lib/appwrite/services/teams.rb +43 -10
- data/lib/appwrite/services/users.rb +22 -10
- metadata +105 -7
|
@@ -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
|
+
storage = Appwrite::Storage.new(client);
|
|
12
|
+
|
|
13
|
+
response = storage.update_file(file_id: '[FILE_ID]', read: [], write: []);
|
|
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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.create_membership(team_id: '[TEAM_ID]', email: 'email@example.com', roles: [], 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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.create(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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.delete_membership(team_id: '[TEAM_ID]', membership_id: '[MEMBERSHIP_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.delete(team_id: '[TEAM_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.get_memberships(team_id: '[TEAM_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.get(team_id: '[TEAM_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
teams = Appwrite::Teams.new(client);
|
|
12
|
+
|
|
13
|
+
response = teams.list();
|
|
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_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
|
|
@@ -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(team_id: '[TEAM_ID]', 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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.create(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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.delete_session(user_id: '[USER_ID]', 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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.delete_sessions(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.delete(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.get_logs(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.get_prefs(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.get_sessions(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.get(user_id: '[USER_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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.list();
|
|
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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.update_prefs(user_id: '[USER_ID]', 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_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
|
9
|
+
;
|
|
10
|
+
|
|
11
|
+
users = Appwrite::Users.new(client);
|
|
12
|
+
|
|
13
|
+
response = users.update_status(user_id: '[USER_ID]', status: 1);
|
|
14
|
+
|
|
15
|
+
puts response
|
data/lib/appwrite.rb
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'uri'
|
|
3
3
|
require 'json'
|
|
4
|
+
require 'mime/types'
|
|
4
5
|
require_relative 'appwrite/client'
|
|
5
6
|
require_relative 'appwrite/service'
|
|
7
|
+
require_relative 'appwrite/exception'
|
|
8
|
+
require_relative 'appwrite/file'
|
|
9
|
+
require_relative 'appwrite/services/account'
|
|
6
10
|
require_relative 'appwrite/services/avatars'
|
|
7
11
|
require_relative 'appwrite/services/database'
|
|
12
|
+
require_relative 'appwrite/services/functions'
|
|
13
|
+
require_relative 'appwrite/services/health'
|
|
8
14
|
require_relative 'appwrite/services/locale'
|
|
9
15
|
require_relative 'appwrite/services/storage'
|
|
10
16
|
require_relative 'appwrite/services/teams'
|
data/lib/appwrite/client.rb
CHANGED
|
@@ -20,7 +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:1.0
|
|
23
|
+
'x-sdk-version' => 'appwrite:ruby:2.1.0',
|
|
24
|
+
'X-Appwrite-Response-Format' => '0.8.0'
|
|
24
25
|
}
|
|
25
26
|
@endpoint = 'https://appwrite.io/v1';
|
|
26
27
|
end
|
|
@@ -37,14 +38,14 @@ module Appwrite
|
|
|
37
38
|
return self
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
def
|
|
41
|
-
add_header('x-appwrite-
|
|
41
|
+
def set_j_w_t(value)
|
|
42
|
+
add_header('x-appwrite-jwt', value)
|
|
42
43
|
|
|
43
44
|
return self
|
|
44
45
|
end
|
|
45
46
|
|
|
46
|
-
def
|
|
47
|
-
add_header('x-appwrite-
|
|
47
|
+
def set_locale(value)
|
|
48
|
+
add_header('x-appwrite-locale', value)
|
|
48
49
|
|
|
49
50
|
return self
|
|
50
51
|
end
|
|
@@ -78,11 +79,14 @@ module Appwrite
|
|
|
78
79
|
payload = ''
|
|
79
80
|
|
|
80
81
|
headers = @headers.merge(headers)
|
|
81
|
-
|
|
82
|
+
@BOUNDARY = "----A30#3ad1"
|
|
82
83
|
if (method != METHOD_GET)
|
|
83
84
|
case headers['content-type'][0, headers['content-type'].index(';') || headers['content-type'].length]
|
|
84
85
|
when 'application/json'
|
|
85
86
|
payload = params.to_json
|
|
87
|
+
when 'multipart/form-data'
|
|
88
|
+
payload = "--#{@BOUNDARY}\r\n" + encodeFormData(params)
|
|
89
|
+
headers['content-type'] = "multipart/form-data; boundary=#{@BOUNDARY}"
|
|
86
90
|
else
|
|
87
91
|
payload = encode(params)
|
|
88
92
|
end
|
|
@@ -91,7 +95,7 @@ module Appwrite
|
|
|
91
95
|
begin
|
|
92
96
|
response = http.send_request(method.upcase, uri.request_uri, payload, headers)
|
|
93
97
|
rescue => error
|
|
94
|
-
raise
|
|
98
|
+
raise Appwrite::Exception.new(error.message)
|
|
95
99
|
end
|
|
96
100
|
|
|
97
101
|
# Handle Redirects
|
|
@@ -101,8 +105,39 @@ module Appwrite
|
|
|
101
105
|
|
|
102
106
|
return fetch(method, uri, headers, {}, limit - 1)
|
|
103
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
|
|
104
114
|
|
|
105
|
-
|
|
115
|
+
if(response.code.to_i >= 400)
|
|
116
|
+
raise Appwrite::Exception.new(res['message'], res['status'], res)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
return res;
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def encodeFormData(value, key=nil)
|
|
123
|
+
case value
|
|
124
|
+
when Hash then value.map { |k,v| encodeFormData(v,k) }.join
|
|
125
|
+
when Array then value.map { |v| encodeFormData(v, "#{key}[]") }.join
|
|
126
|
+
when nil then ''
|
|
127
|
+
else
|
|
128
|
+
post_body = []
|
|
129
|
+
if(value.instance_of? File)
|
|
130
|
+
post_body << "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{value.name}\"\r\n"
|
|
131
|
+
post_body << "Content-Type: #{value.mimeType}\r\n\r\n"
|
|
132
|
+
post_body << value.content
|
|
133
|
+
post_body << "\r\n--#{@BOUNDARY}--\r\n"
|
|
134
|
+
else
|
|
135
|
+
post_body << "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
|
|
136
|
+
post_body << "#{value.to_s}"
|
|
137
|
+
post_body << "\r\n--#{@BOUNDARY}\r\n"
|
|
138
|
+
end
|
|
139
|
+
post_body.join
|
|
140
|
+
end
|
|
106
141
|
end
|
|
107
142
|
|
|
108
143
|
def encode(value, key = nil)
|