appwrite 1.0.11 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +16 -0
  3. data/Gemfile +1 -0
  4. data/LICENSE +1 -1
  5. data/README.md +72 -5
  6. data/appwrite.gemspec +3 -5
  7. data/docs/examples/account/create-recovery.md +15 -0
  8. data/docs/examples/account/create-verification.md +15 -0
  9. data/docs/examples/account/delete-session.md +15 -0
  10. data/docs/examples/account/delete-sessions.md +15 -0
  11. data/docs/examples/account/delete.md +15 -0
  12. data/docs/examples/account/get-logs.md +15 -0
  13. data/docs/examples/account/get-prefs.md +15 -0
  14. data/docs/examples/account/get-sessions.md +15 -0
  15. data/docs/examples/account/get.md +15 -0
  16. data/docs/examples/account/update-email.md +15 -0
  17. data/docs/examples/account/update-name.md +15 -0
  18. data/docs/examples/account/update-password.md +15 -0
  19. data/docs/examples/account/update-prefs.md +15 -0
  20. data/docs/examples/account/update-recovery.md +15 -0
  21. data/docs/examples/account/update-verification.md +15 -0
  22. data/docs/examples/{database/get-collection-logs.md → avatars/get-initials.md} +2 -2
  23. data/docs/examples/database/create-document.md +1 -1
  24. data/docs/examples/database/update-collection.md +1 -1
  25. data/docs/examples/database/update-document.md +1 -1
  26. data/docs/examples/functions/create-execution.md +15 -0
  27. data/docs/examples/functions/create-tag.md +15 -0
  28. data/docs/examples/functions/create.md +15 -0
  29. data/docs/examples/functions/delete-tag.md +15 -0
  30. data/docs/examples/functions/delete.md +15 -0
  31. data/docs/examples/functions/get-execution.md +15 -0
  32. data/docs/examples/functions/get-tag.md +15 -0
  33. data/docs/examples/functions/get.md +15 -0
  34. data/docs/examples/functions/list-executions.md +15 -0
  35. data/docs/examples/functions/list-tags.md +15 -0
  36. data/docs/examples/functions/list.md +15 -0
  37. data/docs/examples/functions/update-tag.md +15 -0
  38. data/docs/examples/functions/update.md +15 -0
  39. data/docs/examples/locale/get-languages.md +15 -0
  40. data/docs/examples/storage/create-file.md +1 -1
  41. data/docs/examples/teams/delete-membership.md +1 -1
  42. data/docs/examples/teams/update-membership-roles.md +15 -0
  43. data/docs/examples/teams/update-membership-status.md +15 -0
  44. data/docs/examples/users/delete.md +15 -0
  45. data/docs/examples/users/update-status.md +1 -1
  46. data/lib/appwrite.rb +5 -0
  47. data/lib/appwrite/client.rb +46 -5
  48. data/lib/appwrite/exception.rb +14 -0
  49. data/lib/appwrite/file.rb +23 -0
  50. data/lib/appwrite/services/account.rb +280 -0
  51. data/lib/appwrite/services/avatars.rb +133 -34
  52. data/lib/appwrite/services/database.rb +199 -67
  53. data/lib/appwrite/services/functions.rb +357 -0
  54. data/lib/appwrite/services/health.rb +12 -24
  55. data/lib/appwrite/services/locale.rb +16 -12
  56. data/lib/appwrite/services/storage.rb +124 -35
  57. data/lib/appwrite/services/teams.rb +187 -34
  58. data/lib/appwrite/services/users.rb +115 -31
  59. metadata +44 -11
