appwrite 4.1.0 → 7.0.0.pre.RC1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +32 -11
  3. data/lib/appwrite/id.rb +11 -0
  4. data/lib/appwrite/input_file.rb +33 -0
  5. data/lib/appwrite/models/account.rb +82 -0
  6. data/lib/appwrite/models/algo_argon2.rb +37 -0
  7. data/lib/appwrite/models/algo_bcrypt.rb +22 -0
  8. data/lib/appwrite/models/algo_md5.rb +22 -0
  9. data/lib/appwrite/models/algo_phpass.rb +22 -0
  10. data/lib/appwrite/models/algo_scrypt.rb +42 -0
  11. data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
  12. data/lib/appwrite/models/algo_sha.rb +22 -0
  13. data/lib/appwrite/models/attribute_datetime.rb +57 -0
  14. data/lib/appwrite/models/bucket.rb +25 -25
  15. data/lib/appwrite/models/collection.rb +25 -15
  16. data/lib/appwrite/models/database.rb +42 -0
  17. data/lib/appwrite/models/database_list.rb +32 -0
  18. data/lib/appwrite/models/deployment.rb +10 -5
  19. data/lib/appwrite/models/document.rb +15 -10
  20. data/lib/appwrite/models/execution.rb +20 -10
  21. data/lib/appwrite/models/file.rb +15 -15
  22. data/lib/appwrite/models/function.rb +12 -12
  23. data/lib/appwrite/models/index.rb +1 -1
  24. data/lib/appwrite/models/membership.rb +25 -10
  25. data/lib/appwrite/models/session.rb +5 -0
  26. data/lib/appwrite/models/team.rb +10 -5
  27. data/lib/appwrite/models/token.rb +5 -0
  28. data/lib/appwrite/models/user.rb +35 -0
  29. data/lib/appwrite/models/variable.rb +52 -0
  30. data/lib/appwrite/models/variable_list.rb +32 -0
  31. data/lib/appwrite/permission.rb +21 -0
  32. data/lib/appwrite/query.rb +43 -14
  33. data/lib/appwrite/role.rb +31 -0
  34. data/lib/appwrite/services/account.rb +274 -126
  35. data/lib/appwrite/services/avatars.rb +106 -59
  36. data/lib/appwrite/services/databases.rb +1425 -0
  37. data/lib/appwrite/services/functions.rb +381 -176
  38. data/lib/appwrite/services/health.rb +34 -34
  39. data/lib/appwrite/services/locale.rb +25 -7
  40. data/lib/appwrite/services/storage.rb +195 -193
  41. data/lib/appwrite/services/teams.rb +138 -128
  42. data/lib/appwrite/services/users.rb +637 -123
  43. data/lib/appwrite.rb +19 -2
  44. metadata +22 -6
  45. data/lib/appwrite/file.rb +0 -17
  46. data/lib/appwrite/services/database.rb +0 -1049
@@ -4,43 +4,71 @@ module Appwrite
4
4
  module Models
5
5
  class User
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :name
10
+ attr_reader :password
11
+ attr_reader :hash
12
+ attr_reader :hash_options
8
13
  attr_reader :registration
9
14
  attr_reader :status
10
15
  attr_reader :password_update
11
16
  attr_reader :email
17
+ attr_reader :phone
12
18
  attr_reader :email_verification
19
+ attr_reader :phone_verification
13
20
  attr_reader :prefs
14
21
 
15
22
  def initialize(
16
23
  id:,
24
+ created_at:,
25
+ updated_at:,
17
26
  name:,
27
+ password:,
28
+ hash:,
29
+ hash_options:,
18
30
  registration:,
19
31
  status:,
20
32
  password_update:,
21
33
  email:,
34
+ phone:,
22
35
  email_verification:,
36
+ phone_verification:,
23
37
  prefs:
24
38
  )
25
39
  @id = id
40
+ @created_at = created_at
41
+ @updated_at = updated_at
26
42
  @name = name
43
+ @password = password
44
+ @hash = hash
45
+ @hash_options = hash_options
27
46
  @registration = registration
28
47
  @status = status
29
48
  @password_update = password_update
30
49
  @email = email
50
+ @phone = phone
31
51
  @email_verification = email_verification
52
+ @phone_verification = phone_verification
32
53
  @prefs = prefs
33
54
  end
34
55
 
35
56
  def self.from(map:)
36
57
  User.new(
37
58
  id: map["$id"],
59
+ created_at: map["$createdAt"],
60
+ updated_at: map["$updatedAt"],
38
61
  name: map["name"],
62
+ password: map["password"],
63
+ hash: map["hash"],
64
+ hash_options: map["hashOptions"],
39
65
  registration: map["registration"],
40
66
  status: map["status"],
41
67
  password_update: map["passwordUpdate"],
42
68
  email: map["email"],
69
+ phone: map["phone"],
43
70
  email_verification: map["emailVerification"],
71
+ phone_verification: map["phoneVerification"],
44
72
  prefs: Preferences.from(map: map["prefs"])
45
73
  )
46
74
  end
@@ -48,12 +76,19 @@ module Appwrite
48
76
  def to_map
49
77
  {
50
78
  "$id": @id,
79
+ "$createdAt": @created_at,
80
+ "$updatedAt": @updated_at,
51
81
  "name": @name,
82
+ "password": @password,
83
+ "hash": @hash,
84
+ "hashOptions": @hash_options,
52
85
  "registration": @registration,
53
86
  "status": @status,
54
87
  "passwordUpdate": @password_update,
55
88
  "email": @email,
89
+ "phone": @phone,
56
90
  "emailVerification": @email_verification,
91
+ "phoneVerification": @phone_verification,
57
92
  "prefs": @prefs.to_map
58
93
  }
