appwrite 4.0.0 → 6.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.
@@ -4,10 +4,13 @@ module Appwrite
4
4
  module Models
5
5
  class Membership
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :user_id
10
+ attr_reader :user_name
11
+ attr_reader :user_email
8
12
  attr_reader :team_id
9
- attr_reader :name
10
- attr_reader :email
13
+ attr_reader :team_name
11
14
  attr_reader :invited
12
15
  attr_reader :joined
13
16
  attr_reader :confirm
@@ -15,20 +18,26 @@ module Appwrite
15
18
 
16
19
  def initialize(
17
20
  id:,
21
+ created_at:,
22
+ updated_at:,
18
23
  user_id:,
24
+ user_name:,
25
+ user_email:,
19
26
  team_id:,
20
- name:,
21
- email:,
27
+ team_name:,
22
28
  invited:,
23
29
  joined:,
24
30
  confirm:,
25
31
  roles:
26
32
  )
27
33
  @id = id
34
+ @created_at = created_at
35
+ @updated_at = updated_at
28
36
  @user_id = user_id
37
+ @user_name = user_name
38
+ @user_email = user_email
29
39
  @team_id = team_id
30
- @name = name
31
- @email = email
40
+ @team_name = team_name
32
41
  @invited = invited
33
42
  @joined = joined
34
43
  @confirm = confirm
@@ -38,10 +47,13 @@ module Appwrite
38
47
  def self.from(map:)
39
48
  Membership.new(
40
49
  id: map["$id"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
41
52
  user_id: map["userId"],
53
+ user_name: map["userName"],
54
+ user_email: map["userEmail"],
42
55
  team_id: map["teamId"],
43
- name: map["name"],
44
- email: map["email"],
56
+ team_name: map["teamName"],
45
57
  invited: map["invited"],
46
58
  joined: map["joined"],
47
59
  confirm: map["confirm"],
@@ -52,10 +64,13 @@ module Appwrite
52
64
  def to_map
53
65
  {
54
66
  "$id": @id,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
55
69
  "userId": @user_id,
70
+ "userName": @user_name,
71
+ "userEmail": @user_email,
56
72
  "teamId": @team_id,
57
- "name": @name,
58
- "email": @email,
73
+ "teamName": @team_name,
59
74
  "invited": @invited,
60
75
  "joined": @joined,
61
76
  "confirm": @confirm,
@@ -4,6 +4,7 @@ module Appwrite
4
4
  module Models
5
5
  class Session
6
6
  attr_reader :id
7
+ attr_reader :created_at
7
8
  attr_reader :user_id
8
9
  attr_reader :expire
9
10
  attr_reader :provider
@@ -30,6 +31,7 @@ module Appwrite
30
31
 
31
32
  def initialize(
32
33
  id:,
34
+ created_at:,
33
35
  user_id:,
34
36
  expire:,
35
37
  provider:,
@@ -55,6 +57,7 @@ module Appwrite
55
57
  current:
56
58
  )
57
59
  @id = id
60
+ @created_at = created_at
58
61
  @user_id = user_id
59
62
  @expire = expire
60
63
  @provider = provider
@@ -83,6 +86,7 @@ module Appwrite
83
86
  def self.from(map:)
84
87
  Session.new(
85
88
  id: map["$id"],
89
+ created_at: map["$createdAt"],
86
90
  user_id: map["userId"],
87
91
  expire: map["expire"],
88
92
  provider: map["provider"],
@@ -112,6 +116,7 @@ module Appwrite
112
116
  def to_map
113
117
  {
114
118
  "$id": @id,
119
+ "$createdAt": @created_at,
115
120
  "userId": @user_id,
116
121
  "expire": @expire,
117
122
  "provider": @provider,
@@ -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
  #
@@ -26,32 +27,6 @@ module Appwrite
26
27
  )
27
28
  end
28
29
 
29
- # Delete a currently logged in user account. Behind the scene, the user
30
- # record is not deleted but permanently blocked from any access. This is done
31
- # to avoid deleted accounts being overtaken by new users with the same email
32
- # address. Any user-related resources like documents or storage files should
33
- # be deleted separately.
34
- #
35
- #
36
- # @return []
37
- def delete()
38
- path = '/account'
39
-
40
- params = {
41
- }
42
-
43
- headers = {
44
- "content-type": 'application/json',
45
- }
46
-
47
- @client.call(
48
- method: 'DELETE',
49
- path: path,
50
- headers: headers,
51
- params: params,
52
- )
53
- end
54
-
55
30
  # Update currently logged in user account email address. After changing user
56
31
  # address, the user confirmation status will get reset. A new confirmation
57
32
  # email is not sent automatically however you can use the send confirmation
@@ -153,7 +128,7 @@ module Appwrite
153
128
 
154
129
  # Update currently logged in user password. For validation, user is required
155
130
  # to pass in the new password, and the old password. For users created with
156
- # OAuth and Team Invites, oldPassword is optional.
131
+ # OAuth, Team Invites and Magic URL, oldPassword is optional.
157
132
  #
158
133
  # @param [string] password New user password. Must be at least 8 chars.
159
134
  # @param [string] old_password Current user password. Must be at least 8 chars.
@@ -184,6 +159,44 @@ module Appwrite
184
159
  )
185
160
  end
186
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
+
187
200
  # Get currently logged in user preferences as a key-value object.
188
201
  #
189
202
  #
@@ -412,7 +425,9 @@ module Appwrite
412
425
  )
413
426
  end
414
427
 
415
- #
428
+ # Access tokens have limited lifespan and expire to mitigate security risks.
429
+ # If session was created using an OAuth provider, this route can be used to
430
+ # "refresh" the access token.
416
431
  #
417
432
  # @param [string] session_id Session ID. Use the string &#039;current&#039; to update the current device session.
418
433
  #
@@ -472,6 +487,31 @@ module Appwrite
472
487
  )
473
488
  end
474
489
 
490
+ # Block the currently logged in user account. Behind the scene, the user
491
+ # record is not deleted but permanently blocked from any access. To
492
+ # completely delete a user, use the Users API instead.
493
+ #
494
+ #
495
+ # @return [User]
496
+ def update_status()
497
+ path = '/account/status'
498
+
499
+ params = {
500
+ }
501
+
502
+ headers = {
503
+ "content-type": 'application/json',
504
+ }
505
+
506
+ @client.call(
507
+ method: 'PATCH',
508
+ path: path,
509
+ headers: headers,
510
+ params: params,
511
+ response_type: Models::User
512
+ )
513
+ end
514
+
475
515
  # Use this endpoint to send a verification message to your user email address
476
516
  # to confirm they are the valid owners of that address. Both the **userId**
477
517
  # and **secret** arguments will be passed as query parameters to the URL you
@@ -479,8 +519,8 @@ module Appwrite
479
519
  # should redirect the user back to your app and allow you to complete the
480
520
  # verification process by verifying both the **userId** and **secret**
481
521
  # parameters. Learn more about how to [complete the verification
482
- # process](/docs/client/account#accountUpdateVerification). The verification
483
- # 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.
484
524
  #
485
525
  # Please note that in order to avoid a [Redirect
486
526
  # Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
@@ -553,5 +593,72 @@ module Appwrite
553
593
  )