@@ -0,0 +1,23 @@
1
+ require 'mime/types'
2
+
3
+ module Appwrite
4
+ class File
5
+ def initialize(path)
6
+ @name = ::File.basename(path)
7
+ @content = ::File.read(path)
8
+ @mimeType = MIME::Types.type_for(path)
9
+ end
10
+
11
+ def name
12
+ @name
13
+ end
14
+
15
+ def content
16
+ @content
17
+ end
18
+
19
+ def mimeType
20
+ @mimeType
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,280 @@
1
+ module Appwrite
2
+ class Account < Service
3
+
4
+ def get()
5
+ path = '/account'
6
+
7
+ params = {}
8
+
9
+ return @client.call('get', path, {
10
+ 'content-type' => 'application/json',
11
+ }, params);
12
+ end
13
+
14
+ def delete()
15
+ path = '/account'
16
+
17
+ params = {}
18
+
19
+ return @client.call('delete', path, {
20
+ 'content-type' => 'application/json',
21
+ }, params);
22
+ end
23
+
24
+ def update_email(email:, password:)
25
+ if email.nil?
26
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
27
+ end
28
+
29
+ if password.nil?
30
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
31
+ end
32
+
33
+ path = '/account/email'
34
+
35
+ params = {}
36
+
37
+ if !email.nil?
38
+ params[:email] = email
39
+ end
40
+
41
+ if !password.nil?
42
+ params[:password] = password
43
+ end
44
+
45
+ return @client.call('patch', path, {
46
+ 'content-type' => 'application/json',
47
+ }, params);
48
+ end
49
+
50
+ def get_logs()
51
+ path = '/account/logs'
52
+
53
+ params = {}
54
+
55
+ return @client.call('get', path, {
56
+ 'content-type' => 'application/json',
57
+ }, params);
58
+ end
59
+
60
+ def update_name(name:)
61
+ if name.nil?
62
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
63
+ end
64
+
65
+ path = '/account/name'
66
+
67
+ params = {}
68
+
69
+ if !name.nil?
70
+ params[:name] = name
71
+ end
72
+
73
+ return @client.call('patch', path, {
74
+ 'content-type' => 'application/json',
75
+ }, params);
76
+ end
77
+
78
+ def update_password(password:, old_password: nil)
79
+ if password.nil?
80
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
81
+ end
82
+
83
+ path = '/account/password'
84
+
85
+ params = {}
86
+
87
+ if !password.nil?
88
+ params[:password] = password
89
+ end
90
+
91
+ if !old_password.nil?
92
+ params[:oldPassword] = old_password
93
+ end
94
+
95
+ return @client.call('patch', path, {
96
+ 'content-type' => 'application/json',
97
+ }, params);
98
+ end
99
+
100
+ def get_prefs()
101
+ path = '/account/prefs'
102
+
103
+ params = {}
104
+
105
+ return @client.call('get', path, {
106
+ 'content-type' => 'application/json',
107
+ }, params);
108
+ end
109
+
110
+ def update_prefs(prefs:)
111
+ if prefs.nil?
112
+ raise Appwrite::Exception.new('Missing required parameter: "prefs"')
113
+ end
114
+
115
+ path = '/account/prefs'
116
+
117
+ params = {}
118
+
119
+ if !prefs.nil?
120
+ params[:prefs] = prefs
121
+ end
122
+
123
+ return @client.call('patch', path, {
124
+ 'content-type' => 'application/json',
125
+ }, params);
126
+ end
127
+
128
+ def create_recovery(email:, url:)
129
+ if email.nil?
130
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
131
+ end
132
+
133
+ if url.nil?
134
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
135
+ end
136
+
137
+ path = '/account/recovery'
138
+
139
+ params = {}
140
+
141
+ if !email.nil?
142
+ params[:email] = email
143
+ end
144
+
145
+ if !url.nil?
146
+ params[:url] = url
147
+ end
148
+
149
+ return @client.call('post', path, {
150
+ 'content-type' => 'application/json',
151
+ }, params);
152
+ end
153
+
154
+ def update_recovery(user_id:, secret:, password:, password_again:)
155
+ if user_id.nil?
156
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
157
+ end
158
+
159
+ if secret.nil?
160
+ raise Appwrite::Exception.new('Missing required parameter: "secret"')
161
+ end
162
+
163
+ if password.nil?
164
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
165
+ end
166
+
167
+ if password_again.nil?
168
+ raise Appwrite::Exception.new('Missing required parameter: "passwordAgain"')
169
+ end
170
+
171
+ path = '/account/recovery'
172
+
173
+ params = {}
174
+
175
+ if !user_id.nil?
176
+ params[:userId] = user_id
177
+ end
178
+
179
+ if !secret.nil?
180
+ params[:secret] = secret
181
+ end
182
+
183
+ if !password.nil?
184
+ params[:password] = password
185
+ end
186
+
187
+ if !password_again.nil?
188
+ params[:passwordAgain] = password_again
189
+ end
190
+
191
+ return @client.call('put', path, {
192
+ 'content-type' => 'application/json',
193
+ }, params);
194
+ end
195
+
196
+ def get_sessions()
197
+ path = '/account/sessions'
198
+
199
+ params = {}
200
+
201
+ return @client.call('get', path, {
202
+ 'content-type' => 'application/json',
203
+ }, params);
204
+ end
205
+
206
+ def delete_sessions()
207
+ path = '/account/sessions'
208
+
209
+ params = {}
210
+
211
+ return @client.call('delete', path, {
212
+ 'content-type' => 'application/json',
213
+ }, params);
214
+ end
215
+
216
+ def delete_session(session_id:)
217
+ if session_id.nil?
218
+ raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
219
+ end
220
+
221
+ path = '/account/sessions/{sessionId}'
222
+ .gsub('{sessionId}', session_id)
223
+
224
+ params = {}
225
+
226
+ return @client.call('delete', path, {
227
+ 'content-type' => 'application/json',
228
+ }, params);
229
+ end
230
+
231
+ def create_verification(url:)
232
+ if url.nil?
233
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
234
+ end
235
+
236
+ path = '/account/verification'
237
+
238
+ params = {}
239
+
240
+ if !url.nil?
241
+ params[:url] = url
242
+ end
243
+
244
+ return @client.call('post', path, {
245
+ 'content-type' => 'application/json',
246
+ }, params);
247
+ end
248
+
249
+ def update_verification(user_id:, secret:)
250
+ if user_id.nil?
251
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
252
+ end
253
+
254
+ if secret.nil?
255
+ raise Appwrite::Exception.new('Missing required parameter: "secret"')
256
+ end
257
+
258
+ path = '/account/verification'
259
+
260
+ params = {}
261
+
262
+ if !user_id.nil?
263
+ params[:userId] = user_id
264
+ end
265
+
266
+ if !secret.nil?
267
+ params[:secret] = secret
268
+ end
269
+
270
+ return @client.call('put', path, {
271
+ 'content-type' => 'application/json',
272
+ }, params);
273
+ end
274
+
275
+
276
+ protected
277
+
278
+ private
279
+ end
280
+ end
@@ -1,30 +1,54 @@
1
1
  module Appwrite
