appwrite 24.1.0 → 25.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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +109 -32
  3. data/lib/appwrite/enums/backup_services.rb +1 -0
  4. data/lib/appwrite/enums/{theme.rb → browser_theme.rb} +1 -1
  5. data/lib/appwrite/enums/build_runtime.rb +2 -3
  6. data/lib/appwrite/enums/{name.rb → health_queue_name.rb} +1 -1
  7. data/lib/appwrite/enums/organization_key_scopes.rb +16 -0
  8. data/lib/appwrite/enums/project_o_auth_provider_id.rb +0 -2
  9. data/lib/appwrite/enums/project_policy_id.rb +3 -0
  10. data/lib/appwrite/enums/region.rb +12 -0
  11. data/lib/appwrite/enums/runtime.rb +2 -3
  12. data/lib/appwrite/enums/status_code.rb +4 -4
  13. data/lib/appwrite/models/activity_event.rb +20 -20
  14. data/lib/appwrite/models/function.rb +10 -0
  15. data/lib/appwrite/models/policy_deny_aliased_email.rb +32 -0
  16. data/lib/appwrite/models/policy_deny_disposable_email.rb +32 -0
  17. data/lib/appwrite/models/policy_deny_free_email.rb +32 -0
  18. data/lib/appwrite/models/presence.rb +2 -6
  19. data/lib/appwrite/models/presence_list.rb +0 -4
  20. data/lib/appwrite/models/project_list.rb +32 -0
  21. data/lib/appwrite/models/site.rb +10 -0
  22. data/lib/appwrite/models/usage_gauge.rb +13 -3
  23. data/lib/appwrite/services/avatars.rb +1 -1
  24. data/lib/appwrite/services/functions.rb +10 -2
  25. data/lib/appwrite/services/health.rb +1 -1
  26. data/lib/appwrite/services/organization.rb +349 -0
  27. data/lib/appwrite/services/presences.rb +1 -1
  28. data/lib/appwrite/services/project.rb +66 -51
  29. data/lib/appwrite/services/sites.rb +10 -2
  30. data/lib/appwrite/services/usage.rb +10 -10
  31. data/lib/appwrite.rb +12 -6
  32. metadata +11 -5
  33. data/lib/appwrite/enums/scopes.rb +0 -100
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 117e69f27971b35ba99f0ccc63cfb9a3494955eef4e214048b38aa4ba57e1b80
4
- data.tar.gz: d0e41de1a5f8550c33b3db61262a9e4f7b4facfafdfccc63f1e2a9d9947b045e
3
+ metadata.gz: dfd2490881b125f29ab7d8d65ac5934317484bfbc15a0793f512f3cc9d464d76
4
+ data.tar.gz: 7880fbf970bb0fd2a39da4e2a9ffa1435628f1525f9dbcd1ab37ab8a67752c57
5
5
  SHA512:
6
- metadata.gz: 5ef18be9f1d2867aac51d1bd83955e5da5e9cf6f92d6d42759d1e7f45c1e95f4e66606e70e1e965e7092f3274923dd04f9cf041a51eaf9a6b7b0df085bfa31d7
7
- data.tar.gz: 7afc04eac74397f0381624d0a3ddce3da33ff80468414856b6ec9e35028437ccee66bfc71f88af12c7f8242def21f63e783053112029271b4e90248a014b74b1
6
+ metadata.gz: c8dc0aeb0e1670c64ab2f605b6fefc7185a523dac9597982db580794ebf13f06d6c6481383cc635a68fdc247ec800f72eb081fc9f828e873ce255ef0cd8e4b6d
7
+ data.tar.gz: b322e85c4907fd3bc68501b3cef4272e877696edb0efc4d53168bb648782a7e951bae8eb7999c088daa7755e8483f0c38b634ff51be965166270dba87be1f7ff
@@ -15,7 +15,7 @@ module Appwrite
15
15
  'x-sdk-name'=> 'Ruby',
16
16
  'x-sdk-platform'=> 'server',
17
17
  'x-sdk-language'=> 'ruby',
18
- 'x-sdk-version'=> '24.1.0',
18
+ 'x-sdk-version'=> '25.0.0',
19
19
  'X-Appwrite-Response-Format' => '1.9.5'
20
20
  }
21
21
  @endpoint = 'https://cloud.appwrite.io/v1'
@@ -262,56 +262,133 @@ module Appwrite
262
262
 
263
263
  offset = 0