554
594
  end
555
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
+
556
663
  end
557
664
  end
@@ -3,10 +3,16 @@
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
- # 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.
8
+ # The code argument receives the browser code as it appears in your user [GET
9
+ # /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
10
+ # width, height and quality arguments to change the output settings.
11
+ #
12
+ # When one dimension is specified and the other is 0, the image is scaled
13
+ # with preserved aspect ratio. If both dimensions are 0, the API provides an
14
+ # image at source quality. If dimensions are not specified, the default size
15
+ # of image returned is 100x100px.
10
16
  #
11
17
  # @param [string] code Browser Code.
12
18
  # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
@@ -43,6 +49,12 @@ module Appwrite
43
49
  # The credit card endpoint will return you the icon of the credit card
44
50
  # provider you need. Use width, height and quality arguments to change the
45
51
  # output settings.
52
+ #
53
+ # When one dimension is specified and the other is 0, the image is scaled
54
+ # with preserved aspect ratio. If both dimensions are 0, the API provides an
55
+ # image at source quality. If dimensions are not specified, the default size
56
+ # of image returned is 100x100px.
57
+ #
46
58
  #
47
59
  # @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
60
  # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
@@ -109,6 +121,12 @@ module Appwrite
109
121
  # You can use this endpoint to show different country flags icons to your
110
122
  # users. The code argument receives the 2 letter country code. Use width,
111
123
  # height and quality arguments to change the output settings.
124
+ #
125
+ # When one dimension is specified and the other is 0, the image is scaled
126
+ # with preserved aspect ratio. If both dimensions are 0, the API provides an
127
+ # image at source quality. If dimensions are not specified, the default size
128
+ # of image returned is 100x100px.
129
+ #
112
130
  #
113
131
  # @param [string] code Country Code. ISO Alpha-2 country code format.
114
132
  # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
@@ -146,10 +164,16 @@ module Appwrite
146
164
  # you want. This endpoint is very useful if you need to crop and display
147
165
  # remote images in your app or in case you want to make sure a 3rd party
148
166
  # image is properly served using a TLS protocol.
167
+ #
168
+ # When one dimension is specified and the other is 0, the image is scaled
169
+ # with preserved aspect ratio. If both dimensions are 0, the API provides an
170
+ # image at source quality. If dimensions are not specified, the default size
171
+ # of image returned is 400x400px.
172
+ #
149
173
  #
150
174
  # @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.
175
+ # @param [number] width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.
176
+ # @param [number] height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.
153
177
  #
154
178
  # @return []
155
179
  def get_image(url:, width: nil, height: nil)
@@ -187,6 +211,12 @@ module Appwrite
187
211
  # default, a random theme will be selected. The random theme will persist for
188
212
  # the user's initials when reloading the same theme will always return for
189
213
  # the same initials.
214
+ #
215
+ # When one dimension is specified and the other is 0, the image is scaled
216
+ # with preserved aspect ratio. If both dimensions are 0, the API provides an
217
+ # image at source quality. If dimensions are not specified, the default size
218
+ # of image returned is 100x100px.
219
+ #
190
220
  #
191
221
  # @param [string] name Full Name. When empty, current user name or email will be used. Max length: 128 chars.
192
222
  # @param [number] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
@@ -220,9 +250,10 @@ module Appwrite
220
250
 
221
251
  # Converts a given plain text to a QR code image. You can use the query
222
252
  # parameters to change the size and style of the resulting image.
253
+ #
223
254
  #
224
255
  # @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.
256
+ # @param [number] size QR code size. Pass an integer between 1 to 1000. Defaults to 400.
226
257
  # @param [number] margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
227
258
  # @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
259
  #