appwrite 2.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +197 -56
  3. data/lib/appwrite/exception.rb +7 -7
  4. data/lib/appwrite/file.rb +9 -15
  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/bucket.rb +82 -0
  15. data/lib/appwrite/models/bucket_list.rb +32 -0
  16. data/lib/appwrite/models/collection.rb +62 -0
  17. data/lib/appwrite/models/collection_list.rb +32 -0
  18. data/lib/appwrite/models/continent.rb +32 -0
  19. data/lib/appwrite/models/continent_list.rb +32 -0
  20. data/lib/appwrite/models/country.rb +32 -0
  21. data/lib/appwrite/models/country_list.rb +32 -0
  22. data/lib/appwrite/models/currency.rb +57 -0
  23. data/lib/appwrite/models/currency_list.rb +32 -0
  24. data/lib/appwrite/models/deployment.rb +77 -0
  25. data/lib/appwrite/models/deployment_list.rb +32 -0
  26. data/lib/appwrite/models/document.rb +50 -0
  27. data/lib/appwrite/models/document_list.rb +36 -0
  28. data/lib/appwrite/models/execution.rb +72 -0
  29. data/lib/appwrite/models/execution_list.rb +32 -0
  30. data/lib/appwrite/models/file.rb +77 -0
  31. data/lib/appwrite/models/file_list.rb +32 -0
  32. data/lib/appwrite/models/function.rb +92 -0
  33. data/lib/appwrite/models/function_list.rb +32 -0
  34. data/lib/appwrite/models/health_antivirus.rb +32 -0
  35. data/lib/appwrite/models/health_queue.rb +27 -0
  36. data/lib/appwrite/models/health_status.rb +32 -0
  37. data/lib/appwrite/models/health_time.rb +37 -0
  38. data/lib/appwrite/models/index.rb +47 -0
  39. data/lib/appwrite/models/index_list.rb +32 -0
  40. data/lib/appwrite/models/language.rb +37 -0
  41. data/lib/appwrite/models/language_list.rb +32 -0
  42. data/lib/appwrite/models/locale.rb +57 -0
  43. data/lib/appwrite/models/log.rb +127 -0
  44. data/lib/appwrite/models/log_list.rb +32 -0
  45. data/lib/appwrite/models/membership.rb +67 -0
  46. data/lib/appwrite/models/membership_list.rb +32 -0
  47. data/lib/appwrite/models/phone.rb +37 -0
  48. data/lib/appwrite/models/phone_list.rb +32 -0
  49. data/lib/appwrite/models/preferences.rb +30 -0
  50. data/lib/appwrite/models/runtime.rb +57 -0
  51. data/lib/appwrite/models/runtime_list.rb +32 -0
  52. data/lib/appwrite/models/session.rb +142 -0
  53. data/lib/appwrite/models/session_list.rb +32 -0
  54. data/lib/appwrite/models/team.rb +42 -0
  55. data/lib/appwrite/models/team_list.rb +32 -0
  56. data/lib/appwrite/models/token.rb +42 -0
  57. data/lib/appwrite/models/user.rb +62 -0
  58. data/lib/appwrite/models/user_list.rb +32 -0
  59. data/lib/appwrite/query.rb +42 -0
  60. data/lib/appwrite/service.rb +0 -5
  61. data/lib/appwrite/services/account.rb +400 -138
  62. data/lib/appwrite/services/avatars.rb +188 -125
  63. data/lib/appwrite/services/database.rb +875 -130
  64. data/lib/appwrite/services/functions.rb +439 -207
  65. data/lib/appwrite/services/health.rb +201 -58
  66. data/lib/appwrite/services/locale.rb +133 -32
  67. data/lib/appwrite/services/storage.rb +469 -118
  68. data/lib/appwrite/services/teams.rb +302 -118
  69. data/lib/appwrite/services/users.rb +322 -127
  70. data/lib/appwrite.rb +57 -0
  71. metadata +74 -108
  72. data/.travis.yml +0 -16
  73. data/CHANGELOG.md +0 -1
  74. data/Gemfile +0 -4
  75. data/LICENSE +0 -12
  76. data/README.md +0 -96
  77. data/appwrite.gemspec +0 -11
  78. data/docs/examples/account/create-recovery.md +0 -15
  79. data/docs/examples/account/create-verification.md +0 -15
  80. data/docs/examples/account/delete-session.md +0 -15
  81. data/docs/examples/account/delete-sessions.md +0 -15
  82. data/docs/examples/account/delete.md +0 -15
  83. data/docs/examples/account/get-logs.md +0 -15
  84. data/docs/examples/account/get-prefs.md +0 -15
  85. data/docs/examples/account/get-session.md +0 -15
  86. data/docs/examples/account/get-sessions.md +0 -15
  87. data/docs/examples/account/get.md +0 -15
  88. data/docs/examples/account/update-email.md +0 -15
  89. data/docs/examples/account/update-name.md +0 -15
  90. data/docs/examples/account/update-password.md +0 -15
  91. data/docs/examples/account/update-prefs.md +0 -15
  92. data/docs/examples/account/update-recovery.md +0 -15
  93. data/docs/examples/account/update-verification.md +0 -15
  94. data/docs/examples/avatars/get-browser.md +0 -15
  95. data/docs/examples/avatars/get-credit-card.md +0 -15
  96. data/docs/examples/avatars/get-favicon.md +0 -15
  97. data/docs/examples/avatars/get-flag.md +0 -15
  98. data/docs/examples/avatars/get-image.md +0 -15
  99. data/docs/examples/avatars/get-initials.md +0 -15
  100. data/docs/examples/avatars/get-q-r.md +0 -15
  101. data/docs/examples/database/create-collection.md +0 -15
  102. data/docs/examples/database/create-document.md +0 -15
  103. data/docs/examples/database/delete-collection.md +0 -15
  104. data/docs/examples/database/delete-document.md +0 -15
  105. data/docs/examples/database/get-collection.md +0 -15
  106. data/docs/examples/database/get-document.md +0 -15
  107. data/docs/examples/database/list-collections.md +0 -15
  108. data/docs/examples/database/list-documents.md +0 -15
  109. data/docs/examples/database/update-collection.md +0 -15
  110. data/docs/examples/database/update-document.md +0 -15
  111. data/docs/examples/functions/create-execution.md +0 -15
  112. data/docs/examples/functions/create-tag.md +0 -15
  113. data/docs/examples/functions/create.md +0 -15
  114. data/docs/examples/functions/delete-tag.md +0 -15
  115. data/docs/examples/functions/delete.md +0 -15
  116. data/docs/examples/functions/get-execution.md +0 -15
  117. data/docs/examples/functions/get-tag.md +0 -15
  118. data/docs/examples/functions/get.md +0 -15
  119. data/docs/examples/functions/list-executions.md +0 -15
  120. data/docs/examples/functions/list-tags.md +0 -15
  121. data/docs/examples/functions/list.md +0 -15
  122. data/docs/examples/functions/update-tag.md +0 -15
  123. data/docs/examples/functions/update.md +0 -15
  124. data/docs/examples/health/get-anti-virus.md +0 -15
  125. data/docs/examples/health/get-cache.md +0 -15
  126. data/docs/examples/health/get-d-b.md +0 -15
  127. data/docs/examples/health/get-queue-certificates.md +0 -15
  128. data/docs/examples/health/get-queue-functions.md +0 -15
  129. data/docs/examples/health/get-queue-logs.md +0 -15
  130. data/docs/examples/health/get-queue-tasks.md +0 -15
  131. data/docs/examples/health/get-queue-usage.md +0 -15
  132. data/docs/examples/health/get-queue-webhooks.md +0 -15
  133. data/docs/examples/health/get-storage-local.md +0 -15
  134. data/docs/examples/health/get-time.md +0 -15
  135. data/docs/examples/health/get.md +0 -15
  136. data/docs/examples/locale/get-continents.md +0 -15
  137. data/docs/examples/locale/get-countries-e-u.md +0 -15
  138. data/docs/examples/locale/get-countries-phones.md +0 -15
  139. data/docs/examples/locale/get-countries.md +0 -15
  140. data/docs/examples/locale/get-currencies.md +0 -15
  141. data/docs/examples/locale/get-languages.md +0 -15
  142. data/docs/examples/locale/get.md +0 -15
  143. data/docs/examples/storage/create-file.md +0 -15
  144. data/docs/examples/storage/delete-file.md +0 -15
  145. data/docs/examples/storage/get-file-download.md +0 -15
  146. data/docs/examples/storage/get-file-preview.md +0 -15
  147. data/docs/examples/storage/get-file-view.md +0 -15
  148. data/docs/examples/storage/get-file.md +0 -15
  149. data/docs/examples/storage/list-files.md +0 -15
  150. data/docs/examples/storage/update-file.md +0 -15
  151. data/docs/examples/teams/create-membership.md +0 -15
  152. data/docs/examples/teams/create.md +0 -15
  153. data/docs/examples/teams/delete-membership.md +0 -15
  154. data/docs/examples/teams/delete.md +0 -15
  155. data/docs/examples/teams/get-memberships.md +0 -15
  156. data/docs/examples/teams/get.md +0 -15
  157. data/docs/examples/teams/list.md +0 -15
  158. data/docs/examples/teams/update-membership-roles.md +0 -15
  159. data/docs/examples/teams/update-membership-status.md +0 -15
  160. data/docs/examples/teams/update.md +0 -15
  161. data/docs/examples/users/create.md +0 -15
  162. data/docs/examples/users/delete-session.md +0 -15
  163. data/docs/examples/users/delete-sessions.md +0 -15
  164. data/docs/examples/users/delete.md +0 -15
  165. data/docs/examples/users/get-logs.md +0 -15
  166. data/docs/examples/users/get-prefs.md +0 -15
  167. data/docs/examples/users/get-sessions.md +0 -15
  168. data/docs/examples/users/get.md +0 -15
  169. data/docs/examples/users/list.md +0 -15
  170. data/docs/examples/users/update-email.md +0 -15
  171. data/docs/examples/users/update-name.md +0 -15
  172. data/docs/examples/users/update-password.md +0 -15
  173. data/docs/examples/users/update-prefs.md +0 -15
  174. data/docs/examples/users/update-status.md +0 -15
  175. data/docs/examples/users/update-verification.md +0 -15
