appwrite 2.4.1 → 3.0.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.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +134 -57
  3. data/lib/appwrite/exception.rb +5 -7
  4. data/lib/appwrite/file.rb +5 -13
  5. data/lib/appwrite/models/attribute_boolean.rb +52 -0
  6. data/lib/appwrite/models/attribute_email.rb +57 -0
  7. data/lib/appwrite/models/attribute_enum.rb +62 -0
  8. data/lib/appwrite/models/attribute_float.rb +62 -0
  9. data/lib/appwrite/models/attribute_integer.rb +62 -0
  10. data/lib/appwrite/models/attribute_ip.rb +57 -0
  11. data/lib/appwrite/models/attribute_list.rb +32 -0
  12. data/lib/appwrite/models/attribute_string.rb +57 -0
  13. data/lib/appwrite/models/attribute_url.rb +57 -0
  14. data/lib/appwrite/models/collection.rb +62 -0
  15. data/lib/appwrite/models/collection_list.rb +32 -0
  16. data/lib/appwrite/models/continent.rb +32 -0
  17. data/lib/appwrite/models/continent_list.rb +32 -0
  18. data/lib/appwrite/models/country.rb +32 -0
  19. data/lib/appwrite/models/country_list.rb +32 -0
  20. data/lib/appwrite/models/currency.rb +57 -0
  21. data/lib/appwrite/models/currency_list.rb +32 -0
  22. data/lib/appwrite/models/document.rb +50 -0
  23. data/lib/appwrite/models/document_list.rb +36 -0
  24. data/lib/appwrite/models/execution.rb +72 -0
  25. data/lib/appwrite/models/execution_list.rb +32 -0
  26. data/lib/appwrite/models/file.rb +62 -0
  27. data/lib/appwrite/models/file_list.rb +32 -0
  28. data/lib/appwrite/models/function.rb +92 -0
  29. data/lib/appwrite/models/function_list.rb +32 -0
  30. data/lib/appwrite/models/health_antivirus.rb +32 -0
  31. data/lib/appwrite/models/health_queue.rb +27 -0
  32. data/lib/appwrite/models/health_status.rb +32 -0
  33. data/lib/appwrite/models/health_time.rb +37 -0
  34. data/lib/appwrite/models/index.rb +47 -0
  35. data/lib/appwrite/models/index_list.rb +32 -0
  36. data/lib/appwrite/models/language.rb +37 -0
  37. data/lib/appwrite/models/language_list.rb +32 -0
  38. data/lib/appwrite/models/locale.rb +57 -0
  39. data/lib/appwrite/models/log.rb +127 -0
  40. data/lib/appwrite/models/log_list.rb +32 -0
  41. data/lib/appwrite/models/membership.rb +67 -0
  42. data/lib/appwrite/models/membership_list.rb +32 -0
  43. data/lib/appwrite/models/phone.rb +37 -0
  44. data/lib/appwrite/models/phone_list.rb +32 -0
  45. data/lib/appwrite/models/preferences.rb +30 -0
  46. data/lib/appwrite/models/runtime.rb +57 -0
  47. data/lib/appwrite/models/runtime_list.rb +32 -0
  48. data/lib/appwrite/models/session.rb +132 -0
  49. data/lib/appwrite/models/session_list.rb +32 -0
  50. data/lib/appwrite/models/tag.rb +47 -0
  51. data/lib/appwrite/models/tag_list.rb +32 -0
  52. data/lib/appwrite/models/team.rb +42 -0
  53. data/lib/appwrite/models/team_list.rb +32 -0
  54. data/lib/appwrite/models/token.rb +42 -0
  55. data/lib/appwrite/models/user.rb +62 -0
  56. data/lib/appwrite/models/user_list.rb +32 -0
  57. data/lib/appwrite/query.rb +42 -0
  58. data/lib/appwrite/service.rb +0 -5
  59. data/lib/appwrite/services/account.rb +370 -138
  60. data/lib/appwrite/services/avatars.rb +189 -125
  61. data/lib/appwrite/services/database.rb +876 -130
  62. data/lib/appwrite/services/functions.rb +364 -182
  63. data/lib/appwrite/services/health.rb +202 -58
  64. data/lib/appwrite/services/locale.rb +134 -32
  65. data/lib/appwrite/services/storage.rb +210 -121
  66. data/lib/appwrite/services/teams.rb +299 -118
  67. data/lib/appwrite/services/users.rb +322 -127
  68. data/lib/appwrite.rb +55 -0
  69. metadata +72 -111
  70. data/.github/ISSUE_TEMPLATE/bug.yaml +0 -82
  71. data/.github/ISSUE_TEMPLATE/documentation.yaml +0 -32
  72. data/.github/ISSUE_TEMPLATE/feature.yaml +0 -40
  73. data/.travis.yml +0 -16
  74. data/CHANGELOG.md +0 -1
  75. data/Gemfile +0 -4
  76. data/LICENSE +0 -12
  77. data/README.md +0 -96
  78. data/appwrite.gemspec +0 -11
  79. data/docs/examples/account/create-recovery.md +0 -15
  80. data/docs/examples/account/create-verification.md +0 -15
  81. data/docs/examples/account/delete-session.md +0 -15
  82. data/docs/examples/account/delete-sessions.md +0 -15
  83. data/docs/examples/account/delete.md +0 -15
  84. data/docs/examples/account/get-logs.md +0 -15
  85. data/docs/examples/account/get-prefs.md +0 -15
  86. data/docs/examples/account/get-session.md +0 -15
  87. data/docs/examples/account/get-sessions.md +0 -15
  88. data/docs/examples/account/get.md +0 -15
  89. data/docs/examples/account/update-email.md +0 -15
  90. data/docs/examples/account/update-name.md +0 -15
  91. data/docs/examples/account/update-password.md +0 -15
  92. data/docs/examples/account/update-prefs.md +0 -15
  93. data/docs/examples/account/update-recovery.md +0 -15
  94. data/docs/examples/account/update-verification.md +0 -15
  95. data/docs/examples/avatars/get-browser.md +0 -15
  96. data/docs/examples/avatars/get-credit-card.md +0 -15
  97. data/docs/examples/avatars/get-favicon.md +0 -15
  98. data/docs/examples/avatars/get-flag.md +0 -15
  99. data/docs/examples/avatars/get-image.md +0 -15
  100. data/docs/examples/avatars/get-initials.md +0 -15
  101. data/docs/examples/avatars/get-q-r.md +0 -15
  102. data/docs/examples/database/create-collection.md +0 -15
  103. data/docs/examples/database/create-document.md +0 -15
  104. data/docs/examples/database/delete-collection.md +0 -15
  105. data/docs/examples/database/delete-document.md +0 -15
  106. data/docs/examples/database/get-collection.md +0 -15
  107. data/docs/examples/database/get-document.md +0 -15
  108. data/docs/examples/database/list-collections.md +0 -15
  109. data/docs/examples/database/list-documents.md +0 -15
  110. data/docs/examples/database/update-collection.md +0 -15
  111. data/docs/examples/database/update-document.md +0 -15
  112. data/docs/examples/functions/create-execution.md +0 -15
  113. data/docs/examples/functions/create-tag.md +0 -15
  114. data/docs/examples/functions/create.md +0 -15
  115. data/docs/examples/functions/delete-tag.md +0 -15
  116. data/docs/examples/functions/delete.md +0 -15
  117. data/docs/examples/functions/get-execution.md +0 -15
  118. data/docs/examples/functions/get-tag.md +0 -15
  119. data/docs/examples/functions/get.md +0 -15
  120. data/docs/examples/functions/list-executions.md +0 -15
  121. data/docs/examples/functions/list-tags.md +0 -15
  122. data/docs/examples/functions/list.md +0 -15
  123. data/docs/examples/functions/update-tag.md +0 -15
  124. data/docs/examples/functions/update.md +0 -15
  125. data/docs/examples/health/get-anti-virus.md +0 -15
  126. data/docs/examples/health/get-cache.md +0 -15
  127. data/docs/examples/health/get-d-b.md +0 -15
  128. data/docs/examples/health/get-queue-certificates.md +0 -15
  129. data/docs/examples/health/get-queue-functions.md +0 -15
  130. data/docs/examples/health/get-queue-logs.md +0 -15
  131. data/docs/examples/health/get-queue-tasks.md +0 -15
  132. data/docs/examples/health/get-queue-usage.md +0 -15
  133. data/docs/examples/health/get-queue-webhooks.md +0 -15
  134. data/docs/examples/health/get-storage-local.md +0 -15
  135. data/docs/examples/health/get-time.md +0 -15
  136. data/docs/examples/health/get.md +0 -15
  137. data/docs/examples/locale/get-continents.md +0 -15
  138. data/docs/examples/locale/get-countries-e-u.md +0 -15
  139. data/docs/examples/locale/get-countries-phones.md +0 -15
  140. data/docs/examples/locale/get-countries.md +0 -15
  141. data/docs/examples/locale/get-currencies.md +0 -15
  142. data/docs/examples/locale/get-languages.md +0 -15
  143. data/docs/examples/locale/get.md +0 -15
  144. data/docs/examples/storage/create-file.md +0 -15
  145. data/docs/examples/storage/delete-file.md +0 -15
  146. data/docs/examples/storage/get-file-download.md +0 -15
  147. data/docs/examples/storage/get-file-preview.md +0 -15
  148. data/docs/examples/storage/get-file-view.md +0 -15
  149. data/docs/examples/storage/get-file.md +0 -15
  150. data/docs/examples/storage/list-files.md +0 -15
  151. data/docs/examples/storage/update-file.md +0 -15
  152. data/docs/examples/teams/create-membership.md +0 -15
  153. data/docs/examples/teams/create.md +0 -15
  154. data/docs/examples/teams/delete-membership.md +0 -15
  155. data/docs/examples/teams/delete.md +0 -15
  156. data/docs/examples/teams/get-memberships.md +0 -15
  157. data/docs/examples/teams/get.md +0 -15
  158. data/docs/examples/teams/list.md +0 -15
  159. data/docs/examples/teams/update-membership-roles.md +0 -15
  160. data/docs/examples/teams/update-membership-status.md +0 -15
  161. data/docs/examples/teams/update.md +0 -15
  162. data/docs/examples/users/create.md +0 -15
  163. data/docs/examples/users/delete-session.md +0 -15
  164. data/docs/examples/users/delete-sessions.md +0 -15
  165. data/docs/examples/users/delete.md +0 -15
  166. data/docs/examples/users/get-logs.md +0 -15
  167. data/docs/examples/users/get-prefs.md +0 -15
  168. data/docs/examples/users/get-sessions.md +0 -15
  169. data/docs/examples/users/get.md +0 -15
  170. data/docs/examples/users/list.md +0 -15
  171. data/docs/examples/users/update-email.md +0 -15
  172. data/docs/examples/users/update-name.md +0 -15
  173. data/docs/examples/users/update-password.md +0 -15
  174. data/docs/examples/users/update-prefs.md +0 -15
  175. data/docs/examples/users/update-status.md +0 -15
  176. data/docs/examples/users/update-verification.md +0 -15