2
2
  class Avatars < Service
3
3
 
4
- def get_browser(code:, width: 100, height: 100, quality: 100)
4
+ def get_browser(code:, width: nil, height: nil, quality: nil)
5
+ if code.nil?
6
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
7
+ end
8
+
5
9
  path = '/avatars/browsers/{code}'
6
10
  .gsub('{code}', code)
7
11
 
8
- params = {
9
- 'width': width,
10
- 'height': height,
11
- 'quality': quality
12
- }
12
+ params = {}
13
+
14
+ if !width.nil?
15
+ params[:width] = width
16
+ end
17
+
18
+ if !height.nil?
19
+ params[:height] = height
20
+ end
21
+
22
+ if !quality.nil?
23
+ params[:quality] = quality
24
+ end
13
25
 
14
26
  return @client.call('get', path, {
15
27
  'content-type' => 'application/json',
16
28
  }, params);
17
29
  end
18
30
 
19
- def get_credit_card(code:, width: 100, height: 100, quality: 100)
31
+ def get_credit_card(code:, width: nil, height: nil, quality: nil)
32
+ if code.nil?
33
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
34
+ end
35
+
20
36
  path = '/avatars/credit-cards/{code}'
21
37
  .gsub('{code}', code)
22
38
 
23
- params = {
24
- 'width': width,
25
- 'height': height,
26
- 'quality': quality
27
- }
39
+ params = {}
40
+
41
+ if !width.nil?
42
+ params[:width] = width
43
+ end
44
+
45
+ if !height.nil?
46
+ params[:height] = height
47
+ end
48
+
49
+ if !quality.nil?
50
+ params[:quality] = quality
51
+ end
28
52
 