264
264
  id_param_name = id_param_name.to_sym if id_param_name
265
+ upload_id = nil
266
+ chunks_uploaded = 0
265
267
  if id_param_name&.empty? == false
268
+ upload_id = params[id_param_name]
266
269
  # Make a request to check if a file already exists
267
- current = call(
268
- method: "GET",
269
- path: "#{path}/#{params[id_param_name]}",
270
- headers: headers,
271
- params: {}
272
- )
273
- chunks_uploaded = current['chunksUploaded'].to_i
274
- offset = chunks_uploaded * @chunk_size
270
+ begin
271
+ current = call(
272
+ method: "GET",
273
+ path: "#{path}/#{params[id_param_name]}",
274
+ headers: headers,
275
+ params: {}
276
+ )
277
+ chunks_uploaded = current['chunksUploaded'].to_i
278
+ offset = chunks_uploaded * @chunk_size
279
+ rescue Appwrite::Exception => error
280
+ raise error unless error.code.to_i == 404
281
+ end
275
282
  end
276
283
 
284
+ total_chunks = (size.to_f / @chunk_size).ceil
285
+ chunks = []
277
286
  while offset < size
287
+ chunks << {
288
+ index: chunks_uploaded.to_i,
289
+ start: offset,
290
+ ending: [offset + @chunk_size, size].min
291
+ }
292
+ offset += @chunk_size
293
+ chunks_uploaded = chunks_uploaded.to_i + 1
294
+ end
295
+
296
+ result = current if defined?(current)
297
+ return result unless chunks.any?
298
+
299
+ upload_chunk = lambda do |chunk, current_upload_id|
278
300
  case input_file.source_type
279
301
  when 'path'
280
- string = IO.read(input_file.path, @chunk_size, offset)
302
+ string = IO.read(input_file.path, chunk[:ending] - chunk[:start], chunk[:start])
281
303
  when 'string'
282
- string = input_file.data.byteslice(offset, [@chunk_size, size - offset].min)
304
+ string = input_file.data.byteslice(chunk[:start], chunk[:ending] - chunk[:start])
283
305
  end
284
306
 
285
- params[param_name.to_sym] = InputFile::from_string(
307
+ chunk_params = params.merge(param_name.to_sym => InputFile::from_string(
286
308
  string,
287
309
  filename: input_file.filename,
288
310
  mime_type: input_file.mime_type
289
- )
311
+ ))
290
312
 
291
- headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, size - 1].min}/#{size}"
313
+ chunk_headers = headers.merge('content-range' => "bytes #{chunk[:start]}-#{chunk[:ending] - 1}/#{size}")
314
+ chunk_headers['x-appwrite-id'] = current_upload_id if current_upload_id
292
315
 
