appwrite 5.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,27 +4,31 @@ module Appwrite
4
4
  module Models
5
5
  class Team
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :name
8
- attr_reader :date_created
9
10
  attr_reader :total
10
11
 
11
12
  def initialize(
12
13
  id:,
14
+ created_at:,
15
+ updated_at:,
13
16
  name:,
14
- date_created:,
15
17
  total:
16
18
  )
17
19
  @id = id
20
+ @created_at = created_at
21
+ @updated_at = updated_at
18
22
  @name = name
19
- @date_created = date_created
20
23
  @total = total
21
24
  end
22
25
 
23
26
  def self.from(map:)
24
27
  Team.new(
25
28
  id: map["$id"],
29
+ created_at: map["$createdAt"],
30
+ updated_at: map["$updatedAt"],
26
31
  name: map["name"],
27
- date_created: map["dateCreated"],
28
32
  total: map["total"]
29
33
  )
30
34
  end
@@ -32,8 +36,9 @@ module Appwrite
32
36
  def to_map
33
37
  {
34
38
  "$id": @id,
39
+ "$createdAt": @created_at,
40
+ "$updatedAt": @updated_at,
35
41
  "name": @name,
36
- "dateCreated": @date_created,
37
42
  "total": @total
38
43
  }
39
44
  end
@@ -4,17 +4,20 @@ module Appwrite
4
4
  module Models
5
5
  class Token
6
6
  attr_reader :id
7
+ attr_reader :created_at
7
8
  attr_reader :user_id
8
9
  attr_reader :secret
9
10
  attr_reader :expire
10
11
 
11
12
  def initialize(
12
13
  id:,
14
+ created_at:,
13
15
  user_id:,
14
16
  secret:,
15
17
  expire:
16
18
  )
17
19
  @id = id
20
+ @created_at = created_at
18
21
  @user_id = user_id
19
22
  @secret = secret
20
23
  @expire = expire
@@ -23,6 +26,7 @@ module Appwrite
23
26
  def self.from(map:)