29
53
  return @client.call('get', path, {
30
54
  'content-type' => 'application/json',
@@ -32,55 +56,130 @@ module Appwrite
32
56
  end
33
57
 
34
58
  def get_favicon(url:)
59
+ if url.nil?
60
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
61
+ end
62
+
35
63
  path = '/avatars/favicon'
36
64
 
37
- params = {
38
- 'url': url
39
- }
65
+ params = {}
66
+
67
+ if !url.nil?
68
+ params[:url] = url
69
+ end
40
70
 
41
71
  return @client.call('get', path, {
42
72
  'content-type' => 'application/json',
43
73
  }, params);
44
74
  end
45
75
 
46
- def get_flag(code:, width: 100, height: 100, quality: 100)
76
+ def get_flag(code:, width: nil, height: nil, quality: nil)
77
+ if code.nil?
78
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
79
+ end
80
+
47
81
  path = '/avatars/flags/{code}'
48
82
  .gsub('{code}', code)
49
83
 
50
- params = {
51
- 'width': width,
52
- 'height': height,
53
- 'quality': quality
54
- }
84
+ params = {}
85
+
86
+ if !width.nil?
87
+ params[:width] = width
88
+ end
89
+
90
+ if !height.nil?
91
+ params[:height] = height
92
+ end
93
+
94
+ if !quality.nil?
95
+ params[:quality] = quality
96
+ end
55
97
 
56
98
  return @client.call('get', path, {
57
99
  'content-type' => 'application/json',
58
100
  }, params);
59
101
  end
60
102
 
61
- def get_image(url:, width: 400, height: 400)
103
+ def get_image(url:, width: nil, height: nil)
104
+ if url.nil?
105
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
106
+ end
107
+
62
108
  path = '/avatars/image'
63
109
 
64
- params = {
65
- 'url': url,
66
- 'width': width,
67
- 'height': height
68
- }
110
+ params = {}
111
+
112
+ if !url.nil?
113
+ params[:url] = url
114
+ end
115
+
116
+ if !width.nil?
117
+ params[:width] = width
118
+ end
119
+
120
+ if !height.nil?
121
+ params[:height] = height
122
+ end
69
123
 
70
124
  return @client.call('get', path, {
71
125
  'content-type' => 'application/json',
72
126
  }, params);
73
127
  end
74
128
 
75
- def get_q_r(text:, size: 400, margin: 1, download: 0)
129
+ def get_initials(name: nil, width: nil, height: nil, color: nil, background: nil)
130
+ path = '/avatars/initials'
131
+
132
+ params = {}
133
+
134
+ if !name.nil?
135
+ params[:name] = name
136
+ end
137
+
138
+ if !width.nil?
139
+ params[:width] = width
140
+ end
141
+
142
+ if !height.nil?
143
+ params[:height] = height
144
+ end
145
+
146
+ if !color.nil?
147
+ params[:color] = color
148
+ end
149
+
150
+ if !background.nil?
151
+ params[:background] = background
152
+ end
153
+
154
+ return @client.call('get', path, {
155
+ 'content-type' => 'application/json',
156
+ }, params);
157
+ end
158
+
159
+ def get_q_r(text:, size: nil, margin: nil, download: nil)
160
+ if text.nil?
161
+ raise Appwrite::Exception.new('Missing required parameter: "text"')
162
+ end
163
+
76
164
  path = '/avatars/qr'
77
165
 
78
- params = {
79
- 'text': text,
80
- 'size': size,
81
- 'margin': margin,
82
- 'download': download
83
- }
166
+ params = {}
167
+
168
+ if !text.nil?
169
+ params[:text] = text
170
+ end
171
+
172
+ if !size.nil?
173
+ params[:size] = size
174
+ end
175
+
176
+ if !margin.nil?
177
+ params[:margin] = margin
178
+ end
179
+
180
+ if !download.nil?
181
+ params[:download] = download
182
+ end
84
183
 
85
184
  return @client.call('get', path, {
86
185
  'content-type' => 'application/json',