@@ -1,33 +1,58 @@
1
+ #frozen_string_literal: true
2
+
1
3
  module Appwrite
2
4
  class Users < Service
3
5
 
4
- def list(search: nil, limit: nil, offset: nil, order_type: nil)
6
+ include Models
7
+ # Get a list of all the project's users. You can use the query params to
8
+ # filter your results.
9
+ #
10
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
11
+ # @param [number] limit Maximum number of users to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
12
+ # @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
13
+ # @param [string] cursor ID of the user used as the starting point for the query, excluding the user itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
14
+ # @param [string] cursor_direction Direction of the cursor.
15
+ # @param [string] order_type Order result by ASC or DESC order.
16
+ #
17
+ # @return [UserList]
18
+ def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
5
19
  path = '/users'
6
20
 
7
- params = {}
8
-
9
- if !search.nil?
10
- params[:search] = search
11
- end
12
-
13
- if !limit.nil?
14
- params[:limit] = limit
15
- end
16
-
17
- if !offset.nil?
18
- params[:offset] = offset
19
- end
21
+ params = {
22
+ search: search,
23
+ limit: limit,
24
+ offset: offset,
25
+ cursor: cursor,
26
+ cursorDirection: cursor_direction,
27
+ orderType: order_type,
28
+ }
29
+
30
+ headers = {
31
+ "content-type": 'application/json',
32
+ }
33
+
34
+ @client.call(
35
+ method: 'GET',
36
+ path: path,
37
+ params: params,
38
+ headers: headers,
39
+ response_type: UserList
40
+ )
41
+ end
20
42
 