@@ -1,6 +1,19 @@
1
+ #frozen_string_literal: true
2
+
1
3
  module Appwrite
2
4
  class Avatars < Service
3
5
 
6
+ # You can use this endpoint to show different browser icons to your users.
7
+ # The code argument receives the browser code as it appears in your user
8
+ # /account/sessions endpoint. Use width, height and quality arguments to
9
+ # change the output settings.
10
+ #
11
+ # @param [string] code Browser Code.
12
+ # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
13
+ # @param [number] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
14
+ # @param [number] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
15
+ #
16
+ # @return []
4
17
  def get_browser(code:, width: nil, height: nil, quality: nil)
5
18
  if code.nil?
6
19
  raise Appwrite::Exception.new('Missing required parameter: "code"')
@@ -9,25 +22,34 @@ module Appwrite
9
22
  path = '/avatars/browsers/{code}'
10
23
  .gsub('{code}', code)
11
24
 
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
25
-
26
- return @client.call('get', path, {
27
- 'content-type' => 'application/json',
28
- }, params);
25
+ params = {
26
+ width: width,
27
+ height: height,
28
+ quality: quality,
29
+ }
30
+
31
+ headers = {
32
+ "content-type": 'application/json',
33
+ }
34
+
35
+ @client.call(
36
+ method: 'GET',
37
+ path: path,
38
+ headers: headers,
39
+ params: params,
40
+ )
29
41
  end
