appwrite 2.4.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +197 -56
- data/lib/appwrite/exception.rb +7 -7
- data/lib/appwrite/file.rb +9 -15
- data/lib/appwrite/models/attribute_boolean.rb +52 -0
- data/lib/appwrite/models/attribute_email.rb +57 -0
- data/lib/appwrite/models/attribute_enum.rb +62 -0
- data/lib/appwrite/models/attribute_float.rb +62 -0
- data/lib/appwrite/models/attribute_integer.rb +62 -0
- data/lib/appwrite/models/attribute_ip.rb +57 -0
- data/lib/appwrite/models/attribute_list.rb +32 -0
- data/lib/appwrite/models/attribute_string.rb +57 -0
- data/lib/appwrite/models/attribute_url.rb +57 -0
- data/lib/appwrite/models/bucket.rb +82 -0
- data/lib/appwrite/models/bucket_list.rb +32 -0
- data/lib/appwrite/models/collection.rb +62 -0
- data/lib/appwrite/models/collection_list.rb +32 -0
- data/lib/appwrite/models/continent.rb +32 -0
- data/lib/appwrite/models/continent_list.rb +32 -0
- data/lib/appwrite/models/country.rb +32 -0
- data/lib/appwrite/models/country_list.rb +32 -0
- data/lib/appwrite/models/currency.rb +57 -0
- data/lib/appwrite/models/currency_list.rb +32 -0
- data/lib/appwrite/models/deployment.rb +77 -0
- data/lib/appwrite/models/deployment_list.rb +32 -0
- data/lib/appwrite/models/document.rb +50 -0
- data/lib/appwrite/models/document_list.rb +36 -0
- data/lib/appwrite/models/execution.rb +72 -0
- data/lib/appwrite/models/execution_list.rb +32 -0
- data/lib/appwrite/models/file.rb +77 -0
- data/lib/appwrite/models/file_list.rb +32 -0
- data/lib/appwrite/models/function.rb +92 -0
- data/lib/appwrite/models/function_list.rb +32 -0
- data/lib/appwrite/models/health_antivirus.rb +32 -0
- data/lib/appwrite/models/health_queue.rb +27 -0
- data/lib/appwrite/models/health_status.rb +32 -0
- data/lib/appwrite/models/health_time.rb +37 -0
- data/lib/appwrite/models/index.rb +47 -0
- data/lib/appwrite/models/index_list.rb +32 -0
- data/lib/appwrite/models/language.rb +37 -0
- data/lib/appwrite/models/language_list.rb +32 -0
- data/lib/appwrite/models/locale.rb +57 -0
- data/lib/appwrite/models/log.rb +127 -0
- data/lib/appwrite/models/log_list.rb +32 -0
- data/lib/appwrite/models/membership.rb +67 -0
- data/lib/appwrite/models/membership_list.rb +32 -0
- data/lib/appwrite/models/phone.rb +37 -0
- data/lib/appwrite/models/phone_list.rb +32 -0
- data/lib/appwrite/models/preferences.rb +30 -0
- data/lib/appwrite/models/runtime.rb +57 -0
- data/lib/appwrite/models/runtime_list.rb +32 -0
- data/lib/appwrite/models/session.rb +142 -0
- data/lib/appwrite/models/session_list.rb +32 -0
- data/lib/appwrite/models/team.rb +42 -0
- data/lib/appwrite/models/team_list.rb +32 -0
- data/lib/appwrite/models/token.rb +42 -0
- data/lib/appwrite/models/user.rb +62 -0
- data/lib/appwrite/models/user_list.rb +32 -0
- data/lib/appwrite/query.rb +42 -0
- data/lib/appwrite/service.rb +0 -5
- data/lib/appwrite/services/account.rb +400 -138
- data/lib/appwrite/services/avatars.rb +188 -125
- data/lib/appwrite/services/database.rb +875 -130
- data/lib/appwrite/services/functions.rb +439 -207
- data/lib/appwrite/services/health.rb +201 -58
- data/lib/appwrite/services/locale.rb +133 -32
- data/lib/appwrite/services/storage.rb +469 -118
- data/lib/appwrite/services/teams.rb +302 -118
- data/lib/appwrite/services/users.rb +322 -127
- data/lib/appwrite.rb +57 -0
- metadata +74 -108
- data/.travis.yml +0 -16
- data/CHANGELOG.md +0 -1
- data/Gemfile +0 -4
- data/LICENSE +0 -12
- data/README.md +0 -96
- data/appwrite.gemspec +0 -11
- data/docs/examples/account/create-recovery.md +0 -15
- data/docs/examples/account/create-verification.md +0 -15
- data/docs/examples/account/delete-session.md +0 -15
- data/docs/examples/account/delete-sessions.md +0 -15
- data/docs/examples/account/delete.md +0 -15
- data/docs/examples/account/get-logs.md +0 -15
- data/docs/examples/account/get-prefs.md +0 -15
- data/docs/examples/account/get-session.md +0 -15
- data/docs/examples/account/get-sessions.md +0 -15
- data/docs/examples/account/get.md +0 -15
- data/docs/examples/account/update-email.md +0 -15
- data/docs/examples/account/update-name.md +0 -15
- data/docs/examples/account/update-password.md +0 -15
- data/docs/examples/account/update-prefs.md +0 -15
- data/docs/examples/account/update-recovery.md +0 -15
- data/docs/examples/account/update-verification.md +0 -15
- data/docs/examples/avatars/get-browser.md +0 -15
- data/docs/examples/avatars/get-credit-card.md +0 -15
- data/docs/examples/avatars/get-favicon.md +0 -15
- data/docs/examples/avatars/get-flag.md +0 -15
- data/docs/examples/avatars/get-image.md +0 -15
- data/docs/examples/avatars/get-initials.md +0 -15
- data/docs/examples/avatars/get-q-r.md +0 -15
- data/docs/examples/database/create-collection.md +0 -15
- data/docs/examples/database/create-document.md +0 -15
- data/docs/examples/database/delete-collection.md +0 -15
- data/docs/examples/database/delete-document.md +0 -15
- data/docs/examples/database/get-collection.md +0 -15
- data/docs/examples/database/get-document.md +0 -15
- data/docs/examples/database/list-collections.md +0 -15
- data/docs/examples/database/list-documents.md +0 -15
- data/docs/examples/database/update-collection.md +0 -15
- data/docs/examples/database/update-document.md +0 -15
- data/docs/examples/functions/create-execution.md +0 -15
- data/docs/examples/functions/create-tag.md +0 -15
- data/docs/examples/functions/create.md +0 -15
- data/docs/examples/functions/delete-tag.md +0 -15
- data/docs/examples/functions/delete.md +0 -15
- data/docs/examples/functions/get-execution.md +0 -15
- data/docs/examples/functions/get-tag.md +0 -15
- data/docs/examples/functions/get.md +0 -15
- data/docs/examples/functions/list-executions.md +0 -15
- data/docs/examples/functions/list-tags.md +0 -15
- data/docs/examples/functions/list.md +0 -15
- data/docs/examples/functions/update-tag.md +0 -15
- data/docs/examples/functions/update.md +0 -15
- data/docs/examples/health/get-anti-virus.md +0 -15
- data/docs/examples/health/get-cache.md +0 -15
- data/docs/examples/health/get-d-b.md +0 -15
- data/docs/examples/health/get-queue-certificates.md +0 -15
- data/docs/examples/health/get-queue-functions.md +0 -15
- data/docs/examples/health/get-queue-logs.md +0 -15
- data/docs/examples/health/get-queue-tasks.md +0 -15
- data/docs/examples/health/get-queue-usage.md +0 -15
- data/docs/examples/health/get-queue-webhooks.md +0 -15
- data/docs/examples/health/get-storage-local.md +0 -15
- data/docs/examples/health/get-time.md +0 -15
- data/docs/examples/health/get.md +0 -15
- data/docs/examples/locale/get-continents.md +0 -15
- data/docs/examples/locale/get-countries-e-u.md +0 -15
- data/docs/examples/locale/get-countries-phones.md +0 -15
- data/docs/examples/locale/get-countries.md +0 -15
- data/docs/examples/locale/get-currencies.md +0 -15
- data/docs/examples/locale/get-languages.md +0 -15
- data/docs/examples/locale/get.md +0 -15
- data/docs/examples/storage/create-file.md +0 -15
- data/docs/examples/storage/delete-file.md +0 -15
- data/docs/examples/storage/get-file-download.md +0 -15
- data/docs/examples/storage/get-file-preview.md +0 -15
- data/docs/examples/storage/get-file-view.md +0 -15
- data/docs/examples/storage/get-file.md +0 -15
- data/docs/examples/storage/list-files.md +0 -15
- data/docs/examples/storage/update-file.md +0 -15
- data/docs/examples/teams/create-membership.md +0 -15
- data/docs/examples/teams/create.md +0 -15
- data/docs/examples/teams/delete-membership.md +0 -15
- data/docs/examples/teams/delete.md +0 -15
- data/docs/examples/teams/get-memberships.md +0 -15
- data/docs/examples/teams/get.md +0 -15
- data/docs/examples/teams/list.md +0 -15
- data/docs/examples/teams/update-membership-roles.md +0 -15
- data/docs/examples/teams/update-membership-status.md +0 -15
- data/docs/examples/teams/update.md +0 -15
- data/docs/examples/users/create.md +0 -15
- data/docs/examples/users/delete-session.md +0 -15
- data/docs/examples/users/delete-sessions.md +0 -15
- data/docs/examples/users/delete.md +0 -15
- data/docs/examples/users/get-logs.md +0 -15
- data/docs/examples/users/get-prefs.md +0 -15
- data/docs/examples/users/get-sessions.md +0 -15
- data/docs/examples/users/get.md +0 -15
- data/docs/examples/users/list.md +0 -15
- data/docs/examples/users/update-email.md +0 -15
- data/docs/examples/users/update-name.md +0 -15
- data/docs/examples/users/update-password.md +0 -15
- data/docs/examples/users/update-prefs.md +0 -15
- data/docs/examples/users/update-status.md +0 -15
- data/docs/examples/users/update-verification.md +0 -15
@@ -1,26 +1,70 @@
|
|
1
|
+
#frozen_string_literal: true
|
2
|
+
|
1
3
|
module Appwrite
|
2
4
|
class Account < Service
|
3
5
|
|
6
|
+
# Get currently logged in user data as JSON object.
|
7
|
+
#
|
8
|
+
#
|
9
|
+
# @return [User]
|
4
10
|
def get()
|
5
11
|
path = '/account'
|
6
12
|
|
7
|
-
params = {
|
13
|
+
params = {
|
14
|
+
}
|
15
|
+
|
16
|
+
headers = {
|
17
|
+
"content-type": 'application/json',
|
18
|
+
}
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
20
|
+
@client.call(
|
21
|
+
method: 'GET',
|
22
|
+
path: path,
|
23
|
+
headers: headers,
|
24
|
+
params: params,
|
25
|
+
response_type: Models::User
|
26
|
+
)
|
12
27
|
end
|
13
28
|
|
29
|
+
# Delete a currently logged in user account. Behind the scene, the user
|
30
|
+
# record is not deleted but permanently blocked from any access. This is done
|
31
|
+
# to avoid deleted accounts being overtaken by new users with the same email
|
32
|
+
# address. Any user-related resources like documents or storage files should
|
33
|
+
# be deleted separately.
|
34
|
+
#
|
35
|
+
#
|
36
|
+
# @return []
|
14
37
|
def delete()
|
15
38
|
path = '/account'
|
16
39
|
|
17
|
-
params = {
|
40
|
+
params = {
|
41
|
+
}
|
18
42
|
|
19
|
-
|
20
|
-
|
21
|
-
}
|
43
|
+
headers = {
|
44
|
+
"content-type": 'application/json',
|
45
|
+
}
|
46
|
+
|
47
|
+
@client.call(
|
48
|
+
method: 'DELETE',
|
49
|
+
path: path,
|
50
|
+
headers: headers,
|
51
|
+
params: params,
|
52
|
+
)
|
22
53
|
end
|
23
54
|
|
55
|
+
# Update currently logged in user account email address. After changing user
|
56
|
+
# address, the user confirmation status will get reset. A new confirmation
|
57
|
+
# email is not sent automatically however you can use the send confirmation
|
58
|
+
# email endpoint again to send the confirmation email. For security measures,
|
59
|
+
# user password is required to complete this request.
|
60
|
+
# This endpoint can also be used to convert an anonymous account to a normal
|
61
|
+
# one, by passing an email address and a new password.
|
62
|
+
#
|
63
|
+
#
|
64
|
+
# @param [string] email User email.
|
65
|
+
# @param [string] password User password. Must be at least 8 chars.
|
66
|
+
#
|
67
|
+
# @return [User]
|
24
68
|
def update_email(email:, password:)
|
25
69
|
if email.nil?
|
26
70
|
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
@@ -32,31 +76,57 @@ module Appwrite
|
|
32
76
|
|
33
77
|
path = '/account/email'
|
34
78
|
|
35
|
-
params = {
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
79
|
+
params = {
|
80
|
+
email: email,
|
81
|
+
password: password,
|
82
|
+
}
|
83
|
+
|
84
|
+
headers = {
|
85
|
+
"content-type": 'application/json',
|
86
|
+
}
|
87
|
+
|
88
|
+
@client.call(
|
89
|
+
method: 'PATCH',
|
90
|
+
path: path,
|
91
|
+
headers: headers,
|
92
|
+
params: params,
|
93
|
+
response_type: Models::User
|
94
|
+
)
|
48
95
|
end
|
49
96
|
|
50
|
-
|
97
|
+
# Get currently logged in user list of latest security activity logs. Each
|
98
|
+
# log returns user IP address, location and date and time of log.
|
99
|
+
#
|
100
|
+
# @param [number] limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
101
|
+
# @param [number] offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
|
102
|
+
#
|
103
|
+
# @return [LogList]
|
104
|
+
def get_logs(limit: nil, offset: nil)
|
51
105
|
path = '/account/logs'
|
52
106
|
|
53
|
-
params = {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
107
|
+
params = {
|
108
|
+
limit: limit,
|
109
|
+
offset: offset,
|
110
|
+
}
|
111
|
+
|
112
|
+
headers = {
|
113
|
+
"content-type": 'application/json',
|
114
|
+
}
|
115
|
+
|
116
|
+
@client.call(
|
117
|
+
method: 'GET',
|
118
|
+
path: path,
|
119
|
+
headers: headers,
|
120
|
+
params: params,
|
121
|
+
response_type: Models::LogList
|
122
|
+
)
|
58
123
|
end
|
59
124
|
|
125
|
+
# Update currently logged in user account name.
|
126
|
+
#
|
127
|
+
# @param [string] name User name. Max length: 128 chars.
|
128
|
+
#
|
129
|
+
# @return [User]
|
60
130
|
def update_name(name:)
|
61
131
|
if name.nil?
|
62
132
|
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
@@ -64,17 +134,31 @@ module Appwrite
|
|
64
134
|
|
65
135
|
path = '/account/name'
|
66
136
|
|
67
|
-
params = {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
137
|
+
params = {
|
138
|
+
name: name,
|
139
|
+
}
|
140
|
+
|
141
|
+
headers = {
|
142
|
+
"content-type": 'application/json',
|
143
|
+
}
|
144
|
+
|
145
|
+
@client.call(
|
146
|
+
method: 'PATCH',
|
147
|
+
path: path,
|
148
|
+
headers: headers,
|
149
|
+
params: params,
|
150
|
+
response_type: Models::User
|
151
|
+
)
|
76
152
|
end
|
77
153
|
|
154
|
+
# Update currently logged in user password. For validation, user is required
|
155
|
+
# to pass in the new password, and the old password. For users created with
|
156
|
+
# OAuth and Team Invites, oldPassword is optional.
|
157
|
+
#
|
158
|
+
# @param [string] password New user password. Must be at least 8 chars.
|
159
|
+
# @param [string] old_password Current user password. Must be at least 8 chars.
|
160
|
+
#
|
161
|
+
# @return [User]
|
78
162
|
def update_password(password:, old_password: nil)
|
79
163
|
if password.nil?
|
80
164
|
raise Appwrite::Exception.new('Missing required parameter: "password"')
|
@@ -82,31 +166,54 @@ module Appwrite
|
|
82
166
|
|
83
167
|
path = '/account/password'
|
84
168
|
|
85
|
-
params = {
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
169
|
+
params = {
|
170
|
+
password: password,
|
171
|
+
oldPassword: old_password,
|
172
|
+
}
|
173
|
+
|
174
|
+
headers = {
|
175
|
+
"content-type": 'application/json',
|
176
|
+
}
|
177
|
+
|
178
|
+
@client.call(
|
179
|
+
method: 'PATCH',
|
180
|
+
path: path,
|
181
|
+
headers: headers,
|
182
|
+
params: params,
|
183
|
+
response_type: Models::User
|
184
|
+
)
|
98
185
|
end
|
99
186
|
|
187
|
+
# Get currently logged in user preferences as a key-value object.
|
188
|
+
#
|
189
|
+
#
|
190
|
+
# @return [Preferences]
|
100
191
|
def get_prefs()
|
101
192
|
path = '/account/prefs'
|
102
193
|
|
103
|
-
params = {
|
194
|
+
params = {
|
195
|
+
}
|
104
196
|
|
105
|
-
|
106
|
-
|
107
|
-
}
|
197
|
+
headers = {
|
198
|
+
"content-type": 'application/json',
|
199
|
+
}
|
200
|
+
|
201
|
+
@client.call(
|
202
|
+
method: 'GET',
|
203
|
+
path: path,
|
204
|
+
headers: headers,
|
205
|
+
params: params,
|
206
|
+
response_type: Models::Preferences
|
207
|
+
)
|
108
208
|
end
|
109
209
|
|
210
|
+
# Update currently logged in user account preferences. The object you pass is
|
211
|
+
# stored as is, and replaces any previous value. The maximum allowed prefs
|
212
|
+
# size is 64kB and throws error if exceeded.
|
213
|
+
#
|
214
|
+
# @param [object] prefs Prefs key-value JSON object.
|
215
|
+
#
|
216
|
+
# @return [User]
|
110
217
|
def update_prefs(prefs:)
|
111
218
|
if prefs.nil?
|
112
219
|
raise Appwrite::Exception.new('Missing required parameter: "prefs"')
|
@@ -114,17 +221,36 @@ module Appwrite
|
|
114
221
|
|
115
222
|
path = '/account/prefs'
|
116
223
|
|
117
|
-
params = {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
224
|
+
params = {
|
225
|
+
prefs: prefs,
|
226
|
+
}
|
227
|
+
|
228
|
+
headers = {
|
229
|
+
"content-type": 'application/json',
|
230
|
+
}
|
231
|
+
|
232
|
+
@client.call(
|
233
|
+
method: 'PATCH',
|
234
|
+
path: path,
|
235
|
+
headers: headers,
|
236
|
+
params: params,
|
237
|
+
response_type: Models::User
|
238
|
+
)
|
126
239
|
end
|
127
240
|
|
241
|
+
# Sends the user an email with a temporary secret key for password reset.
|
242
|
+
# When the user clicks the confirmation link he is redirected back to your
|
243
|
+
# app password reset URL with the secret key and email address values
|
244
|
+
# attached to the URL query string. Use the query string params to submit a
|
245
|
+
# request to the [PUT
|
246
|
+
# /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to
|
247
|
+
# complete the process. The verification link sent to the user's email
|
248
|
+
# address is valid for 1 hour.
|
249
|
+
#
|
250
|
+
# @param [string] email User email.
|
251
|
+
# @param [string] url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
252
|
+
#
|
253
|
+
# @return [Token]
|
128
254
|
def create_recovery(email:, url:)
|
129
255
|
if email.nil?
|
130
256
|
raise Appwrite::Exception.new('Missing required parameter: "email"')
|
@@ -136,21 +262,40 @@ module Appwrite
|
|
136
262
|
|
137
263
|
path = '/account/recovery'
|
138
264
|
|
139
|
-
params = {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
265
|
+
params = {
|
266
|
+
email: email,
|
267
|
+
url: url,
|
268
|
+
}
|
269
|
+
|
270
|
+
headers = {
|
271
|
+
"content-type": 'application/json',
|
272
|
+
}
|
273
|
+
|
274
|
+
@client.call(
|
275
|
+
method: 'POST',
|
276
|
+
path: path,
|
277
|
+
headers: headers,
|
278
|
+
params: params,
|
279
|
+
response_type: Models::Token
|
280
|
+
)
|
152
281
|
end
|
153
282
|
|
283
|
+
# Use this endpoint to complete the user account password reset. Both the
|
284
|
+
# **userId** and **secret** arguments will be passed as query parameters to
|
285
|
+
# the redirect URL you have provided when sending your request to the [POST
|
286
|
+
# /account/recovery](/docs/client/account#accountCreateRecovery) endpoint.
|
287
|
+
#
|
288
|
+
# Please note that in order to avoid a [Redirect
|
289
|
+
# Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
290
|
+
# the only valid redirect URLs are the ones from domains you have set when
|
291
|
+
# adding your platforms in the console interface.
|
292
|
+
#
|
293
|
+
# @param [string] user_id User ID.
|
294
|
+
# @param [string] secret Valid reset token.
|
295
|
+
# @param [string] password New user password. Must be at least 8 chars.
|
296
|
+
# @param [string] password_again Repeat new user password. Must be at least 8 chars.
|
297
|
+
#
|
298
|
+
# @return [Token]
|
154
299
|
def update_recovery(user_id:, secret:, password:, password_again:)
|
155
300
|
if user_id.nil?
|
156
301
|
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
@@ -170,49 +315,79 @@ module Appwrite
|
|
170
315
|
|
171
316
|
path = '/account/recovery'
|
172
317
|
|
173
|
-
params = {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
params
|
189
|
-
|
190
|
-
|
191
|
-
return @client.call('put', path, {
|
192
|
-
'content-type' => 'application/json',
|
193
|
-
}, params);
|
318
|
+
params = {
|
319
|
+
userId: user_id,
|
320
|
+
secret: secret,
|
321
|
+
password: password,
|
322
|
+
passwordAgain: password_again,
|
323
|
+
}
|
324
|
+
|
325
|
+
headers = {
|
326
|
+
"content-type": 'application/json',
|
327
|
+
}
|
328
|
+
|
329
|
+
@client.call(
|
330
|
+
method: 'PUT',
|
331
|
+
path: path,
|
332
|
+
headers: headers,
|
333
|
+
params: params,
|
334
|
+
response_type: Models::Token
|
335
|
+
)
|
194
336
|
end
|
195
337
|
|
338
|
+
# Get currently logged in user list of active sessions across different
|
339
|
+
# devices.
|
340
|
+
#
|
341
|
+
#
|
342
|
+
# @return [SessionList]
|
196
343
|
def get_sessions()
|
197
344
|
path = '/account/sessions'
|
198
345
|
|
199
|
-
params = {
|
346
|
+
params = {
|
347
|
+
}
|
348
|
+
|
349
|
+
headers = {
|
350
|
+
"content-type": 'application/json',
|
351
|
+
}
|
200
352
|
|
201
|
-
|
202
|
-
|
203
|
-
|
353
|
+
@client.call(
|
354
|
+
method: 'GET',
|
355
|
+
path: path,
|
356
|
+
headers: headers,
|
357
|
+
params: params,
|
358
|
+
response_type: Models::SessionList
|
359
|
+
)
|
204
360
|
end
|
205
361
|
|
362
|
+
# Delete all sessions from the user account and remove any sessions cookies
|
363
|
+
# from the end client.
|
364
|
+
#
|
365
|
+
#
|
366
|
+
# @return []
|
206
367
|
def delete_sessions()
|
207
368
|
path = '/account/sessions'
|
208
369
|
|
209
|
-
params = {
|
370
|
+
params = {
|
371
|
+
}
|
210
372
|
|
211
|
-
|
212
|
-
|
213
|
-
}
|
373
|
+
headers = {
|
374
|
+
"content-type": 'application/json',
|
375
|
+
}
|
376
|
+
|
377
|
+
@client.call(
|
378
|
+
method: 'DELETE',
|
379
|
+
path: path,
|
380
|
+
headers: headers,
|
381
|
+
params: params,
|
382
|
+
)
|
214
383
|
end
|
215
384
|
|
385
|
+
# Use this endpoint to get a logged in user's session using a Session ID.
|
386
|
+
# Inputting 'current' will return the current session being used.
|
387
|
+
#
|
388
|
+
# @param [string] session_id Session ID. Use the string 'current' to get the current device session.
|
389
|
+
#
|
390
|
+
# @return [Session]
|
216
391
|
def get_session(session_id:)
|
217
392
|
if session_id.nil?
|
218
393
|
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
@@ -221,13 +396,59 @@ module Appwrite
|
|
221
396
|
path = '/account/sessions/{sessionId}'
|
222
397
|
.gsub('{sessionId}', session_id)
|
223
398
|
|
224
|
-
params = {
|
399
|
+
params = {
|
400
|
+
}
|
401
|
+
|
402
|
+
headers = {
|
403
|
+
"content-type": 'application/json',
|
404
|
+
}
|
405
|
+
|
406
|
+
@client.call(
|
407
|
+
method: 'GET',
|
408
|
+
path: path,
|
409
|
+
headers: headers,
|
410
|
+
params: params,
|
411
|
+
response_type: Models::Session
|
412
|
+
)
|
413
|
+
end
|
414
|
+
|
415
|
+
#
|
416
|
+
#
|
417
|
+
# @param [string] session_id Session ID. Use the string 'current' to update the current device session.
|
418
|
+
#
|
419
|
+
# @return [Session]
|
420
|
+
def update_session(session_id:)
|
421
|
+
if session_id.nil?
|
422
|
+
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
423
|
+
end
|
424
|
+
|
425
|
+
path = '/account/sessions/{sessionId}'
|
426
|
+
.gsub('{sessionId}', session_id)
|
427
|
+
|
428
|
+
params = {
|
429
|
+
}
|
430
|
+
|
431
|
+
headers = {
|
432
|
+
"content-type": 'application/json',
|
433
|
+
}
|
225
434
|
|
226
|
-
|
227
|
-
|
228
|
-
|
435
|
+
@client.call(
|
436
|
+
method: 'PATCH',
|
437
|
+
path: path,
|
438
|
+
headers: headers,
|
439
|
+
params: params,
|
440
|
+
response_type: Models::Session
|
441
|
+
)
|
229
442
|
end
|
230
443
|
|
444
|
+
# Use this endpoint to log out the currently logged in user from all their
|
445
|
+
# account sessions across all of their different devices. When using the
|
446
|
+
# Session ID argument, only the unique session ID provided is deleted.
|
447
|
+
#
|
448
|
+
#
|
449
|
+
# @param [string] session_id Session ID. Use the string 'current' to delete the current device session.
|
450
|
+
#
|
451
|
+
# @return []
|
231
452
|
def delete_session(session_id:)
|
232
453
|
if session_id.nil?
|
233
454
|
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
|
@@ -236,13 +457,40 @@ module Appwrite
|
|
236
457
|
path = '/account/sessions/{sessionId}'
|
237
458
|
.gsub('{sessionId}', session_id)
|
238
459
|
|
239
|
-
params = {
|
460
|
+
params = {
|
461
|
+
}
|
240
462
|
|
241
|
-
|
242
|
-
|
243
|
-
}
|
463
|
+
headers = {
|
464
|
+
"content-type": 'application/json',
|
465
|
+
}
|
466
|
+
|
467
|
+
@client.call(
|
468
|
+
method: 'DELETE',
|
469
|
+
path: path,
|
470
|
+
headers: headers,
|
471
|
+
params: params,
|
472
|
+
)
|
244
473
|
end
|
245
474
|
|
475
|
+
# Use this endpoint to send a verification message to your user email address
|
476
|
+
# to confirm they are the valid owners of that address. Both the **userId**
|
477
|
+
# and **secret** arguments will be passed as query parameters to the URL you
|
478
|
+
# have provided to be attached to the verification email. The provided URL
|
479
|
+
# should redirect the user back to your app and allow you to complete the
|
480
|
+
# verification process by verifying both the **userId** and **secret**
|
481
|
+
# parameters. Learn more about how to [complete the verification
|
482
|
+
# process](/docs/client/account#accountUpdateVerification). The verification
|
483
|
+
# link sent to the user's email address is valid for 7 days.
|
484
|
+
#
|
485
|
+
# Please note that in order to avoid a [Redirect
|
486
|
+
# Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
|
487
|
+
# the only valid redirect URLs are the ones from domains you have set when
|
488
|
+
# adding your platforms in the console interface.
|
489
|
+
#
|
490
|
+
#
|
491
|
+
# @param [string] url URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
|
492
|
+
#
|
493
|
+
# @return [Token]
|
246
494
|
def create_verification(url:)
|
247
495
|
if url.nil?
|
248
496
|
raise Appwrite::Exception.new('Missing required parameter: "url"')
|
@@ -250,17 +498,32 @@ module Appwrite
|
|
250
498
|
|
251
499
|
path = '/account/verification'
|
252
500
|
|
253
|
-
params = {
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
501
|
+
params = {
|
502
|
+
url: url,
|
503
|
+
}
|
504
|
+
|
505
|
+
headers = {
|
506
|
+
"content-type": 'application/json',
|
507
|
+
}
|
508
|
+
|
509
|
+
@client.call(
|
510
|
+
method: 'POST',
|
511
|
+
path: path,
|
512
|
+
headers: headers,
|
513
|
+
params: params,
|
514
|
+
response_type: Models::Token
|
515
|
+
)
|
262
516
|
end
|
263
517
|
|
518
|
+
# Use this endpoint to complete the user email verification process. Use both
|
519
|
+
# the **userId** and **secret** parameters that were attached to your app URL
|
520
|
+
# to verify the user email ownership. If confirmed this route will return a
|
521
|
+
# 200 status code.
|
522
|
+
#
|
523
|
+
# @param [string] user_id User ID.
|
524
|
+
# @param [string] secret Valid verification token.
|
525
|
+
#
|
526
|
+
# @return [Token]
|
264
527
|
def update_verification(user_id:, secret:)
|
265
528
|
if user_id.nil?
|
266
529
|
raise Appwrite::Exception.new('Missing required parameter: "userId"')
|
@@ -272,24 +535,23 @@ module Appwrite
|
|
272
535
|
|
273
536
|
path = '/account/verification'
|
274
537
|
|
275
|
-
params = {
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
538
|
+
params = {
|
539
|
+
userId: user_id,
|
540
|
+
secret: secret,
|
541
|
+
}
|
542
|
+
|
543
|
+
headers = {
|
544
|
+
"content-type": 'application/json',
|
545
|
+
}
|
546
|
+
|
547
|
+
@client.call(
|
548
|
+
method: 'PUT',
|
549
|
+
path: path,
|
550
|
+
headers: headers,
|
551
|
+
params: params,
|
552
|
+
response_type: Models::Token
|
553
|
+
)
|
288
554
|
end
|
289
555
|
|
290
|
-
|
291
|
-
protected
|
292
|
-
|
293
|
-
private
|
294
556
|
end
|
295
557
|
end
|