293
- result = call(
316
+ call(
294
317
  method: 'POST',
295
318
  path: path,
296
- headers: headers,
297
- params: params,
319
+ headers: chunk_headers,
320
+ params: chunk_params,
298
321
  )
322
+ end
299
323
 
300
- offset += @chunk_size
324
+ result = upload_chunk.call(chunks.first, upload_id)
325
+ upload_id = result['$id'] if result['$id']
326
+ completed_count = chunks.first[:index] + 1
327
+ uploaded_size = chunks.first[:ending]
301
328
 
302
- if defined? result['$id']
303
- headers['x-appwrite-id'] = result['$id']
304
- end
329
+ upload_complete = lambda do |chunk_result|
330
+ chunks_uploaded = chunk_result['chunksUploaded']
331
+ return false if chunks_uploaded.nil?
305
332
 
306
- on_progress.call({
307
- id: result['$id'],
308
- progress: ([offset, size].min).to_f/size.to_f * 100.0,
309
- size_uploaded: [offset, size].min,
310
- chunks_total: result['chunksTotal'],
311
- chunks_uploaded: result['chunksUploaded']
312
- }) unless on_progress.nil?
333
+ chunks_total = chunk_result['chunksTotal'] || total_chunks
334
+ chunks_uploaded.to_i >= chunks_total.to_i
313
335
  end
314
336
 
337
+ on_progress.call({
338
+ id: result['$id'],
339
+ progress: uploaded_size.to_f/size.to_f * 100.0,
340
+ size_uploaded: uploaded_size,
341
+ chunks_total: result['chunksTotal'] || total_chunks,
342
+ chunks_uploaded: result['chunksUploaded'] || completed_count
343
+ }) unless on_progress.nil?
344
+
345
+ mutex = Mutex.new
346
+ queue = Queue.new
347
+ chunks.drop(1).each { |chunk| queue << chunk }
348
+ first_error = nil
349
+ last_result = result
350
+ completed_result = nil
351
+
352
+ workers = [8, queue.size].min.times.map do
353
+ Thread.new do
354
+ loop do
355
+ break if mutex.synchronize { !first_error.nil? }
356
+
357
+ chunk = begin
358
+ queue.pop(true)
359
+ rescue ThreadError
360
+ nil
361
+ end
362
+ break unless chunk
363
+
364
+ begin
365
+ chunk_result = upload_chunk.call(chunk, upload_id)
366
+ rescue => error
367
+ mutex.synchronize { first_error ||= error }
368
+ break
369
+ end
370
+ mutex.synchronize do
371
+ completed_count += 1
372
+ uploaded_size += chunk[:ending] - chunk[:start]
373
+ last_result = chunk_result
374
+ completed_result = chunk_result if upload_complete.call(chunk_result)
375
+ on_progress.call({
376
+ id: upload_id,
377
+ progress: uploaded_size.to_f/size.to_f * 100.0,
378
+ size_uploaded: uploaded_size,
379
+ chunks_total: chunk_result['chunksTotal'] || total_chunks,
380
+ chunks_uploaded: chunk_result['chunksUploaded'] || completed_count
381
+ }) unless on_progress.nil?
382
+ end
383
+ end
384
+ end
385
+ end
386
+
387
+ workers.each(&:join)
388
+ raise first_error if first_error
389
+
390
+ result = completed_result || last_result
391
+
315
392
  return result unless response_type.respond_to?("from")
316
393
 
317
394
  response_type.from(map: result)
@@ -329,8 +406,8 @@ module Appwrite
329
406
  )
330
407
  raise ArgumentError, 'Too Many HTTP Redirects' if limit == 0
331
408
 
332
- @http = Net::HTTP.new(uri.host, uri.port) unless defined? @http
333
- @http.use_ssl = !@self_signed
409
+ http = Net::HTTP.new(uri.host, uri.port)
410
+ http.use_ssl = !@self_signed
334
411
  payload = ''
335
412
 
336
413
  headers = @headers.merge(headers)
@@ -351,7 +428,7 @@ module Appwrite
351
428
  end
352
429
 
353
430
  begin
354
- response = @http.send_request(method, uri.request_uri, payload, headers)
431
+ response = http.send_request(method, uri.request_uri, payload, headers)
355
432
  rescue => error
356
433
  raise Appwrite::Exception.new(error.message)
357
434
  end
@@ -382,7 +459,7 @@ module Appwrite
382
459
  end
383
460
 
384
461
  if response.code.to_i >= 400
385
- raise Appwrite::Exception.new(result['message'], result['status'], result['type'], response.body)
462
+ raise Appwrite::Exception.new(result['message'], response.code, result['type'], response.body)
386
463
  end
387
464
 
388
465
  unless response_type.respond_to?("from")
@@ -5,6 +5,7 @@ module Appwrite
5
5
  TABLESDB = 'tablesdb'
6
6
  DOCUMENTSDB = 'documentsdb'
7
7
  VECTORSDB = 'vectorsdb'
8
+ DEDICATEDDATABASES = 'dedicatedDatabases'
8
9
  FUNCTIONS = 'functions'
9
10
  STORAGE = 'storage'
10
11
  end
@@ -1,6 +1,6 @@
1
1
  module Appwrite
2
2
  module Enums
3
- module Theme
3
+ module BrowserTheme
4
4
  LIGHT = 'light'
5
5
  DARK = 'dark'
6
6
  end
@@ -32,9 +32,6 @@ module Appwrite
32
32
  PYTHON_ML_3_11 = 'python-ml-3.11'
33
33
  PYTHON_ML_3_12 = 'python-ml-3.12'
34
34
  PYTHON_ML_3_13 = 'python-ml-3.13'
35
- DENO_1_21 = 'deno-1.21'
36
- DENO_1_24 = 'deno-1.24'
37
- DENO_1_35 = 'deno-1.35'
38
35
  DENO_1_40 = 'deno-1.40'
39
36
  DENO_1_46 = 'deno-1.46'
40
37
  DENO_2_0 = 'deno-2.0'