24
27
  Token.new(
25
28
  id: map["$id"],
29
+ created_at: map["$createdAt"],
26
30
  user_id: map["userId"],
27
31
  secret: map["secret"],
28
32
  expire: map["expire"]
@@ -32,6 +36,7 @@ module Appwrite
32
36
  def to_map
33
37
  {
34
38
  "$id": @id,
39
+ "$createdAt": @created_at,
35
40
  "userId": @user_id,
36
41
  "secret": @secret,
37
42
  "expire": @expire
@@ -4,43 +4,59 @@ 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
8
10
  attr_reader :registration
9
11
  attr_reader :status
10
12
  attr_reader :password_update
11
13
  attr_reader :email
14
+ attr_reader :phone
12
15
  attr_reader :email_verification
16
+ attr_reader :phone_verification
13
17
  attr_reader :prefs
14
18
 
15
19
  def initialize(
16
20
  id:,
21
+ created_at:,
22
+ updated_at:,
17
23
  name:,
18
24
  registration:,
19
25
  status:,
20
26
  password_update:,
21
27
  email:,
28
+ phone:,
22
29
  email_verification:,
30
+ phone_verification:,
23
31
  prefs:
24
32
  )
25
33
  @id = id
34
+ @created_at = created_at
35
+ @updated_at = updated_at
26
36
  @name = name
27
37
  @registration = registration
28
38
  @status = status
29
39
  @password_update = password_update
30
40
  @email = email
41
+ @phone = phone
31
42
  @email_verification = email_verification
43
+ @phone_verification = phone_verification
32
44
  @prefs = prefs
33
45
  end
34
46
 
35
47
  def self.from(map:)
36
48
  User.new(
37
49
  id: map["$id"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
38
52
  name: map["name"],
39
53
  registration: map["registration"],
40
54
  status: map["status"],
41
55
  password_update: map["passwordUpdate"],
42
56
  email: map["email"],
57
+ phone: map["phone"],
43
58
  email_verification: map["emailVerification"],
59
+ phone_verification: map["phoneVerification"],
44
60
  prefs: Preferences.from(map: map["prefs"])
45
61
  )
46
62
  end
@@ -48,12 +64,16 @@ module Appwrite
48
64
  def to_map
49
65
  {
50
66
  "$id": @id,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
51
69
  "name": @name,
52
70
  "registration": @registration,
53
71
  "status": @status,
54
72
  "passwordUpdate": @password_update,
55
73
  "email": @email,
74
+ "phone": @phone,
56
75
  "emailVerification": @email_verification,
76
+ "phoneVerification": @phone_verification,
57
77
  "prefs": @prefs.to_map
58
78
  }
59
79
  end
@@ -3,6 +3,7 @@
3
3
  module Appwrite
4
4
  class Account < Service
5
5
 
6
+
6
7
  # Get currently logged in user data as JSON object.
7
8
  #
8
9
  #
@@ -158,6 +159,44 @@ module Appwrite
158
159
  )
159
160
  end
160
161
 
162
+ # Update currently logged in user account phone number. After changing phone
163
+ # number, the user confirmation status will get reset. A new confirmation SMS
164
+ # is not sent automatically however you can use the phone confirmation
165
+ # endpoint again to send the confirmation SMS.
166
+ #
167
+ # @param [string] number Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
168
+ # @param [string] password User password. Must be at least 8 chars.
169
+ #
170
+ # @return [User]
171
+ def update_phone(number:, password:)
172
+ if number.nil?
173
+ raise Appwrite::Exception.new('Missing required parameter: "number"')
174
+ end
175
+
176
+ if password.nil?
177
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
178
+ end
179
+
180
+ path = '/account/phone'
181
+
182
+ params = {
183
+ number: number,
184
+ password: password,
185
+ }
186
+
187
+ headers = {
188
+ "content-type": 'application/json',
189
+ }
190
+
191
+ @client.call(
192
+ method: 'PATCH',
193
+ path: path,
194
+ headers: headers,
195
+ params: params,
196
+ response_type: Models::User
197
+ )
198
+ end
199
+
161
200
  # Get currently logged in user preferences as a key-value object.
162
201
  #
163
202
  #
@@ -480,8 +519,8 @@ module Appwrite
480
519
  # should redirect the user back to your app and allow you to complete the
481
520
  # verification process by verifying both the **userId** and **secret**
482
521
  # parameters. Learn more about how to [complete the verification
483
- # process](/docs/client/account#accountUpdateVerification). The verification
484
- # link sent to the user's email address is valid for 7 days.
522
+ # process](/docs/client/account#accountUpdateEmailVerification). The
523
+ # verification link sent to the user's email address is valid for 7 days.
485
524
  #
486
525
  # Please note that in order to avoid a [Redirect
487
526
  # Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
@@ -554,5 +593,72 @@ module Appwrite
554
593
  )
555
594
  end
556
595
 
596
+ # Use this endpoint to send a verification message to your user's phone
597
+ # number to confirm they are the valid owners of that address. The provided
598
+ # secret should allow you to complete the verification process by verifying
599
+ # both the **userId** and **secret** parameters. Learn more about how to
600
+ # [complete the verification
601
+ # process](/docs/client/account#accountUpdatePhoneVerification). The
602
+ # verification link sent to the user's phone number is valid for 15 minutes.
603
+ #
604
+ #
605
+ # @return [Token]
606
+ def create_phone_verification()
607
+ path = '/account/verification/phone'
608
+
609
+ params = {
610
+ }
611
+
612
+ headers = {
613
+ "content-type": 'application/json',
614
+ }
615
+
616
+ @client.call(
617
+ method: 'POST',
618
+ path: path,
619
+ headers: headers,
620
+ params: params,
621
+ response_type: Models::Token
622
+ )
623
+ end
624
+
625
+ # Use this endpoint to complete the user phone verification process. Use the
626
+ # **userId** and **secret** that were sent to your user's phone number to
627
+ # verify the user email ownership. If confirmed this route will return a 200
628
+ # status code.
629
+ #
630
+ # @param [string] user_id User ID.
631
+ # @param [string] secret Valid verification token.
632
+ #
633
+ # @return [Token]
634
+ def update_phone_verification(user_id:, secret:)
635
+ if user_id.nil?
636
+ raise Appwrite::Exception.new('Missing required parameter: "userId"')
637
+ end
638
+
639
+ if secret.nil?
640
+ raise Appwrite::Exception.new('Missing required parameter: "secret"')
641
+ end
642
+
643
+ path = '/account/verification/phone'
644
+
645
+ params = {
646
+ userId: user_id,
647
+ secret: secret,
648
+ }
649
+
650
+ headers = {
651
+ "content-type": 'application/json',
652
+ }
653
+
654
+ @client.call(
655
+ method: 'PUT',
656
+ path: path,
657
+ headers: headers,
658
+ params: params,
659
+ response_type: Models::Token
660
+ )
661
+ end
662
+
557
663
  end
558
664
  end
@@ -3,6 +3,7 @@
3
3
  module Appwrite
4
4
  class Avatars < Service
5
5
 
6
+
6
7
  # You can use this endpoint to show different browser icons to your users.
7
8
  # The code argument receives the browser code as it appears in your user [GET
8
9
  # /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use