30
42
 
43
+ # The credit card endpoint will return you the icon of the credit card
44
+ # provider you need. Use width, height and quality arguments to change the
45
+ # output settings.
46
+ #
47
+ # @param [string] code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
48
+ # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
49
+ # @param [number] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
50
+ # @param [number] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
51
+ #
52
+ # @return []
31
53
  def get_credit_card(code:, width: nil, height: nil, quality: nil)
32
54
  if code.nil?
33
55
  raise Appwrite::Exception.new('Missing required parameter: "code"')
@@ -36,25 +58,31 @@ module Appwrite
36
58
  path = '/avatars/credit-cards/{code}'
37
59
  .gsub('{code}', code)
38
60
 
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
52
-
53
- return @client.call('get', path, {
54
- 'content-type' => 'application/json',
55
- }, params);
61
+ params = {
62
+ width: width,
63
+ height: height,
64
+ quality: quality,
65
+ }
66
+
67
+ headers = {
68
+ "content-type": 'application/json',
69
+ }
70
+
71
+ @client.call(
72
+ method: 'GET',
73
+ path: path,
74
+ headers: headers,
75
+ params: params,
76
+ )
56
77
  end
57
78
 
79
+ # Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
80
+ # website URL.
81
+ #
82
+ #
83
+ # @param [string] url Website URL which you want to fetch the favicon from.
84
+ #
85
+ # @return []
58
86
  def get_favicon(url:)