@@ -53,6 +50,7 @@ module Appwrite
53
50
  DART_3_9 = 'dart-3.9'
54
51
  DART_3_10 = 'dart-3.10'
55
52
  DART_3_11 = 'dart-3.11'
53
+ DART_3_12 = 'dart-3.12'
56
54
  DOTNET_6_0 = 'dotnet-6.0'
57
55
  DOTNET_7_0 = 'dotnet-7.0'
58
56
  DOTNET_8_0 = 'dotnet-8.0'
@@ -93,6 +91,7 @@ module Appwrite
93
91
  FLUTTER_3_35 = 'flutter-3.35'
94
92
  FLUTTER_3_38 = 'flutter-3.38'
95
93
  FLUTTER_3_41 = 'flutter-3.41'
94
+ FLUTTER_3_44 = 'flutter-3.44'
96
95
  end
97
96
  end
98
97
  end
@@ -1,6 +1,6 @@
1
1
  module Appwrite
2
2
  module Enums
3
- module Name
3
+ module HealthQueueName
4
4
  V1_DATABASE = 'v1-database'
5
5
  V1_DELETES = 'v1-deletes'
6
6
  V1_AUDITS = 'v1-audits'
@@ -0,0 +1,16 @@
1
+ module Appwrite
2
+ module Enums
3
+ module OrganizationKeyScopes
4
+ PROJECTS_READ = 'projects.read'
5
+ PROJECTS_WRITE = 'projects.write'
6
+ DEVKEYS_READ = 'devKeys.read'
7
+ DEVKEYS_WRITE = 'devKeys.write'
8
+ ORGANIZATION_KEYS_READ = 'organization.keys.read'
9
+ ORGANIZATION_KEYS_WRITE = 'organization.keys.write'
10
+ DOMAINS_READ = 'domains.read'
11
+ DOMAINS_WRITE = 'domains.write'
12
+ KEYS_READ = 'keys.read'
13
+ KEYS_WRITE = 'keys.write'
14
+ end
15
+ end
16
+ end
@@ -44,8 +44,6 @@ module Appwrite
44
44
  YANDEX = 'yandex'
45
45
  ZOHO = 'zoho'
46
46
  ZOOM = 'zoom'
47
- GITHUBIMAGINE = 'githubImagine'
48
- GOOGLEIMAGINE = 'googleImagine'
49
47
  end
50
48
  end
51
49
  end
@@ -10,6 +10,9 @@ module Appwrite
10
10
  SESSION_LIMIT = 'session-limit'
11
11
  USER_LIMIT = 'user-limit'
12
12
  MEMBERSHIP_PRIVACY = 'membership-privacy'
13
+ DENY_ALIASED_EMAIL = 'deny-aliased-email'
14
+ DENY_DISPOSABLE_EMAIL = 'deny-disposable-email'
15
+ DENY_FREE_EMAIL = 'deny-free-email'
13
16
  end
14
17
  end
15
18
  end
@@ -0,0 +1,12 @@
1
+ module Appwrite
2
+ module Enums
3
+ module Region
4
+ FRA = 'fra'
5
+ NYC = 'nyc'
6
+ SYD = 'syd'
7
+ SFO = 'sfo'
8
+ SGP = 'sgp'
9
+ TOR = 'tor'
10
+ end
11
+ end
12
+ end
@@ -32,9 +32,6 @@ module Appwrite
32
32
  PYTHON_ML_3_11 = 'python-ml-3.11'
33
33
  PYTHON_ML_3_12 = 'python-ml-3.12'
34
34
  PYTHON_ML_3_13 = 'python-ml-3.13'
35
- DENO_1_21 = 'deno-1.21'
36
- DENO_1_24 = 'deno-1.24'
37
- DENO_1_35 = 'deno-1.35'
38
35
  DENO_1_40 = 'deno-1.40'
39
36
  DENO_1_46 = 'deno-1.46'
40
37
  DENO_2_0 = 'deno-2.0'
@@ -53,6 +50,7 @@ module Appwrite
53
50
  DART_3_9 = 'dart-3.9'
54
51
  DART_3_10 = 'dart-3.10'
55
52
  DART_3_11 = 'dart-3.11'
53
+ DART_3_12 = 'dart-3.12'
56
54
  DOTNET_6_0 = 'dotnet-6.0'
57
55
  DOTNET_7_0 = 'dotnet-7.0'
58
56
  DOTNET_8_0 = 'dotnet-8.0'
