Skip to content

Commit c3f4af1

Browse files
authored
Merge pull request #45 from appwrite/dev
feat: Ruby SDK update for version 19.1.0
2 parents 0cd6ac2 + d4b6112 commit c3f4af1

File tree

9 files changed

+155
-34
lines changed

9 files changed

+155
-34
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 19.1.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 16.1.0
49

510
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service

appwrite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |spec|
22

33
spec.name = 'appwrite'
4-
spec.version = '19.0.0'
4+
spec.version = '19.1.0'
55
spec.license = 'BSD-3-Clause'
66
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
77
spec.author = 'Appwrite Team'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'appwrite'
2+
3+
include Appwrite
4+
5+
client = Client.new
6+
.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
7+
.set_project('<YOUR_PROJECT_ID>') # Your project ID
8+
.set_session('') # The user session to authenticate with
9+
10+
account = Account.new(client)
11+
12+
result = account.create_email_verification(
13+
url: 'https://example.com'
14+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'appwrite'
2+
3+
include Appwrite
4+
5+
client = Client.new
6+
.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
7+
.set_project('<YOUR_PROJECT_ID>') # Your project ID
8+
.set_session('') # The user session to authenticate with
9+
10+
account = Account.new(client)
11+
12+
result = account.update_email_verification(
13+
user_id: '<USER_ID>',
14+
secret: '<SECRET>'
15+
)

lib/appwrite/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize
1515
'x-sdk-name'=> 'Ruby',
1616
'x-sdk-platform'=> 'server',
1717
'x-sdk-language'=> 'ruby',
18-
'x-sdk-version'=> '19.0.0',
18+
'x-sdk-version'=> '19.1.0',
1919
'X-Appwrite-Response-Format' => '1.8.0'
2020
}
2121
@endpoint = 'https://cloud.appwrite.io/v1'

lib/appwrite/services/account.rb

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,52 @@ def create_phone_token(user_id:, phone:)
13081308
)
13091309
end
13101310

1311+
# Use this endpoint to send a verification message to your user email address
1312+
# to confirm they are the valid owners of that address. Both the **userId**
1313+
# and **secret** arguments will be passed as query parameters to the URL you
1314+
# have provided to be attached to the verification email. The provided URL
1315+
# should redirect the user back to your app and allow you to complete the
1316+
# verification process by verifying both the **userId** and **secret**
1317+
# parameters. Learn more about how to [complete the verification
1318+
# process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1319+
# The verification link sent to the user's email address is valid for 7 days.
1320+
#
1321+
# Please note that in order to avoid a [Redirect
1322+
# Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1323+
# the only valid redirect URLs are the ones from domains you have set when
1324+
# adding your platforms in the console interface.
1325+
#
1326+
#
1327+
# @param [String] url URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
1328+
#
1329+
# @return [Token]
1330+
def create_email_verification(url:)
1331+
api_path = '/account/verifications/email'
1332+
1333+
if url.nil?
1334+
raise Appwrite::Exception.new('Missing required parameter: "url"')
1335+
end
1336+
1337+
api_params = {
1338+
url: url,
1339+
}
1340+
1341+
api_headers = {
1342+
"content-type": 'application/json',
1343+
}
1344+
1345+
@client.call(
1346+
method: 'POST',
1347+
path: api_path,
1348+
headers: api_headers,
1349+
params: api_params,
1350+
response_type: Models::Token
1351+
)
1352+
end
1353+
1354+
#
1355+
# @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.
1356+
#
13111357
# Use this endpoint to send a verification message to your user email address
13121358
# to confirm they are the valid owners of that address. Both the **userId**
13131359
# and **secret** arguments will be passed as query parameters to the URL you
@@ -1328,7 +1374,7 @@ def create_phone_token(user_id:, phone:)
13281374
#
13291375
# @return [Token]
13301376
def create_verification(url:)
1331-
api_path = '/account/verification'
1377+
api_path = '/account/verifications/email'
13321378

13331379
if url.nil?
13341380
raise Appwrite::Exception.new('Missing required parameter: "url"')
@@ -1351,6 +1397,47 @@ def create_verification(url:)
13511397
)
13521398
end
13531399

1400+
# Use this endpoint to complete the user email verification process. Use both
1401+
# the **userId** and **secret** parameters that were attached to your app URL
1402+
# to verify the user email ownership. If confirmed this route will return a
1403+
# 200 status code.
1404+
#
1405+
# @param [String] user_id User ID.
1406+
# @param [String] secret Valid verification token.
1407+
#
1408+
# @return [Token]
1409+
def update_email_verification(user_id:, secret:)
1410+
api_path = '/account/verifications/email'
1411+
1412+
if user_id.nil?
1413+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
1414+
end
1415+
1416+
if secret.nil?
1417+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
1418+
end
1419+
1420+
api_params = {
1421+
userId: user_id,
1422+
secret: secret,
1423+
}
1424+
1425+
api_headers = {
1426+
"content-type": 'application/json',
1427+
}
1428+
1429+
@client.call(
1430+
method: 'PUT',
1431+
path: api_path,
1432+
headers: api_headers,
1433+
params: api_params,
1434+
response_type: Models::Token
1435+
)
1436+
end
1437+
1438+
#
1439+
# @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.
1440+
#
13541441
# Use this endpoint to complete the user email verification process. Use both
13551442
# the **userId** and **secret** parameters that were attached to your app URL
13561443
# to verify the user email ownership. If confirmed this route will return a
@@ -1361,7 +1448,7 @@ def create_verification(url:)
13611448
#
13621449
# @return [Token]
13631450
def update_verification(user_id:, secret:)
1364-
api_path = '/account/verification'
1451+
api_path = '/account/verifications/email'
13651452

13661453
if user_id.nil?
13671454
raise Appwrite::Exception.new('Missing required parameter: "userId"')
@@ -1401,7 +1488,7 @@ def update_verification(user_id:, secret:)
14011488
#
14021489
# @return [Token]
14031490
def create_phone_verification()
1404-
api_path = '/account/verification/phone'
1491+
api_path = '/account/verifications/phone'
14051492

14061493
api_params = {
14071494
}
@@ -1429,7 +1516,7 @@ def create_phone_verification()
14291516
#
14301517
# @return [Token]
14311518
def update_phone_verification(user_id:, secret:)
1432-
api_path = '/account/verification/phone'
1519+
api_path = '/account/verifications/phone'
14331520

14341521
if user_id.nil?
14351522
raise Appwrite::Exception.new('Missing required parameter: "userId"')

lib/appwrite/services/functions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def create_duplicate_deployment(function_id:, deployment_id:, build_id: nil)
447447
# Create a deployment based on a template.
448448
#
449449
# Use this endpoint with combination of
450-
# [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to
450+
# [listTemplates](https://appwrite.io/docs/products/functions/templates) to
451451
# find the template details.
452452
#
453453
# @param [String] function_id Function ID.

lib/appwrite/services/sites.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ def create_duplicate_deployment(site_id:, deployment_id:)
446446
# Create a deployment based on a template.
447447
#
448448
# Use this endpoint with combination of
449-
# [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to
450-
# find the template details.
449+
# [listTemplates](https://appwrite.io/docs/products/sites/templates) to find
450+
# the template details.
451451
#
452452
# @param [String] site_id Site ID.
453453
# @param [String] repository Repository name of the template.

0 commit comments

Comments
 (0)