21
- if !order_type.nil?
22
- params[:orderType] = order_type
43
+ # Create a new user.
44
+ #
45
+ # @param [string] user_id User ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
46
+ # @param [string] email User email.
47
+ # @param [string] password User password. Must be at least 8 chars.
48
+ # @param [string] name User name. Max length: 128 chars.
49
+ #
50
+ # @return [User]
51
+ def create(user_id:, email:, password:, name: nil)
52
+ if user_id.nil?
53
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
23
54
  end
24
55
 
25
- return @client.call('get', path, {
26
- 'content-type' => 'application/json',
27
- }, params);
28
- end
29
-
30
- def create(email:, password:, name: nil)
31
56
  if email.nil?
32
57
  raise Appwrite::Exception.new('Missing required parameter: "email"')
33
58
  end
@@ -38,25 +63,31 @@ module Appwrite
38
63
 
39
64
  path = '/users'
40
65
 
41
- params = {}
42
-
43
- if !email.nil?
44
- params[:email] = email
45
- end
46
-
47
- if !password.nil?
48
- params[:password] = password
49
- end
50
-
51
- if !name.nil?
52
- params[:name] = name
53
- end
54
-
55
- return @client.call('post', path, {
56
- 'content-type' => 'application/json',
57
- }, params);
66
+ params = {
67
+ userId: user_id,
68
+ email: email,
69
+ password: password,
70
+ name: name,
71
+ }
72
+
73
+ headers = {
74
+ "content-type": 'application/json',
75
+ }
76
+
77
+ @client.call(
78
+ method: 'POST',
79
+ path: path,
80
+ params: params,
81
+ headers: headers,
82
+ response_type: User
83
+ )
58
84
  end
