Skip to content

Commit 57e0059

Browse files
authored
Merge pull request #74 from appwrite/dev
feat: .NET SDK update for version 0.20.0
2 parents b8a7189 + 1d91fc3 commit 57e0059

File tree

10 files changed

+134
-18
lines changed

10 files changed

+134
-18
lines changed

Appwrite/Appwrite.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
44
<PackageId>Appwrite</PackageId>
5-
<Version>0.19.0</Version>
5+
<Version>0.20.0</Version>
66
<Authors>Appwrite Team</Authors>
77
<Company>Appwrite Team</Company>
88
<Description>

Appwrite/Client.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public Client(
6969
_headers = new Dictionary<string, string>()
7070
{
7171
{ "content-type", "application/json" },
72-
{ "user-agent" , $"AppwriteDotNetSDK/0.19.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
72+
{ "user-agent" , $"AppwriteDotNetSDK/0.20.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
7373
{ "x-sdk-name", ".NET" },
7474
{ "x-sdk-platform", "server" },
7575
{ "x-sdk-language", "dotnet" },
76-
{ "x-sdk-version", "0.19.0"},
76+
{ "x-sdk-version", "0.20.0"},
7777
{ "X-Appwrite-Response-Format", "1.8.0" }
7878
};
7979

Appwrite/Services/Account.cs

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,9 +1673,55 @@ static Models.Token Convert(Dictionary<string, object> it) =>
16731673
///
16741674
/// </para>
16751675
/// </summary>
1676+
public Task<Models.Token> CreateEmailVerification(string url)
1677+
{
1678+
var apiPath = "/account/verifications/email";
1679+
1680+
var apiParameters = new Dictionary<string, object?>()
1681+
{
1682+
{ "url", url }
1683+
};
1684+
1685+
var apiHeaders = new Dictionary<string, string>()
1686+
{
1687+
{ "content-type", "application/json" }
1688+
};
1689+
1690+
1691+
static Models.Token Convert(Dictionary<string, object> it) =>
1692+
Models.Token.From(map: it);
1693+
1694+
return _client.Call<Models.Token>(
1695+
method: "POST",
1696+
path: apiPath,
1697+
headers: apiHeaders,
1698+
parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!,
1699+
convert: Convert);
1700+
1701+
}
1702+
1703+
/// <para>
1704+
/// Use this endpoint to send a verification message to your user email address
1705+
/// to confirm they are the valid owners of that address. Both the **userId**
1706+
/// and **secret** arguments will be passed as query parameters to the URL you
1707+
/// have provided to be attached to the verification email. The provided URL
1708+
/// should redirect the user back to your app and allow you to complete the
1709+
/// verification process by verifying both the **userId** and **secret**
1710+
/// parameters. Learn more about how to [complete the verification
1711+
/// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1712+
/// The verification link sent to the user's email address is valid for 7 days.
1713+
///
1714+
/// Please note that in order to avoid a [Redirect
1715+
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1716+
/// the only valid redirect URLs are the ones from domains you have set when
1717+
/// adding your platforms in the console interface.
1718+
///
1719+
/// </para>
1720+
/// </summary>
1721+
[Obsolete("This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.")]
16761722
public Task<Models.Token> CreateVerification(string url)
16771723
{
1678-
var apiPath = "/account/verification";
1724+
var apiPath = "/account/verifications/email";
16791725

16801726
var apiParameters = new Dictionary<string, object?>()
16811727
{
@@ -1707,9 +1753,45 @@ static Models.Token Convert(Dictionary<string, object> it) =>
17071753
/// 200 status code.
17081754
/// </para>
17091755
/// </summary>
1756+
public Task<Models.Token> UpdateEmailVerification(string userId, string secret)
1757+
{
1758+
var apiPath = "/account/verifications/email";
1759+
1760+
var apiParameters = new Dictionary<string, object?>()
1761+
{
1762+
{ "userId", userId },
1763+
{ "secret", secret }
1764+
};
1765+
1766+
var apiHeaders = new Dictionary<string, string>()
1767+
{
1768+
{ "content-type", "application/json" }
1769+
};
1770+
1771+
1772+
static Models.Token Convert(Dictionary<string, object> it) =>
1773+
Models.Token.From(map: it);
1774+
1775+
return _client.Call<Models.Token>(
1776+
method: "PUT",
1777+
path: apiPath,
1778+
headers: apiHeaders,
1779+
parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!,
1780+
convert: Convert);
1781+
1782+
}
1783+
1784+
/// <para>
1785+
/// Use this endpoint to complete the user email verification process. Use both
1786+
/// the **userId** and **secret** parameters that were attached to your app URL
1787+
/// to verify the user email ownership. If confirmed this route will return a
1788+
/// 200 status code.
1789+
/// </para>
1790+
/// </summary>
1791+
[Obsolete("This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.")]
17101792
public Task<Models.Token> UpdateVerification(string userId, string secret)
17111793
{
1712-
var apiPath = "/account/verification";
1794+
var apiPath = "/account/verifications/email";
17131795

17141796
var apiParameters = new Dictionary<string, object?>()
17151797
{
@@ -1748,7 +1830,7 @@ static Models.Token Convert(Dictionary<string, object> it) =>
17481830
/// </summary>
17491831
public Task<Models.Token> CreatePhoneVerification()
17501832
{
1751-
var apiPath = "/account/verification/phone";
1833+
var apiPath = "/account/verifications/phone";
17521834

17531835
var apiParameters = new Dictionary<string, object?>()
17541836
{
@@ -1781,7 +1863,7 @@ static Models.Token Convert(Dictionary<string, object> it) =>
17811863
/// </summary>
17821864
public Task<Models.Token> UpdatePhoneVerification(string userId, string secret)
17831865
{
1784-
var apiPath = "/account/verification/phone";
1866+
var apiPath = "/account/verifications/phone";
17851867

17861868
var apiParameters = new Dictionary<string, object?>()
17871869
{

Appwrite/Services/Functions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static Models.Deployment Convert(Dictionary<string, object> it) =>
417417
/// Create a deployment based on a template.
418418
///
419419
/// Use this endpoint with combination of
420-
/// [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to
420+
/// [listTemplates](https://appwrite.io/docs/products/functions/templates) to
421421
/// find the template details.
422422
/// </para>
423423
/// </summary>

Appwrite/Services/Sites.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ static Models.Deployment Convert(Dictionary<string, object> it) =>
408408
/// Create a deployment based on a template.
409409
///
410410
/// Use this endpoint with combination of
411-
/// [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to
412-
/// find the template details.
411+
/// [listTemplates](https://appwrite.io/docs/products/sites/templates) to find
412+
/// the template details.
413413
/// </para>
414414
/// </summary>
415415
public Task<Models.Deployment> CreateTemplateDeployment(string siteId, string repository, string owner, string rootDirectory, string version, bool? activate = null)

Appwrite/Services/TablesDb.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static Models.TableList Convert(Dictionary<string, object> it) =>
209209
/// <para>
210210
/// Create a new Table. Before using this route, you should create a new
211211
/// database resource using either a [server
212-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
212+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
213213
/// API or directly from your database console.
214214
/// </para>
215215
/// </summary>
@@ -1583,7 +1583,7 @@ static Models.RowList Convert(Dictionary<string, object> it) =>
15831583
/// <para>
15841584
/// Create a new Row. Before using this route, you should create a new table
15851585
/// resource using either a [server
1586-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1586+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
15871587
/// API or directly from your database console.
15881588
/// </para>
15891589
/// </summary>
@@ -1621,7 +1621,7 @@ static Models.Row Convert(Dictionary<string, object> it) =>
16211621
/// <para>
16221622
/// Create new Rows. Before using this route, you should create a new table
16231623
/// resource using either a [server
1624-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1624+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
16251625
/// API or directly from your database console.
16261626
/// </para>
16271627
/// </summary>
@@ -1657,7 +1657,7 @@ static Models.RowList Convert(Dictionary<string, object> it) =>
16571657
/// <para>
16581658
/// Create or update Rows. Before using this route, you should create a new
16591659
/// table resource using either a [server
1660-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1660+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
16611661
/// API or directly from your database console.
16621662
///
16631663
/// </para>
@@ -1797,7 +1797,7 @@ static Models.Row Convert(Dictionary<string, object> it) =>
17971797
/// <para>
17981798
/// Create or update a Row. Before using this route, you should create a new
17991799
/// table resource using either a [server
1800-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1800+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
18011801
/// API or directly from your database console.
18021802
/// </para>
18031803
/// </summary>

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+
## 0.20.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 0.15.0
49

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstract and simplif
1717
Add this reference to your project's `.csproj` file:
1818

1919
```xml
20-
<PackageReference Include="Appwrite" Version="0.19.0" />
20+
<PackageReference Include="Appwrite" Version="0.20.0" />
2121
```
2222

2323
You can install packages from the command line:
2424

2525
```powershell
2626
# Package Manager
27-
Install-Package Appwrite -Version 0.19.0
27+
Install-Package Appwrite -Version 0.20.0
2828
2929
# or .NET CLI
30-
dotnet add package Appwrite --version 0.19.0
30+
dotnet add package Appwrite --version 0.20.0
3131
```
3232

3333

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Appwrite;
2+
using Appwrite.Models;
3+
using Appwrite.Services;
4+
5+
Client client = new Client()
6+
.SetEndPoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.SetProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.SetSession(""); // The user session to authenticate with
9+
10+
Account account = new Account(client);
11+
12+
Token result = await account.CreateEmailVerification(
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+
using Appwrite;
2+
using Appwrite.Models;
3+
using Appwrite.Services;
4+
5+
Client client = new Client()
6+
.SetEndPoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.SetProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.SetSession(""); // The user session to authenticate with
9+
10+
Account account = new Account(client);
11+
12+
Token result = await account.UpdateEmailVerification(
13+
userId: "<USER_ID>",
14+
secret: "<SECRET>"
15+
);

0 commit comments

Comments
 (0)