Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest changes #21

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/bin
**/obj
**/.DS_Store
**/.vs
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors.
Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand All @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification,

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 changes: 28 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Appwrite .NET SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-dotnet.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.3.2-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).**
**This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).**

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the .NET SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand All @@ -17,69 +17,65 @@ Appwrite is an open-source backend as a service server that abstract and simplif
Add this reference to your project's `.csproj` file:

```xml
<PackageReference Include="Appwrite" Version="0.3.0" />
<PackageReference Include="Appwrite" Version="0.4.0" />
```

You can install packages from the command line:

```powershell
# Package Manager
Install-Package Appwrite -Version 0.3.0
Install-Package Appwrite -Version 0.4.0

# or .NET CLI
dotnet add package Appwrite --version 0.3.0
dotnet add package Appwrite --version 0.4.0
```



## Getting Started

### Initialize & Make API Request
Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example:
Once you have installed the package, it is extremely easy to get started with the SDK; all you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example:

```csharp
using Appwrite;

static async Task Main(string[] args)
{
var client = Client();
var client = new Client()
.SetEndpoint("http://cloud.appwrite.io/v1") // Make sure your endpoint is accessible
.SetProject("5ff3379a01d25") // Your project ID
.SetKey("cd868db89") // Your secret API key
.SetSelfSigned(); // Use only on dev mode with a self-signed SSL cert

client
.setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible
.setProject('5ff3379a01d25') // Your project ID
.setKey('cd868c7af8bdc893b4...93b7535db89')
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
;
var users = new Users(client);

var users = Users(client);
var user = await users.Create(
userId: ID.Unique(),
email: "[email protected]",
password: "password",
name: "name");

try {
var request = await users.create('[email protected]', 'password', 'name');
var response = await request.Content.ReadAsStringAsync();
Console.WriteLine(response);
} catch (AppwriteException e) {
Console.WriteLine(e.Message);
}
}
Console.WriteLine(user.ToMap());
```

### Error Handling
The Appwrite .NET SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
The Appwrite .NET SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.

```csharp
var users = Users(client);
var users = new Users(client);

try {
var request = await users.create('[email protected]', 'password', 'name');
var response = await request.Content.ReadAsStringAsync();
Console.WriteLine(response);
var user = await users.Create(
userId: ID.Unique(),
email: "[email protected]",
password: "password",
name: "name");
} catch (AppwriteException e) {
Console.WriteLine(e.Message);
Console.WriteLine(e.Message);
}
```

### Learn more
You can use following resources to learn more and get help
You can use the following resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [Discord Community](https://appwrite.io/discord)
Expand Down
11 changes: 11 additions & 0 deletions docs/examples/account/create-phone-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Appwrite;
using Appwrite.Models;

var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

var account = new Account(client);

Token result = await account.CreatePhoneVerification();
18 changes: 9 additions & 9 deletions docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.CreateRecovery("[email protected]", "https://example.com");
Token result = await account.CreateRecovery(
email: "[email protected]",
url: "https://example.com");
17 changes: 8 additions & 9 deletions docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.CreateVerification("https://example.com");
Token result = await account.CreateVerification(
url: "https://example.com");
17 changes: 8 additions & 9 deletions docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.DeleteSession("[SESSION_ID]");
await account.DeleteSession(
sessionId: "[SESSION_ID]");
16 changes: 7 additions & 9 deletions docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.DeleteSessions();
await account.DeleteSessions();
13 changes: 0 additions & 13 deletions docs/examples/account/delete.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/examples/account/get-logs.md

This file was deleted.

16 changes: 7 additions & 9 deletions docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.GetPrefs();
Preferences result = await account.GetPrefs();
17 changes: 8 additions & 9 deletions docs/examples/account/get-session.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.GetSession("[SESSION_ID]");
Session result = await account.GetSession(
sessionId: "[SESSION_ID]");
13 changes: 0 additions & 13 deletions docs/examples/account/get-sessions.md

This file was deleted.

16 changes: 7 additions & 9 deletions docs/examples/account/get.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.Get();
User result = await account.Get();
11 changes: 11 additions & 0 deletions docs/examples/account/list-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Appwrite;
using Appwrite.Models;

var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

var account = new Account(client);

LogList result = await account.ListLogs();
11 changes: 11 additions & 0 deletions docs/examples/account/list-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Appwrite;
using Appwrite.Models;

var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

var account = new Account(client);

SessionList result = await account.ListSessions();
18 changes: 9 additions & 9 deletions docs/examples/account/update-email.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Appwrite;
using Appwrite.Models;

Client client = new Client();
var client = new Client()
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token

client
.SetEndPoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.SetProject("5df5acd0d48c2") // Your project ID
.SetJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
;
var account = new Account(client);

Account account = new Account(client);

HttpResponseMessage result = await account.UpdateEmail("[email protected]", "password");
User result = await account.UpdateEmail(
email: "[email protected]",
password: "password");
Loading