59
85
 
86
+ # Get a user by its unique ID.
87
+ #
88
+ # @param [string] user_id User ID.
89
+ #
90
+ # @return [User]
60
91
  def get(user_id:)
61
92
  if user_id.nil?
62
93
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -65,13 +96,27 @@ module Appwrite
65
96
  path = '/users/{userId}'
66
97
  .gsub('{userId}', user_id)
67
98
 
68
- params = {}
99
+ params = {
100
+ }
101
+
102
+ headers = {
103
+ "content-type": 'application/json',
104
+ }
69
105
 
70
- return @client.call('get', path, {
71
- 'content-type' => 'application/json',
72
- }, params);
106
+ @client.call(
107
+ method: 'GET',
108
+ path: path,
109
+ params: params,
110
+ headers: headers,
111
+ response_type: User
112
+ )
73
113
  end
74
114
 
115
+ # Delete a user by its unique ID.
116
+ #
117
+ # @param [string] user_id User ID.
118
+ #
119
+ # @return []
75
120
  def delete(user_id:)
76
121
  if user_id.nil?
77
122
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -80,13 +125,27 @@ module Appwrite
80
125
  path = '/users/{userId}'
81
126
  .gsub('{userId}', user_id)
82
127
 
83
- params = {}
128
+ params = {
129
+ }
130
+
131
+ headers = {
132
+ "content-type": 'application/json',
133
+ }
84
134
 
