appwrite 2.0.2 → 2.3.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -1
  4. data/README.md +74 -6
  5. data/appwrite.gemspec +2 -2
  6. data/docs/examples/account/create-recovery.md +15 -0
  7. data/docs/examples/account/create-verification.md +15 -0
  8. data/docs/examples/account/delete-session.md +15 -0
  9. data/docs/examples/account/delete-sessions.md +15 -0
  10. data/docs/examples/account/delete.md +15 -0
  11. data/docs/examples/account/get-logs.md +15 -0
  12. data/docs/examples/account/get-prefs.md +15 -0
  13. data/docs/examples/account/get-session.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/avatars/get-q-r.md +1 -1
  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.md +1 -1
  27. data/docs/examples/health/get-d-b.md +1 -1
  28. data/docs/examples/locale/get-countries-e-u.md +1 -1
  29. data/docs/examples/storage/create-file.md +1 -1
  30. data/docs/examples/teams/delete-membership.md +1 -1
  31. data/docs/examples/teams/update-membership-roles.md +15 -0
  32. data/docs/examples/teams/update-membership-status.md +15 -0
  33. data/docs/examples/users/{delete-user.md → delete.md} +1 -1
  34. data/docs/examples/users/update-status.md +1 -1
  35. data/docs/examples/users/update-verification.md +15 -0
  36. data/lib/appwrite.rb +2 -0
  37. data/lib/appwrite/client.rb +21 -5
  38. data/lib/appwrite/exception.rb +14 -0
  39. data/lib/appwrite/services/account.rb +295 -0
  40. data/lib/appwrite/services/avatars.rb +125 -42
  41. data/lib/appwrite/services/database.rb +199 -53
  42. data/lib/appwrite/services/functions.rb +223 -60
  43. data/lib/appwrite/services/health.rb +13 -25
  44. data/lib/appwrite/services/locale.rb +8 -15
  45. data/lib/appwrite/services/storage.rb +127 -33
  46. data/lib/appwrite/services/teams.rb +187 -38
  47. data/lib/appwrite/services/users.rb +129 -34
  48. metadata +24 -3
@@ -4,8 +4,7 @@ module Appwrite
4
4
  def get()
5
5
  path = '/locale'
6
6
 
7
- params = {
8
- }
7
+ params = {}
9
8
 
