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