85
- return @client.call('delete', path, {
86
- 'content-type' => 'application/json',
87
- }, params);
135
+ @client.call(
136
+ method: 'DELETE',
137
+ path: path,
138
+ params: params,
139
+ headers: headers,
140
+ )
88
141
  end
89
142
 
143
+ # Update the user email by its unique ID.
144
+ #
145
+ # @param [string] user_id User ID.
146
+ # @param [string] email User email.
147
+ #
148
+ # @return [User]
90
149
  def update_email(user_id:, email:)
91
150
  if user_id.nil?
92
151
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -99,18 +158,31 @@ module Appwrite
99
158
  path = '/users/{userId}/email'
100
159
  .gsub('{userId}', user_id)
101
160
 
102
- params = {}
103
-
104
- if !email.nil?
105
- params[:email] = email
106
- end
107
-
108
- return @client.call('patch', path, {
109
- 'content-type' => 'application/json',
110
- }, params);
161
+ params = {
162
+ email: email,
163
+ }
164
+
165
+ headers = {
166
+ "content-type": 'application/json',
167
+ }
168
+
169
+ @client.call(
170
+ method: 'PATCH',
171
+ path: path,
172
+ params: params,
173
+ headers: headers,
174
+ response_type: User
175
+ )
111
176
  end
112
177
 
113
- def get_logs(user_id:)
178
+ # Get the user activity logs list by its unique ID.
179
+ #
180
+ # @param [string] user_id User ID.
181
+ # @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.
182
+ # @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)
183
+ #
184
+ # @return [LogList]
185
+ def get_logs(user_id:, limit: nil, offset: nil)
114
186
  if user_id.nil?
115
187
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
116
188
  end
@@ -118,13 +190,30 @@ module Appwrite
118
190
  path = '/users/{userId}/logs'
119
191
  .gsub('{userId}', user_id)
120
192
 
121
- params = {}
122
-
123
- return @client.call('get', path, {
124
- 'content-type' => 'application/json',
125
- }, params);
193
+ params = {
194
+ limit: limit,
195
+ offset: offset,
196
+ }
197
+
198
+ headers = {
199
+ "content-type": 'application/json',
200
+ }
201
+
202
+ @client.call(
203
+ method: 'GET',
204
+ path: path,
205
+ params: params,
206
+ headers: headers,
207
+ response_type: LogList
208
+ )
126
209
  end
127
210
 
211
+ # Update the user name by its unique ID.
212
+ #
213
+ # @param [string] user_id User ID.
214
+ # @param [string] name User name. Max length: 128 chars.
215
+ #
216
+ # @return [User]
128
217
  def update_name(user_id:, name:)
129
218
  if user_id.nil?
130
219
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -137,17 +226,29 @@ module Appwrite
137
226
  path = '/users/{userId}/name'
138
227
  .gsub('{userId}', user_id)
139
228
 
140
- params = {}
141
-
142
- if !name.nil?
143
- params[:name] = name
144
- end
145
-
146
- return @client.call('patch', path, {
147
- 'content-type' => 'application/json',
148
- }, params);
229
+ params = {
230
+ name: name,
231
+ }
232
+
233
+ headers = {
234
+ "content-type": 'application/json',
235
+ }
236
+
237
+ @client.call(
238
+ method: 'PATCH',
239
+ path: path,
240
+ params: params,
241
+ headers: headers,
242
+ response_type: User
243
+ )
149
244
  end