59
87
  if url.nil?
60
88
  raise Appwrite::Exception.new('Missing required parameter: "url"')
@@ -62,17 +90,32 @@ module Appwrite
62
90
 
63
91
  path = '/avatars/favicon'
64
92
 
65
- params = {}
93
+ params = {
94
+ url: url,
95
+ }
66
96
 
67
- if !url.nil?
68
- params[:url] = url
69
- end
97
+ headers = {
98
+ "content-type": 'application/json',
99
+ }
70
100
 
71
- return @client.call('get', path, {
72
- 'content-type' => 'application/json',
73
- }, params);
101
+ @client.call(
102
+ method: 'GET',
103
+ path: path,
104
+ headers: headers,
105
+ params: params,
106
+ )
74
107
  end
75
108
 
109
+ # You can use this endpoint to show different country flags icons to your
110
+ # users. The code argument receives the 2 letter country code. Use width,
111
+ # height and quality arguments to change the output settings.
112
+ #
113
+ # @param [string] code Country Code. ISO Alpha-2 country code format.
114
+ # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
115
+ # @param [number] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
116
+ # @param [number] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
117
+ #
118
+ # @return []
76
119
  def get_flag(code:, width: nil, height: nil, quality: nil)
77
120
  if code.nil?
78
121
  raise Appwrite::Exception.new('Missing required parameter: "code"')
@@ -81,25 +124,34 @@ module Appwrite
81
124
  path = '/avatars/flags/{code}'
82
125
  .gsub('{code}', code)
83
126
 
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
97
-
98
- return @client.call('get', path, {
99
- 'content-type' => 'application/json',
100
- }, params);
127
+ params = {
128
+ width: width,
129
+ height: height,
130
+ quality: quality,
131
+ }
132
+
133
+ headers = {
134
+ "content-type": 'application/json',
135
+ }
136
+
137
+ @client.call(
138
+ method: 'GET',
139
+ path: path,
140
+ headers: headers,
141
+ params: params,
142
+ )
101
143
  end
102
144
 
145
+ # Use this endpoint to fetch a remote image URL and crop it to any image size
146
+ # you want. This endpoint is very useful if you need to crop and display
147
+ # remote images in your app or in case you want to make sure a 3rd party
148
+ # image is properly served using a TLS protocol.
149
+ #
150
+ # @param [string] url Image URL which you want to crop.
151
+ # @param [number] width Resize preview image width, Pass an integer between 0 to 2000.
152
+ # @param [number] height Resize preview image height, Pass an integer between 0 to 2000.
153
+ #
154
+ # @return []
103
155
  def get_image(url:, width: nil, height: nil)
