Merge pull request #5785 from appwrite/update-dotnet-getting-started
doc: Update getting started examples for .NET SDK
This commit is contained in:
commit
a1519e263c
4 changed files with 70 additions and 69 deletions
|
@ -357,12 +357,12 @@ return [
|
||||||
[
|
[
|
||||||
'key' => 'dotnet',
|
'key' => 'dotnet',
|
||||||
'name' => '.NET',
|
'name' => '.NET',
|
||||||
'version' => '2.0.0',
|
'version' => '0.4.1',
|
||||||
'url' => 'https://github.com/appwrite/sdk-for-dotnet',
|
'url' => 'https://github.com/appwrite/sdk-for-dotnet',
|
||||||
'package' => 'https://www.nuget.org/packages/Appwrite',
|
'package' => 'https://www.nuget.org/packages/Appwrite',
|
||||||
'enabled' => false,
|
'enabled' => true,
|
||||||
'beta' => true,
|
'beta' => true,
|
||||||
'dev' => true,
|
'dev' => false,
|
||||||
'hidden' => false,
|
'hidden' => false,
|
||||||
'family' => APP_PLATFORM_SERVER,
|
'family' => APP_PLATFORM_SERVER,
|
||||||
'prism' => 'csharp',
|
'prism' => 'csharp',
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"appwrite/sdk-generator": "0.32.*",
|
"appwrite/sdk-generator": "0.33.*",
|
||||||
"ext-fileinfo": "*",
|
"ext-fileinfo": "*",
|
||||||
"phpunit/phpunit": "9.5.20",
|
"phpunit/phpunit": "9.5.20",
|
||||||
"squizlabs/php_codesniffer": "^3.6",
|
"squizlabs/php_codesniffer": "^3.6",
|
||||||
|
|
77
composer.lock
generated
77
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "169ab6e7dd540e45309d3c5093506fad",
|
"content-hash": "3eadbfe5543aafdf8682ea0465159e3c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/jwt",
|
"name": "adhocore/jwt",
|
||||||
|
@ -2964,16 +2964,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webonyx/graphql-php",
|
"name": "webonyx/graphql-php",
|
||||||
"version": "v14.11.9",
|
"version": "v14.11.10",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/webonyx/graphql-php.git",
|
"url": "https://github.com/webonyx/graphql-php.git",
|
||||||
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70"
|
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
|
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/d9c2fdebc6aa01d831bc2969da00e8588cffef19",
|
||||||
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
|
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2993,8 +2993,7 @@
|
||||||
"phpunit/phpunit": "^7.2 || ^8.5",
|
"phpunit/phpunit": "^7.2 || ^8.5",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0",
|
||||||
"react/promise": "2.*",
|
"react/promise": "2.*",
|
||||||
"simpod/php-coveralls-mirror": "^3.0",
|
"simpod/php-coveralls-mirror": "^3.0"
|
||||||
"squizlabs/php_codesniffer": "3.5.4"
|
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"psr/http-message": "To use standard GraphQL server",
|
"psr/http-message": "To use standard GraphQL server",
|
||||||
|
@ -3018,7 +3017,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/webonyx/graphql-php/issues",
|
"issues": "https://github.com/webonyx/graphql-php/issues",
|
||||||
"source": "https://github.com/webonyx/graphql-php/tree/v14.11.9"
|
"source": "https://github.com/webonyx/graphql-php/tree/v14.11.10"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -3026,22 +3025,22 @@
|
||||||
"type": "open_collective"
|
"type": "open_collective"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-01-06T12:12:50+00:00"
|
"time": "2023-07-05T14:23:37+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "appwrite/sdk-generator",
|
"name": "appwrite/sdk-generator",
|
||||||
"version": "0.32.3",
|
"version": "0.33.5",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/appwrite/sdk-generator.git",
|
"url": "https://github.com/appwrite/sdk-generator.git",
|
||||||
"reference": "4057e14a61335070034b1cbdce9e39bef94d997d"
|
"reference": "4e9dc898f8b52b1057abe1295c2ae44ca0501633"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4057e14a61335070034b1cbdce9e39bef94d997d",
|
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4e9dc898f8b52b1057abe1295c2ae44ca0501633",
|
||||||
"reference": "4057e14a61335070034b1cbdce9e39bef94d997d",
|
"reference": "4e9dc898f8b52b1057abe1295c2ae44ca0501633",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3077,9 +3076,9 @@
|
||||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
||||||
"source": "https://github.com/appwrite/sdk-generator/tree/0.32.3"
|
"source": "https://github.com/appwrite/sdk-generator/tree/0.33.5"
|
||||||
},
|
},
|
||||||
"time": "2023-04-27T19:22:05+00:00"
|
"time": "2023-07-06T20:26:40+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/deprecations",
|
"name": "doctrine/deprecations",
|
||||||
|
@ -3200,16 +3199,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "matthiasmullie/minify",
|
"name": "matthiasmullie/minify",
|
||||||
"version": "1.3.70",
|
"version": "1.3.71",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/matthiasmullie/minify.git",
|
"url": "https://github.com/matthiasmullie/minify.git",
|
||||||
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b"
|
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2807d9f9bece6877577ad44acb5c801bb3ae536b",
|
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
|
||||||
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b",
|
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3259,7 +3258,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/matthiasmullie/minify/issues",
|
"issues": "https://github.com/matthiasmullie/minify/issues",
|
||||||
"source": "https://github.com/matthiasmullie/minify/tree/1.3.70"
|
"source": "https://github.com/matthiasmullie/minify/tree/1.3.71"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -3267,7 +3266,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2022-12-09T12:56:44+00:00"
|
"time": "2023-04-25T20:33:03+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "matthiasmullie/path-converter",
|
"name": "matthiasmullie/path-converter",
|
||||||
|
@ -3383,16 +3382,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nikic/php-parser",
|
"name": "nikic/php-parser",
|
||||||
"version": "v4.15.5",
|
"version": "v4.16.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e"
|
"reference": "19526a33fb561ef417e822e85f08a00db4059c17"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e",
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17",
|
||||||
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e",
|
"reference": "19526a33fb561ef417e822e85f08a00db4059c17",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3433,9 +3432,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.15.5"
|
"source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0"
|
||||||
},
|
},
|
||||||
"time": "2023-05-19T20:20:00+00:00"
|
"time": "2023-06-25T14:52:30+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
|
@ -3786,16 +3785,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpdoc-parser",
|
"name": "phpstan/phpdoc-parser",
|
||||||
"version": "1.22.0",
|
"version": "1.22.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||||
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c"
|
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
|
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0",
|
||||||
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
|
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3827,9 +3826,9 @@
|
||||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.0"
|
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.1"
|
||||||
},
|
},
|
||||||
"time": "2023-06-01T12:35:21+00:00"
|
"time": "2023-06-29T20:46:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
|
@ -5581,16 +5580,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.6.0",
|
"version": "v3.6.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b"
|
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/106c170d08e8415d78be2d16c3d057d0d108262b",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
|
||||||
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b",
|
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -5636,7 +5635,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.6.0"
|
"source": "https://github.com/twigphp/Twig/tree/v3.6.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -5648,7 +5647,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-05-03T19:06:57+00:00"
|
"time": "2023-06-08T12:52:13+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
|
|
@ -1,43 +1,45 @@
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Initialize & Make API Request
|
### 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
|
```csharp
|
||||||
using Appwrite;
|
using Appwrite;
|
||||||
|
using Appwrite.Services;
|
||||||
|
using Appwrite.Models;
|
||||||
|
|
||||||
static async Task Main(string[] args)
|
var client = new Client()
|
||||||
{
|
.SetEndpoint("http://cloud.appwrite.io/v1")
|
||||||
var client = Client();
|
.SetProject("5ff3379a01d25") // Your project ID
|
||||||
|
.SetKey("cd868db89"); // Your secret API key
|
||||||
|
|
||||||
client
|
var users = new Users(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 = Users(client);
|
var user = await users.Create(
|
||||||
|
userId: ID.Unique(),
|
||||||
|
email: "email@example.com",
|
||||||
|
password: "password",
|
||||||
|
name: "name");
|
||||||
|
|
||||||
try {
|
Console.WriteLine(user.ToMap());
|
||||||
var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name');
|
|
||||||
Console.WriteLine(user.ToMap());
|
|
||||||
} catch (AppwriteException e) {
|
|
||||||
Console.WriteLine(e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Error Handling
|
### 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 presenting the `message` to the user or handling it yourself based on the provided error information. Below is an example.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var users = Users(client);
|
var users = new Users(client);
|
||||||
|
|
||||||
try {
|
try
|
||||||
var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name');
|
{
|
||||||
Console.WriteLine(user.ToMap());
|
var user = await users.Create(
|
||||||
} catch (AppwriteException e) {
|
userId: ID.Unique(),
|
||||||
|
email: "email@example.com",
|
||||||
|
password: "password",
|
||||||
|
name: "name");
|
||||||
|
}
|
||||||
|
catch (AppwriteException e)
|
||||||
|
{
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -47,4 +49,4 @@ You can use the following resources to learn more and get help
|
||||||
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
|
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
|
||||||
- 📜 [Appwrite Docs](https://appwrite.io/docs)
|
- 📜 [Appwrite Docs](https://appwrite.io/docs)
|
||||||
- 💬 [Discord Community](https://appwrite.io/discord)
|
- 💬 [Discord Community](https://appwrite.io/discord)
|
||||||
- 🚂 [Appwrite Dart Playground](https://github.com/appwrite/playground-for-dotnet)
|
- 🚂 [Appwrite .NET Playground](https://github.com/appwrite/playground-for-dotnet)
|
||||||
|
|
Loading…
Reference in a new issue