150
245
 
246
+ # Update the user password by its unique ID.
247
+ #
248
+ # @param [string] user_id User ID.
249
+ # @param [string] password New user password. Must be at least 8 chars.
250
+ #
251
+ # @return [User]
151
252
  def update_password(user_id:, password:)
152
253
  if user_id.nil?
153
254
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -160,17 +261,28 @@ module Appwrite
160
261
  path = '/users/{userId}/password'
161
262
  .gsub('{userId}', user_id)
162
263
 
163
- params = {}
164
-
165
- if !password.nil?
166
- params[:password] = password
167
- end
168
-
169
- return @client.call('patch', path, {
170
- 'content-type' => 'application/json',
171
- }, params);
264
+ params = {
265
+ password: password,
266
+ }
267
+
268
+ headers = {
269
+ "content-type": 'application/json',
270
+ }
271
+
272
+ @client.call(
273
+ method: 'PATCH',
274
+ path: path,
275
+ params: params,
276
+ headers: headers,
277
+ response_type: User
278
+ )
172
279
  end
173
280
 
281
+ # Get the user preferences by its unique ID.
282
+ #
283
+ # @param [string] user_id User ID.
284
+ #
285
+ # @return [Preferences]
174
286
  def get_prefs(user_id:)
175
287
  if user_id.nil?
176
288
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -179,13 +291,29 @@ module Appwrite
179
291
  path = '/users/{userId}/prefs'
180
292
  .gsub('{userId}', user_id)
181
293
 
182
- params = {}
294
+ params = {
295
+ }
296
+
297
+ headers = {
298
+ "content-type": 'application/json',
299
+ }
183
300
 
184
- return @client.call('get', path, {
185
- 'content-type' => 'application/json',
186
- }, params);
301
+ @client.call(
302
+ method: 'GET',
303
+ path: path,
304
+ params: params,
305
+ headers: headers,
306
+ response_type: Preferences
307
+ )
187
308
  end
188
309
 
310
+ # Update the user preferences by its unique ID. You can pass only the
311
+ # specific settings you wish to update.
312
+ #
313
+ # @param [string] user_id User ID.
314
+ # @param [object] prefs Prefs key-value JSON object.
315
+ #
316
+ # @return [Preferences]
189
317
  def update_prefs(user_id:, prefs:)
190
318
  if user_id.nil?
191
319
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -198,17 +326,28 @@ module Appwrite
198
326
  path = '/users/{userId}/prefs'
199
327
  .gsub('{userId}', user_id)
200
328
 
201
- params = {}
202
-
203
- if !prefs.nil?
204
- params[:prefs] = prefs
205
- end
206
-
207
- return @client.call('patch', path, {
208
- 'content-type' => 'application/json',
209
- }, params);
329
+ params = {
330
+ prefs: prefs,
331
+ }
332
+
333
+ headers = {
334
+ "content-type": 'application/json',
335
+ }
336
+
337
+ @client.call(
338
+ method: 'PATCH',
339
+ path: path,
340
+ params: params,
341
+ headers: headers,
342
+ response_type: Preferences
343
+ )
210
344
  end
211
345
 
346
+ # Get the user sessions list by its unique ID.
347
+ #
348
+ # @param [string] user_id User ID.
349
+ #
350
+ # @return [SessionList]
212
351
  def get_sessions(user_id:)
213
352
  if user_id.nil?
214
353
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -217,13 +356,27 @@ module Appwrite
217
356
  path = '/users/{userId}/sessions'
218
357
  .gsub('{userId}', user_id)
219
358
 
220
- params = {}
359
+ params = {
360
+ }
221
361
 
