1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

Merge pull request #5785 from appwrite/update-dotnet-getting-started

doc: Update getting started examples for .NET SDK
This commit is contained in:
Christy Jacob 2023-07-11 00:03:19 +05:30 committed by GitHub
commit a1519e263c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 69 deletions

View file

@ -357,12 +357,12 @@ return [
[
'key' => 'dotnet',
'name' => '.NET',
'version' => '2.0.0',
'version' => '0.4.1',
'url' => 'https://github.com/appwrite/sdk-for-dotnet',
'package' => 'https://www.nuget.org/packages/Appwrite',
'enabled' => false,
'enabled' => true,
'beta' => true,
'dev' => true,
'dev' => false,
'hidden' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'csharp',

View file

@ -79,7 +79,7 @@
}
],
"require-dev": {
"appwrite/sdk-generator": "0.32.*",
"appwrite/sdk-generator": "0.33.*",
"ext-fileinfo": "*",
"phpunit/phpunit": "9.5.20",
"squizlabs/php_codesniffer": "^3.6",

77
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "169ab6e7dd540e45309d3c5093506fad",
"content-hash": "3eadbfe5543aafdf8682ea0465159e3c",
"packages": [
{
"name": "adhocore/jwt",
@ -2964,16 +2964,16 @@
},
{
"name": "webonyx/graphql-php",
"version": "v14.11.9",
"version": "v14.11.10",
"source": {
"type": "git",
"url": "https://github.com/webonyx/graphql-php.git",
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70"
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
"reference": "ff91c9f3cf241db702e30b2c42bcc0920e70ac70",
"url": "https://api.github.com/repos/webonyx/graphql-php/zipball/d9c2fdebc6aa01d831bc2969da00e8588cffef19",
"reference": "d9c2fdebc6aa01d831bc2969da00e8588cffef19",
"shasum": ""
},
"require": {
@ -2993,8 +2993,7 @@
"phpunit/phpunit": "^7.2 || ^8.5",
"psr/http-message": "^1.0",
"react/promise": "2.*",
"simpod/php-coveralls-mirror": "^3.0",
"squizlabs/php_codesniffer": "3.5.4"
"simpod/php-coveralls-mirror": "^3.0"
},
"suggest": {
"psr/http-message": "To use standard GraphQL server",
@ -3018,7 +3017,7 @@
],
"support": {
"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": [
{
@ -3026,22 +3025,22 @@
"type": "open_collective"
}
],
"time": "2023-01-06T12:12:50+00:00"
"time": "2023-07-05T14:23:37+00:00"
}
],
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.32.3",
"version": "0.33.5",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "4057e14a61335070034b1cbdce9e39bef94d997d"
"reference": "4e9dc898f8b52b1057abe1295c2ae44ca0501633"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4057e14a61335070034b1cbdce9e39bef94d997d",
"reference": "4057e14a61335070034b1cbdce9e39bef94d997d",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4e9dc898f8b52b1057abe1295c2ae44ca0501633",
"reference": "4e9dc898f8b52b1057abe1295c2ae44ca0501633",
"shasum": ""
},
"require": {
@ -3077,9 +3076,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"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",
@ -3200,16 +3199,16 @@
},
{
"name": "matthiasmullie/minify",
"version": "1.3.70",
"version": "1.3.71",
"source": {
"type": "git",
"url": "https://github.com/matthiasmullie/minify.git",
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b"
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/2807d9f9bece6877577ad44acb5c801bb3ae536b",
"reference": "2807d9f9bece6877577ad44acb5c801bb3ae536b",
"url": "https://api.github.com/repos/matthiasmullie/minify/zipball/ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
"reference": "ae42a47d7fecc1fbb7277b2f2d84c37a33edc3b1",
"shasum": ""
},
"require": {
@ -3259,7 +3258,7 @@
],
"support": {
"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": [
{
@ -3267,7 +3266,7 @@
"type": "github"
}
],
"time": "2022-12-09T12:56:44+00:00"
"time": "2023-04-25T20:33:03+00:00"
},
{
"name": "matthiasmullie/path-converter",
@ -3383,16 +3382,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.15.5",
"version": "v4.16.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e"
"reference": "19526a33fb561ef417e822e85f08a00db4059c17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e",
"reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17",
"reference": "19526a33fb561ef417e822e85f08a00db4059c17",
"shasum": ""
},
"require": {
@ -3433,9 +3432,9 @@
],
"support": {
"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",
@ -3786,16 +3785,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.22.0",
"version": "1.22.1",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c"
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
"reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/65c39594fbd8c67abfc68bb323f86447bab79cc0",
"reference": "65c39594fbd8c67abfc68bb323f86447bab79cc0",
"shasum": ""
},
"require": {
@ -3827,9 +3826,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"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",
@ -5581,16 +5580,16 @@
},
{
"name": "twig/twig",
"version": "v3.6.0",
"version": "v3.6.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b"
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/106c170d08e8415d78be2d16c3d057d0d108262b",
"reference": "106c170d08e8415d78be2d16c3d057d0d108262b",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
"reference": "7e7d5839d4bec168dfeef0ac66d5c5a2edbabffd",
"shasum": ""
},
"require": {
@ -5636,7 +5635,7 @@
],
"support": {
"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": [
{
@ -5648,7 +5647,7 @@
"type": "tidelift"
}
],
"time": "2023-05-03T19:06:57+00:00"
"time": "2023-06-08T12:52:13+00:00"
}
],
"aliases": [],

View file

@ -1,44 +1,46 @@
## 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;
using Appwrite.Services;
using Appwrite.Models;
static async Task Main(string[] args)
{
var client = Client();
var client = new Client()
.SetEndpoint("http://cloud.appwrite.io/v1")
.SetProject("5ff3379a01d25") // Your project ID
.SetKey("cd868db89"); // Your secret API key
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@example.com",
password: "password",
name: "name");
try {
var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name');
Console.WriteLine(user.ToMap());
} 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 presenting the `message` to the user or handling it yourself based on the provided error information. Below is an example.
```csharp
var users = Users(client);
var users = new Users(client);
try {
var user = await users.Create(ID.Unique(), 'email@example.com', 'password', 'name');
Console.WriteLine(user.ToMap());
} catch (AppwriteException e) {
Console.WriteLine(e.Message);
try
{
var user = await users.Create(
userId: ID.Unique(),
email: "email@example.com",
password: "password",
name: "name");
}
catch (AppwriteException e)
{
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)
- 📜 [Appwrite Docs](https://appwrite.io/docs)
- 💬 [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)