10
9
  return @client.call('get', path, {
11
10
  'content-type' => 'application/json',
@@ -15,8 +14,7 @@ module Appwrite
15
14
  def get_continents()
16
15
  path = '/locale/continents'
17
16
 
18
- params = {
19
- }
17
+ params = {}
20
18
 
21
19
  return @client.call('get', path, {
22
20
  'content-type' => 'application/json',
@@ -26,19 +24,17 @@ module Appwrite
26
24
  def get_countries()
27
25
  path = '/locale/countries'
28
26
 
29
- params = {
30
- }
27
+ params = {}
31
28
 
32
29
  return @client.call('get', path, {
33
30
  'content-type' => 'application/json',
34
31
  }, params);
35
32
  end
36
33
 
37
- def get_countries_e_u()
34
+ def get_countries_eu()
38
35
  path = '/locale/countries/eu'
39
36
 
40
- params = {
41
- }
37
+ params = {}
42
38
 
43
39
  return @client.call('get', path, {
44
40
  'content-type' => 'application/json',
@@ -48,8 +44,7 @@ module Appwrite
48
44
  def get_countries_phones()
49
45
  path = '/locale/countries/phones'
50
46
 
51
- params = {
52
- }
47
+ params = {}
53
48
 
54
49
  return @client.call('get', path, {
55
50
  'content-type' => 'application/json',
@@ -59,8 +54,7 @@ module Appwrite
59
54
  def get_currencies()
60
55
  path = '/locale/currencies'
61
56
 
62
- params = {
63
- }
57
+ params = {}
64
58
 
65
59
  return @client.call('get', path, {
66
60
  'content-type' => 'application/json',
@@ -70,8 +64,7 @@ module Appwrite
70
64
  def get_languages()
71
65
  path = '/locale/languages'
72
66
 
73
- params = {
74
- }
67
+ params = {}
75
68
 
76
69
  return @client.call('get', path, {
77
70
  'content-type' => 'application/json',
@@ -1,29 +1,52 @@
1
1
  module Appwrite
2
2
  class Storage < Service
3
3
 
4
- def list_files(search: '', limit: 25, offset: 0, order_type: 'ASC')
4
+ def list_files(search: nil, limit: nil, offset: nil, order_type: nil)
5
5
  path = '/storage/files'
6
6
 
7
- params = {
8
- 'search': search,
9
- 'limit': limit,
10
- 'offset': offset,
11
- 'orderType': order_type
12
- }
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
20
+
21
+ if !order_type.nil?
22
+ params[:orderType] = order_type
23
+ end
13
24
 
14
25
  return @client.call('get', path, {
15
26
  'content-type' => 'application/json',
16
27
  }, params);
17
28
  end
18
29
 
19
- def create_file(file:, read:, write:)
30
+ def create_file(file:, read: nil, write: nil)
31
+ if file.nil?
32
+ raise Appwrite::Exception.new('Missing required parameter: "file"')
33
+ end
34
+
20
35
  path = '/storage/files'
21
36
 
22
- params = {
23
- 'file': file,
24
- 'read': read,
25
- 'write': write
26
- }
37
+ params = {}
38
+
39
+ if !file.nil?
40
+ params[:file] = file
41
+ end
42
+
43
+ if !read.nil?
44
+ params[:read] = read
45
+ end
46
+
47
+ if !write.nil?
48
+ params[:write] = write
49
+ end
27
50
 
28
51
  return @client.call('post', path, {
29
52
  'content-type' => 'multipart/form-data',
@@ -31,11 +54,14 @@ module Appwrite
31
54
  end
32
55
 
33
56
  def get_file(file_id:)
57
+ if file_id.nil?
58
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
59
+ end
60
+
34
61
  path = '/storage/files/{fileId}'
35
62
  .gsub('{fileId}', file_id)
36
63
 
37
- params = {
38
- }
64
+ params = {}
39
65
 
40
66
  return @client.call('get', path, {
41
67
  'content-type' => 'application/json',
@@ -43,13 +69,30 @@ module Appwrite
43
69
  end
44
70
 
45
71
  def update_file(file_id:, read:, write:)
72
+ if file_id.nil?
73
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
74
+ end
75
+
76
+ if read.nil?
77
+ raise Appwrite::Exception.new('Missing required parameter: "read"')
78
+ end
79
+
80
+ if write.nil?
81
+ raise Appwrite::Exception.new('Missing required parameter: "write"')
82
+ end
83
+
46
84
  path = '/storage/files/{fileId}'
47
85
  .gsub('{fileId}', file_id)
48
86
 
49
- params = {
50
- 'read': read,
51
- 'write': write
52
- }
87
+ params = {}
88
+
89
+ if !read.nil?
90
+ params[:read] = read
91
+ end
92
+
93
+ if !write.nil?
94
+ params[:write] = write
95
+ end
53
96
 
54
97
  return @client.call('put', path, {
55
98
  'content-type' => 'application/json',
@@ -57,11 +100,14 @@ module Appwrite
57
100
  end
58
101
 
59
102
  def delete_file(file_id:)
103
+ if file_id.nil?
104
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
105
+ end
106
+
60
107
  path = '/storage/files/{fileId}'
61
108
  .gsub('{fileId}', file_id)
62
109
 
63
- params = {
64
- }
110
+ params = {}
65
111
 
66
112
  return @client.call('delete', path, {
67
113
  'content-type' => 'application/json',
@@ -69,28 +115,73 @@ module Appwrite
69
115
  end
70
116
 
71
117
  def get_file_download(file_id:)
118
+ if file_id.nil?
119
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
120
+ end
121
+
72
122
  path = '/storage/files/{fileId}/download'
73
123
  .gsub('{fileId}', file_id)
74
124
 
75
- params = {
76
- }
125
+ params = {}
77
126
 
78
127
  return @client.call('get', path, {
79
128
  'content-type' => 'application/json',
80
129
  }, params);
81
130
  end
82
131
 
83
- def get_file_preview(file_id:, width: 0, height: 0, quality: 100, background: '', output: '')
132
+ def get_file_preview(file_id:, width: nil, height: nil, gravity: nil, quality: nil, border_width: nil, border_color: nil, border_radius: nil, opacity: nil, rotation: nil, background: nil, output: nil)
133
+ if file_id.nil?
134
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
135
+ end
136
+
84
137
  path = '/storage/files/{fileId}/preview'
85
138
  .gsub('{fileId}', file_id)
86
139
 
87
- params = {
88
- 'width': width,
89
- 'height': height,
90
- 'quality': quality,
91
- 'background': background,
92
- 'output': output
93
- }
140
+ params = {}
141
+
142
+ if !width.nil?
143
+ params[:width] = width
144
+ end
145
+
146
+ if !height.nil?
147
+ params[:height] = height
148
+ end
149
+
150
+ if !gravity.nil?
151
+ params[:gravity] = gravity
152
+ end
153
+
154
+ if !quality.nil?
155
+ params[:quality] = quality
156
+ end
157
+
158
+ if !border_width.nil?
159
+ params[:borderWidth] = border_width
160
+ end
161
+
162
+ if !border_color.nil?
163
+ params[:borderColor] = border_color
164
+ end
165
+
166
+ if !border_radius.nil?
167
+ params[:borderRadius] = border_radius
168
+ end
169
+
170
+ if !opacity.nil?
171
+ params[:opacity] = opacity
172
+ end
173
+
174
+ if !rotation.nil?
175
+ params[:rotation] = rotation
176
+ end
177
+
178
+ if !background.nil?
179
+ params[:background] = background
180
+ end
181
+
182
+ if !output.nil?
183
+ params[:output] = output
184
+ end
94
185
 
95
186
  return @client.call('get', path, {
96
187
  'content-type' => 'application/json',
@@ -98,11 +189,14 @@ module Appwrite
98
189
  end
99
190
 
100
191
  def get_file_view(file_id:)
192
+ if file_id.nil?
193
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
194
+ end
195
+
101
196
  path = '/storage/files/{fileId}/view'
102
197
  .gsub('{fileId}', file_id)
103
198
 
104
- params = {
105
- }
199
+ params = {}
106
200
 
107
201
  return @client.call('get', path, {
108
202
  'content-type' => 'application/json',
@@ -1,28 +1,48 @@
1
1
  module Appwrite
2
2
  class Teams < Service
3
3
 
4
- def list(search: '', limit: 25, offset: 0, order_type: 'ASC')
4
+ def list(search: nil, limit: nil, offset: nil, order_type: nil)
5
5
  path = '/teams'
6
6
 
7
- params = {
8
- 'search': search,
9
- 'limit': limit,
10
- 'offset': offset,
11
- 'orderType': order_type
12
- }
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
20
+
21
+ if !order_type.nil?
22
+ params[:orderType] = order_type
23
+ end
13
24
 
14
25
  return @client.call('get', path, {
15
26
  'content-type' => 'application/json',
16
27
  }, params);
17
28
  end
18
29
 
19
- def create(name:, roles: ["owner"])
30
+ def create(name:, roles: nil)
31
+ if name.nil?
32
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
33
+ end
34
+
20
35
  path = '/teams'
21
36
 
22
- params = {
23
- 'name': name,
24
- 'roles': roles
25
- }
37
+ params = {}
38
+
39
+ if !name.nil?
40
+ params[:name] = name
41
+ end
42
+
43
+ if !roles.nil?
44
+ params[:roles] = roles
45
+ end
26
46
 
27
47
  return @client.call('post', path, {
28
48
  'content-type' => 'application/json',
@@ -30,11 +50,14 @@ module Appwrite
30
50
  end
31
51
 
32
52
  def get(team_id:)
53
+ if team_id.nil?
54
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
55
+ end
56
+
33
57
  path = '/teams/{teamId}'
34
58
  .gsub('{teamId}', team_id)
35
59
 
36
- params = {
37
- }
60
+ params = {}
38
61
 
39
62
  return @client.call('get', path, {
40
63
  'content-type' => 'application/json',
@@ -42,12 +65,22 @@ module Appwrite
42
65
  end
43
66
 
44
67
  def update(team_id:, name:)
68
+ if team_id.nil?
69
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
70
+ end
71
+
72
+ if name.nil?
73
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
74
+ end
75
+
45
76
  path = '/teams/{teamId}'
46
77
  .gsub('{teamId}', team_id)
47
78
 
48
- params = {
49
- 'name': name
50
- }
79
+ params = {}
80
+
81
+ if !name.nil?
82
+ params[:name] = name
83
+ end
51
84
 
52
85
  return @client.call('put', path, {
53
86
  'content-type' => 'application/json',
@@ -55,62 +88,178 @@ module Appwrite
55
88
  end
56
89
 
57
90
  def delete(team_id:)
91
+ if team_id.nil?
92
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
93
+ end
94
+
58
95
  path = '/teams/{teamId}'
59
96
  .gsub('{teamId}', team_id)
60
97
 
61
- params = {
62
- }
98
+ params = {}
63
99
 
64
100
  return @client.call('delete', path, {
65
101
  'content-type' => 'application/json',
66
102
  }, params);
67
103
  end
68
104
 
69
- def get_memberships(team_id:, search: '', limit: 25, offset: 0, order_type: 'ASC')
105
+ def get_memberships(team_id:, search: nil, limit: nil, offset: nil, order_type: nil)
106
+ if team_id.nil?
107
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
108
+ end
109
+
70
110
  path = '/teams/{teamId}/memberships'
71
111
  .gsub('{teamId}', team_id)
72
112
 
73
- params = {
74
- 'search': search,
75
- 'limit': limit,
76
- 'offset': offset,
77
- 'orderType': order_type
78
- }
113
+ params = {}
114
+
115
+ if !search.nil?
116
+ params[:search] = search
117
+ end
118
+
119
+ if !limit.nil?
120
+ params[:limit] = limit
121
+ end
122
+
123
+ if !offset.nil?
124
+ params[:offset] = offset
125
+ end
126
+
127
+ if !order_type.nil?
128
+ params[:orderType] = order_type
129
+ end
79
130
 
80
131
  return @client.call('get', path, {
81
132
  'content-type' => 'application/json',
82
133
  }, params);
83
134
  end
84
135
 
85
- def create_membership(team_id:, email:, roles:, url:, name: '')
136
+ def create_membership(team_id:, email:, roles:, url:, name: nil)
137
+ if team_id.nil?
138
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
139
+ end
140
+
141
+ if email.nil?
142
+ raise Appwrite::Exception.new('Missing required parameter: "email"')
143
+ end
144
+
145
+ if roles.nil?
146
+ raise Appwrite::Exception.new('Missing required parameter: "roles"')
147
+ end
148
+
149
+ if url.nil?
150
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
151
+ end
152
+
86
153
  path = '/teams/{teamId}/memberships'
87
154
  .gsub('{teamId}', team_id)
88
155
 
89
- params = {
90
- 'email': email,
91
- 'name': name,
92
- 'roles': roles,
93
- 'url': url
94
- }
156
+ params = {}
157
+
158
+ if !email.nil?
159
+ params[:email] = email
160
+ end
161
+
162
+ if !name.nil?
163
+ params[:name] = name
164
+ end
165
+
166
+ if !roles.nil?
167
+ params[:roles] = roles
168
+ end
169
+
170
+ if !url.nil?
171
+ params[:url] = url
172
+ end
95
173
 
96
174
  return @client.call('post', path, {
97
175
  'content-type' => 'application/json',
98
176
  }, params);
99
177
  end
100
178
 
101
- def delete_membership(team_id:, invite_id:)
102
- path = '/teams/{teamId}/memberships/{inviteId}'
179
+ def update_membership_roles(team_id:, membership_id:, roles:)
180
+ if team_id.nil?
181
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
182
+ end
183
+
184
+ if membership_id.nil?
185
+ raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
186
+ end
187
+
188
+ if roles.nil?
189
+ raise Appwrite::Exception.new('Missing required parameter: "roles"')
190
+ end
191
+
192
+ path = '/teams/{teamId}/memberships/{membershipId}'
103
193
  .gsub('{teamId}', team_id)
104
- .gsub('{inviteId}', invite_id)
194
+ .gsub('{membershipId}', membership_id)
195
+
196
+ params = {}
197
+
198
+ if !roles.nil?
199
+ params[:roles] = roles
200
+ end
105
201
 
106
- params = {
107
- }
202
+ return @client.call('patch', path, {
203
+ 'content-type' => 'application/json',
204
+ }, params);
205
+ end
206
+
207
+ def delete_membership(team_id:, membership_id:)
208
+ if team_id.nil?
209
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
210
+ end
211
+
212
+ if membership_id.nil?
213
+ raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
214
+ end
215
+
216
+ path = '/teams/{teamId}/memberships/{membershipId}'
217
+ .gsub('{teamId}', team_id)
218
+ .gsub('{membershipId}', membership_id)
219
+
220
+ params = {}
108
221
 
109
222
  return @client.call('delete', path, {
110
223
  'content-type' => 'application/json',
111
224
  }, params);
112
225
  end
113
226
 
227
+ def update_membership_status(team_id:, membership_id:, user_id:, secret:)
228
+ if team_id.nil?
229
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
230
+ end
231
+
232
+ if membership_id.nil?
233
+ raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
234
+ end
235
+
236
+ if user_id.nil?
237
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
238
+ end
239
+
240
+ if secret.nil?
241
+ raise Appwrite::Exception.new('Missing required parameter: "secret"')
242
+ end
243
+
244
+ path = '/teams/{teamId}/memberships/{membershipId}/status'
245
+ .gsub('{teamId}', team_id)
246
+ .gsub('{membershipId}', membership_id)
247
+
248
+ params = {}
249
+
250
+ if !user_id.nil?
251
+ params[:userId] = user_id
252
+ end
253
+
254
+ if !secret.nil?
255
+ params[:secret] = secret
256
+ end
257
+
258
+ return @client.call('patch', path, {
259
+ 'content-type' => 'application/json',
260
+ }, params);
261
+ end
262
+
114
263
 
115
264
  protected
116
265