222
- return @client.call('get', path, {
223
- 'content-type' => 'application/json',
224
- }, params);
362
+ headers = {
363
+ "content-type": 'application/json',
364
+ }
365
+
366
+ @client.call(
367
+ method: 'GET',
368
+ path: path,
369
+ params: params,
370
+ headers: headers,
371
+ response_type: SessionList
372
+ )
225
373
  end
226
374
 
375
+ # Delete all user's sessions by using the user's unique ID.
376
+ #
377
+ # @param [string] user_id User ID.
378
+ #
379
+ # @return []
227
380
  def delete_sessions(user_id:)
228
381
  if user_id.nil?
229
382
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -232,13 +385,27 @@ module Appwrite
232
385
  path = '/users/{userId}/sessions'
233
386
  .gsub('{userId}', user_id)
234
387
 
235
- params = {}
388
+ params = {
389
+ }
390
+
391
+ headers = {
392
+ "content-type": 'application/json',
393
+ }
236
394
 
237
- return @client.call('delete', path, {
238
- 'content-type' => 'application/json',
239
- }, params);
395
+ @client.call(
396
+ method: 'DELETE',
397
+ path: path,
398
+ params: params,
399
+ headers: headers,
400
+ )
240
401
  end
241
402
 
403
+ # Delete a user sessions by its unique ID.
404
+ #
405
+ # @param [string] user_id User ID.
406
+ # @param [string] session_id Session ID.
407
+ #
408
+ # @return []
242
409
  def delete_session(user_id:, session_id:)
243
410
  if user_id.nil?
244
411
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -252,13 +419,27 @@ module Appwrite
252
419
  .gsub('{userId}', user_id)
253
420
  .gsub('{sessionId}', session_id)
254
421
 
255
- params = {}
422
+ params = {
423
+ }
424
+
425
+ headers = {
426
+ "content-type": 'application/json',
427
+ }
256
428
 
257
- return @client.call('delete', path, {
258
- 'content-type' => 'application/json',
259
- }, params);
429
+ @client.call(
430
+ method: 'DELETE',
431
+ path: path,
432
+ params: params,
433
+ headers: headers,
434
+ )
260
435
  end
261
436
 
437
+ # Update the user status by its unique ID.
438
+ #
439
+ # @param [string] user_id User ID.
440
+ # @param [boolean] status User Status. To activate the user pass `true` and to block the user pass `false`.
441
+ #
442
+ # @return [User]
262
443
  def update_status(user_id:, status:)
263
444
  if user_id.nil?
264
445
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -271,17 +452,29 @@ module Appwrite
271
452
  path = '/users/{userId}/status'
272
453
  .gsub('{userId}', user_id)
273
454
 
274
- params = {}
275
-
276
- if !status.nil?
277
- params[:status] = status
278
- end
279
-
280
- return @client.call('patch', path, {
281
- 'content-type' => 'application/json',
282
- }, params);
455
+ params = {
456
+ status: status,
457
+ }
458
+
459
+ headers = {
460
+ "content-type": 'application/json',
461
+ }
462
+
463
+ @client.call(
464
+ method: 'PATCH',
465
+ path: path,
466
+ params: params,
467
+ headers: headers,
468
+ response_type: User
469
+ )
283
470
  end
284
471
 
472
+ # Update the user email verification status by its unique ID.
473
+ #
474
+ # @param [string] user_id User ID.
475
+ # @param [boolean] email_verification User email verification status.
476
+ #
477
+ # @return [User]
285
478
  def update_verification(user_id:, email_verification:)
286
479
  if user_id.nil?
287
480
  raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -294,20 +487,22 @@ module Appwrite
294
487
  path = '/users/{userId}/verification'
295
488
  .gsub('{userId}', user_id)
296
489
 
297
- params = {}
298
-
299
- if !email_verification.nil?
300
- params[:emailVerification] = email_verification
301
- end
302
-
303
- return @client.call('patch', path, {
304
- 'content-type' => 'application/json',
305
- }, params);
490
+ params = {
491
+ emailVerification: email_verification,
492
+ }
493
+
494
+ headers = {
495
+ "content-type": 'application/json',
496
+ }
497
+
498
+ @client.call(
499
+ method: 'PATCH',
500
+ path: path,
501
+ params: params,
502
+ headers: headers,
503
+ response_type: User
504
+ )
306
505
  end