59
94
  end
@@ -0,0 +1,52 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class Variable
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :key
10
+ attr_reader :value
11
+ attr_reader :function_id
12
+
13
+ def initialize(
14
+ id:,
15
+ created_at:,
16
+ updated_at:,
17
+ key:,
18
+ value:,
19
+ function_id:
20
+ )
21
+ @id = id
22
+ @created_at = created_at
23
+ @updated_at = updated_at
24
+ @key = key
25
+ @value = value
26
+ @function_id = function_id
27
+ end
28
+
29
+ def self.from(map:)
30
+ Variable.new(
31
+ id: map["$id"],
32
+ created_at: map["$createdAt"],
33
+ updated_at: map["$updatedAt"],
34
+ key: map["key"],
35
+ value: map["value"],
36
+ function_id: map["functionId"]
37
+ )
38
+ end
39
+
40
+ def to_map
41
+ {
42
+ "$id": @id,
43
+ "$createdAt": @created_at,
44
+ "$updatedAt": @updated_at,
45
+ "key": @key,
46
+ "value": @value,
47
+ "functionId": @function_id
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class VariableList
6
+ attr_reader :total
7
+ attr_reader :variables
8
+
9
+ def initialize(
10
+ total:,
11
+ variables:
12
+ )
13
+ @total = total
14
+ @variables = variables
15
+ end
16
+
17
+ def self.from(map:)
18
+ VariableList.new(
19
+ total: map["total"],
20
+ variables: map["variables"].map { |it| Variable.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "variables": @variables.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ module Appwrite
2
+ class Permission
3
+ class << Permission
4
+ def read(role)
5
+ return "read(\"#{role}\")"
6
+ end
7
+ def write(role)
8
+ return "write(\"#{role}\")"
9
+ end
10
+ def create(role)
11
+ return "create(\"#{role}\")"
12
+ end
13
+ def update(role)
14
+ return "update(\"#{role}\")"
15
+ end
16
+ def delete(role)
17
+ return "delete(\"#{role}\")"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -6,31 +6,60 @@ module Appwrite
6
6
  end
7
7
 
8
8
  def notEqual(attribute, value)
9
- return Query.addQuery(attribute, "notEqual", value)
9
+ return addQuery(attribute, "notEqual", value)
10
10
  end
11
- def lesser(attribute, value)
12
- return Query.addQuery(attribute, "lesser", value)
11
+
12
+ def lessThan(attribute, value)
13
+ return addQuery(attribute, "lessThan", value)
13
14
  end
14
- def lesserEqual(attribute, value)
15
- return Query.addQuery(attribute, "lesserEqual", value)
15
+
16
+ def lessThanEqual(attribute, value)
17
+ return addQuery(attribute, "lessThanEqual", value)
16
18
  end
17
- def greater(attribute, value)
18
- return Query.addQuery(attribute, "greater", value)
19
+
20
+ def greaterThan(attribute, value)
21
+ return addQuery(attribute, "greaterThan", value)
19
22
  end
20
- def greaterEqual(attribute, value)
21
- return Query.addQuery(attribute, "equal", value)
23
+
24
+ def greaterThanEqual(attribute, value)
25
+ return addQuery(attribute, "greaterThanEqual", value)
22
26
  end
27
+
23
28
  def search(attribute, value)
24
- return Query.addQuery(attribute, "search", value)
29
+ return addQuery(attribute, "search", value)
30
+ end
31
+
32
+ def orderAsc(attribute)
33
+ return "orderAsc(\"#{attribute}\")"
34
+ end
35
+
36
+ def orderDesc(attribute)
37
+ return "orderDesc(\"#{attribute}\")"
38
+ end
39
+
40
+ def cursorBefore(id)
41
+ return "cursorBefore(\"#{id}\")"
42
+ end
43
+
44
+ def cursorAfter(id)
45
+ return "cursorAfter(\"#{id}\")"
46
+ end
47
+
48
+ def limit(limit)
49
+ return "limit(#{limit})"
50
+ end
51
+
52
+ def offset(offset)
53
+ return "offset(#{offset})"
25
54
  end
26
55
 
27
56
  private
28
57
 
29
- def addQuery(attribute, oper, value)
58
+ def addQuery(attribute, method, value)
30
59
  if value.is_a?(Array)
31
- "#{attribute}.#{oper}.(#{value.map {|item| parseValues(item)}.join(',')})"
60
+ "#{method}(\"#{attribute}\", [#{value.map {|item| parseValues(item)}.join(',')}])"
32
61
  else
33
- return "#{attribute}.#{oper}.(#{parseValues(value)})"
62
+ return "#{method}(\"#{attribute}\", [#{parseValues(value)}])"
34
63
  end
35
64
  end
36
65
 
@@ -39,4 +68,4 @@ module Appwrite
39
68
  end
40
69
  end
41
70
  end
42
- end
71
+ end
@@ -0,0 +1,31 @@
1
+ module Appwrite
2
+ class Role
3
+ def self.any
4
+ 'any'
5
+ end
6
+
7
+ def self.user(id)
8
+ "user:#{id}"
9
+ end
10
+
11
+ def self.users
12
+ 'users'
13
+ end
14
+
15
+ def self.guests
16
+ 'guests'
17
+ end
18
+
19
+ def self.team(id, role = "")
20
+ if(role.empty?)
21
+ "team:#{id}"
22
+ else
23
+ "team:#{id}/#{role}"
24
+ end
25
+ end
26
+
27
+ def self.status(status)
28
+ "status:#{status}"
29
+ end
30
+ end
31
+ end