@@ -93,6 +91,7 @@ module Appwrite
93
91
  FLUTTER_3_35 = 'flutter-3.35'
94
92
  FLUTTER_3_38 = 'flutter-3.38'
95
93
  FLUTTER_3_41 = 'flutter-3.41'
94
+ FLUTTER_3_44 = 'flutter-3.44'
96
95
  end
97
96
  end
98
97
  end
@@ -1,10 +1,10 @@
1
1
  module Appwrite
2
2
  module Enums
3
3
  module StatusCode
4
- MOVED_PERMANENTLY_301 = '301'
5
- FOUND_302 = '302'
6
- TEMPORARY_REDIRECT_307 = '307'
7
- PERMANENT_REDIRECT_308 = '308'
4
+ MOVEDPERMANENTLY = '301'
5
+ FOUND = '302'
6
+ TEMPORARYREDIRECT = '307'
7
+ PERMANENTREDIRECT = '308'
8
8
  end
9
9
  end
10
10
  end
@@ -4,10 +4,10 @@ module Appwrite
4
4
  module Models
5
5
  class ActivityEvent
6
6
  attr_reader :id
7
- attr_reader :user_type
8
- attr_reader :user_id
9
- attr_reader :user_email
10
- attr_reader :user_name
7
+ attr_reader :actor_type
8
+ attr_reader :actor_id
9
+ attr_reader :actor_email
10
+ attr_reader :actor_name
11
11
  attr_reader :resource_parent
12
12
  attr_reader :resource_type
13
13
  attr_reader :resource_id
@@ -38,10 +38,10 @@ module Appwrite
38
38
 
39
39
  def initialize(
40
40
  id:,
41
- user_type:,
42
- user_id:,
43
- user_email:,
44
- user_name:,
41
+ actor_type:,
42
+ actor_id:,
43
+ actor_email:,
44
+ actor_name:,
45
45
  resource_parent:,
46
46
  resource_type:,
47
47
  resource_id:,
@@ -71,10 +71,10 @@ module Appwrite
71
71
  country_name:
72
72
  )
73
73
  @id = id
74
- @user_type = user_type
75
- @user_id = user_id
76
- @user_email = user_email
77
- @user_name = user_name
74
+ @actor_type = actor_type
75
+ @actor_id = actor_id
76
+ @actor_email = actor_email
77
+ @actor_name = actor_name
78
78
  @resource_parent = resource_parent
79
79
  @resource_type = resource_type
80
80
  @resource_id = resource_id
@@ -107,10 +107,10 @@ module Appwrite
107
107
  def self.from(map:)
108
108
  ActivityEvent.new(
109
109
  id: map["$id"],
110
- user_type: map["userType"],
111
- user_id: map["userId"],
112
- user_email: map["userEmail"],
113
- user_name: map["userName"],
110
+ actor_type: map["actorType"],
111
+ actor_id: map["actorId"],
112
+ actor_email: map["actorEmail"],
113
+ actor_name: map["actorName"],
114
114
  resource_parent: map["resourceParent"],
115
115
  resource_type: map["resourceType"],
116
116
  resource_id: map["resourceId"],
@@ -144,10 +144,10 @@ module Appwrite
144
144
  def to_map
145
145
  {
146
146
  "$id": @id,
147
- "userType": @user_type,
148
- "userId": @user_id,
149
- "userEmail": @user_email,
150
- "userName": @user_name,
147
+ "actorType": @actor_type,
148
+ "actorId": @actor_id,
149
+ "actorEmail": @actor_email,
150
+ "actorName": @actor_name,
151
151
  "resourceParent": @resource_parent,
152
152
  "resourceType": @resource_type,
153
153
  "resourceId": @resource_id,
@@ -31,6 +31,8 @@ module Appwrite
31
31
  attr_reader :provider_branch
32
32
  attr_reader :provider_root_directory
33
33
  attr_reader :provider_silent_mode
34
+ attr_reader :provider_branches
35
+ attr_reader :provider_paths
34
36
  attr_reader :build_specification
35
37
  attr_reader :runtime_specification
36
38
 
@@ -63,6 +65,8 @@ module Appwrite
63
65
  provider_branch:,
64
66
  provider_root_directory:,
65
67
  provider_silent_mode:,
68
+ provider_branches:,
69
+ provider_paths:,
66
70
  build_specification:,
67
71
  runtime_specification:
68
72
  )
@@ -94,6 +98,8 @@ module Appwrite
94
98
  @provider_branch = provider_branch
95
99
  @provider_root_directory = provider_root_directory
96
100
  @provider_silent_mode = provider_silent_mode
101
+ @provider_branches = provider_branches
102
+ @provider_paths = provider_paths
97
103
  @build_specification = build_specification
98
104
  @runtime_specification = runtime_specification
99
105
  end
@@ -128,6 +134,8 @@ module Appwrite
128
134
  provider_branch: map["providerBranch"],
129
135
  provider_root_directory: map["providerRootDirectory"],
130
136
  provider_silent_mode: map["providerSilentMode"],
137
+ provider_branches: map["providerBranches"],
138
+ provider_paths: map["providerPaths"],
131
139
  build_specification: map["buildSpecification"],
132
140
  runtime_specification: map["runtimeSpecification"]
133
141
  )