104
156
  if url.nil?
105
157
  raise Appwrite::Exception.new('Missing required parameter: "url"')
@@ -107,55 +159,74 @@ module Appwrite
107
159
 
108
160
  path = '/avatars/image'
109
161
 
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
123
-
124
- return @client.call('get', path, {
125
- 'content-type' => 'application/json',
126
- }, params);
162
+ params = {
163
+ url: url,
164
+ width: width,
165
+ height: height,
166
+ }
167
+
168
+ headers = {
169
+ "content-type": 'application/json',
170
+ }
171
+
172
+ @client.call(
173
+ method: 'GET',
174
+ path: path,
175
+ headers: headers,
176
+ params: params,
177
+ )
127
178
  end
128
179
 
180
+ # Use this endpoint to show your user initials avatar icon on your website or
181
+ # app. By default, this route will try to print your logged-in user name or
182
+ # email initials. You can also overwrite the user name if you pass the 'name'
183
+ # parameter. If no name is given and no user is logged, an empty avatar will
184
+ # be returned.
185
+ #
186
+ # You can use the color and background params to change the avatar colors. By
187
+ # default, a random theme will be selected. The random theme will persist for
188
+ # the user's initials when reloading the same theme will always return for
189
+ # the same initials.
190
+ #
191
+ # @param [string] name Full Name. When empty, current user name or email will be used. Max length: 128 chars.
192
+ # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
193
+ # @param [number] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
194
+ # @param [string] color Changes text color. By default a random color will be picked and stay will persistent to the given name.
195
+ # @param [string] background Changes background color. By default a random color will be picked and stay will persistent to the given name.
196
+ #
197
+ # @return []
129
198
  def get_initials(name: nil, width: nil, height: nil, color: nil, background: nil)
130
199
  path = '/avatars/initials'
131
200
 
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);
201
+ params = {
202
+ name: name,
203
+ width: width,
204
+ height: height,
205
+ color: color,
206
+ background: background,
207
+ }
208
+
209
+ headers = {
210
+ "content-type": 'application/json',
211
+ }
212
+
213
+ @client.call(
214
+ method: 'GET',
215
+ path: path,
216
+ headers: headers,
217
+ params: params,
218
+ )
157
219
  end
158
220
 
221
+ # Converts a given plain text to a QR code image. You can use the query
222
+ # parameters to change the size and style of the resulting image.
223
+ #
224
+ # @param [string] text Plain text to be converted to QR code image.
225
+ # @param [number] size QR code size. Pass an integer between 0 to 1000. Defaults to 400.
226
+ # @param [number] margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
227
+ # @param [boolean] download Return resulting image with &#039;Content-Disposition: attachment &#039; headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.
228
+ #
229
+ # @return []
159
230
  def get_qr(text:, size: nil, margin: nil, download: nil)
160
231
  if text.nil?
161
232
  raise Appwrite::Exception.new('Missing required parameter: "text"')
@@ -163,32 +234,24 @@ module Appwrite
163
234
 
164
235
  path = '/avatars/qr'
165
236
 
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
183
-
184
- return @client.call('get', path, {
185
- 'content-type' => 'application/json',
186
- }, params);
237
+ params = {
238
+ text: text,
239
+ size: size,
240
+ margin: margin,
241
+ download: download,
242
+ }
243
+
244
+ headers = {
245
+ "content-type": 'application/json',
246
+ }
247
+
248
+ @client.call(
249
+ method: 'GET',
250
+ path: path,
251
+ headers: headers,
252
+ params: params,
253
+ )
187
254
  end
188
255
 
189
-
190
- protected
191
-
192
- private
193
256
  end
194
257
  end