307
506
 
308
-
309
- protected
310
-
311
- private
312
507
  end
313
508
  end
data/lib/appwrite.rb CHANGED
@@ -2,10 +2,65 @@ require 'net/http'
2
2
  require 'uri'
3
3
  require 'json'
4
4
  require 'mime/types'
5
+
5
6
  require_relative 'appwrite/client'
6
7
  require_relative 'appwrite/service'
7
8
  require_relative 'appwrite/exception'
8
9
  require_relative 'appwrite/file'
10
+
11
+ require_relative 'appwrite/models/collection_list'
12
+ require_relative 'appwrite/models/index_list'
13
+ require_relative 'appwrite/models/document_list'
14
+ require_relative 'appwrite/models/user_list'
15
+ require_relative 'appwrite/models/session_list'
16
+ require_relative 'appwrite/models/log_list'
17
+ require_relative 'appwrite/models/file_list'
18
+ require_relative 'appwrite/models/team_list'
19
+ require_relative 'appwrite/models/membership_list'
20
+ require_relative 'appwrite/models/function_list'
21
+ require_relative 'appwrite/models/runtime_list'
22
+ require_relative 'appwrite/models/tag_list'
23
+ require_relative 'appwrite/models/execution_list'
24
+ require_relative 'appwrite/models/country_list'
25
+ require_relative 'appwrite/models/continent_list'
26
+ require_relative 'appwrite/models/language_list'
27
+ require_relative 'appwrite/models/currency_list'
28
+ require_relative 'appwrite/models/phone_list'
29
+ require_relative 'appwrite/models/collection'
30
+ require_relative 'appwrite/models/attribute_list'
31
+ require_relative 'appwrite/models/attribute_string'
32
+ require_relative 'appwrite/models/attribute_integer'
33
+ require_relative 'appwrite/models/attribute_float'
34
+ require_relative 'appwrite/models/attribute_boolean'
35
+ require_relative 'appwrite/models/attribute_email'
36
+ require_relative 'appwrite/models/attribute_enum'
37
+ require_relative 'appwrite/models/attribute_ip'
38
+ require_relative 'appwrite/models/attribute_url'
39
+ require_relative 'appwrite/models/index'
40
+ require_relative 'appwrite/models/document'
41
+ require_relative 'appwrite/models/log'
42
+ require_relative 'appwrite/models/user'
43
+ require_relative 'appwrite/models/preferences'
44
+ require_relative 'appwrite/models/session'
45
+ require_relative 'appwrite/models/token'
46
+ require_relative 'appwrite/models/locale'
47
+ require_relative 'appwrite/models/file'
48
+ require_relative 'appwrite/models/team'
49
+ require_relative 'appwrite/models/membership'
50
+ require_relative 'appwrite/models/function'
51
+ require_relative 'appwrite/models/runtime'
52
+ require_relative 'appwrite/models/tag'
53
+ require_relative 'appwrite/models/execution'
54
+ require_relative 'appwrite/models/country'
55
+ require_relative 'appwrite/models/continent'
56
+ require_relative 'appwrite/models/language'
57
+ require_relative 'appwrite/models/currency'
58
+ require_relative 'appwrite/models/phone'
59
+ require_relative 'appwrite/models/health_antivirus'
60
+ require_relative 'appwrite/models/health_queue'
61
+ require_relative 'appwrite/models/health_status'
62
+ require_relative 'appwrite/models/health_time'
63
+
9
64
  require_relative 'appwrite/services/account'
10
65
  require_relative 'appwrite/services/avatars'
11
66
  require_relative 'appwrite/services/database'