@@ -163,6 +171,8 @@ module Appwrite
163
171
  "providerBranch": @provider_branch,
164
172
  "providerRootDirectory": @provider_root_directory,
165
173
  "providerSilentMode": @provider_silent_mode,
174
+ "providerBranches": @provider_branches,
175
+ "providerPaths": @provider_paths,
166
176
  "buildSpecification": @build_specification,
167
177
  "runtimeSpecification": @runtime_specification
168
178
  }
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class PolicyDenyAliasedEmail
6
+ attr_reader :id
7
+ attr_reader :enabled
8
+
9
+ def initialize(
10
+ id:,
11
+ enabled:
12
+ )
13
+ @id = id
14
+ @enabled = enabled
15
+ end
16
+
17
+ def self.from(map:)
18
+ PolicyDenyAliasedEmail.new(
19
+ id: map["$id"],
20
+ enabled: map["enabled"]
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "$id": @id,
27
+ "enabled": @enabled
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class PolicyDenyDisposableEmail
6
+ attr_reader :id
7
+ attr_reader :enabled
8
+
9
+ def initialize(
10
+ id:,
11
+ enabled:
12
+ )
13
+ @id = id
14
+ @enabled = enabled
15
+ end
16
+
17
+ def self.from(map:)
18
+ PolicyDenyDisposableEmail.new(
19
+ id: map["$id"],
20
+ enabled: map["enabled"]
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "$id": @id,
27
+ "enabled": @enabled
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class PolicyDenyFreeEmail
6
+ attr_reader :id
7
+ attr_reader :enabled
8
+
9
+ def initialize(
10
+ id:,
11
+ enabled:
12
+ )
13
+ @id = id
14
+ @enabled = enabled
15
+ end
16
+
17
+ def self.from(map:)
18
+ PolicyDenyFreeEmail.new(
19
+ id: map["$id"],
20
+ enabled: map["enabled"]
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "$id": @id,
27
+ "enabled": @enabled
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -22,7 +22,7 @@ module Appwrite
22
22
  status: ,
23
23
  source:,
24
24
  expires_at: ,
25
- metadata:
25
+ metadata:
26
26
  )
27
27
  @id = id
28
28
  @created_at = created_at
@@ -45,7 +45,7 @@ module Appwrite
45
45
  status: map["status"],
46
46
  source: map["source"],
47
47
  expires_at: map["expiresAt"],
48
- metadata: map["metadata"] || map
48
+ metadata: map["metadata"]
49
49
  )
50
50
  end
51
51
 
@@ -62,10 +62,6 @@ module Appwrite
62
62
  "metadata": @metadata
63
63
  }
64
64
  end
65
-
66
- def convert_to(from_json)
67
- from_json.call(metadata)
68
- end
69
65
  end
70
66
  end
71
67
  end
@@ -27,10 +27,6 @@ module Appwrite
27
27
  "presences": @presences.map { |it| it.to_map }
28
28
  }
29
29
  end
30
-
31
- def convert_to(from_json)
32
- presences.map { |it| it.convert_to(from_json) }
33
- end
34
30
  end
35
31
  end
36
32
  end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class ProjectList
6
+ attr_reader :total
7
+ attr_reader :projects
8
+
9
+ def initialize(
10
+ total:,
11
+ projects:
12
+ )
13
+ @total = total
14
+ @projects = projects
15
+ end
16
+
17
+ def self.from(map:)
18
+ ProjectList.new(
19
+ total: map["total"],
20
+ projects: map["projects"].map { |it| Project.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "projects": @projects.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end