Skip to content

Commit 400c2a2

Browse files
committed
Merge branch 'master' into feat-update-dart-flutter-test
2 parents fa1f0fd + 9dd1321 commit 400c2a2

File tree

166 files changed

+3994
-1929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+3994
-1929
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,21 @@ The following checklist aims to balance consistency among languages, and follow
139139
- [ ] Default Headers
140140
- [ ] 'appwrite-sdk-version' header
141141
- [ ] Add 'User-Agent' header with device/server name and version + platform name and version (ubuntu-20.04-php-7.0.1 / android-20.0-flutter-3.0)
142+
- [ ] Add 'origin' header with the following syntax `<scheme>://<identifier>` where scheme is one of `http`, `https`, `appwrite-android`, `appwrite-ios`, `appwrite-macos`, `appwrite-windows`, `appwrite-linux` and identifier is the host name is case of web apps and the package name in case of ios, android and other platforms.
143+
- [ ] All Global headers available in spec
142144
- [ ] Methods
143145
- [ ] addHeader(key, value)
144146
- [ ] call(method, path = '', headers = [], params = [])
145147
- [ ] Concat GET params to path
146148
- [ ] Parse request params by content type header
147149
- [ ] Parse response params by content type header
148150
- [ ] Throw error on bad response
151+
- [ ] Handle errors and throw `AppwriteException` with proper information
149152
- [ ] Service Abstraction (optional)
150153
- [ ] Constructor receiving an instance of the client class
151154
- [ ] Service Class (extends the service abstraction if exists)
152155
- [ ] Headers Support (Content Type)
153156
- [ ] Parameters Support
154-
- [ ] Default Values Support
155157
- [ ] Required Values Support
156158
- [ ] String Support
157159
- [ ] Integer Support
@@ -183,6 +185,8 @@ After you finish initializing, make a series of HTTP calls using your new genera
183185
1. tests/languages/tests-for-php.js
184186
2. tests/languages/tests-for-node.js
185187

188+
> Note: In your test files, make sure that you begin the test with the following string "\nTest Started\n". We use this string to filter output from the build tool you're using.
189+
186190
Once done, add a Docker command that can execute your test file to the SDK test algorithm `$containers` array in this location: `./tests/SDKTest.php:17`. Make sure to add one command for each language version you wish to support.
187191

188192
A good example is the PHP test for 5 different PHP versions:
@@ -200,5 +204,5 @@ protected $containers = [
200204

201205
Finally, you can run the tests using
202206
```sh
203-
docker run --rm -v $(pwd):/app:rw -w /app -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit tests/SDKTest.php"
207+
docker run --rm -v $(pwd):$(pwd):rw -w $(pwd) -v /var/run/docker.sock:/var/run/docker.sock php:7.4-cli-alpine sh -c "apk add docker-cli && vendor/bin/phpunit tests/SDKTest.php"
204208
```

composer.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example.php

Lines changed: 30 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
use Appwrite\SDK\Language\Ruby;
1313
use Appwrite\SDK\Language\Dart;
1414
use Appwrite\SDK\Language\Go;
15-
use Appwrite\SDK\Language\Java;
16-
use Appwrite\SDK\Language\Typescript;
1715
use Appwrite\SDK\Language\Deno;
1816
use Appwrite\SDK\Language\HTTP;
1917
use Appwrite\SDK\Language\Swift;
2018
use Appwrite\SDK\Language\DotNet;
2119
use Appwrite\SDK\Language\Flutter;
20+
use Appwrite\SDK\Language\Android;
2221
use Appwrite\SDK\Language\Kotlin;
2322

2423
try {
@@ -38,7 +37,7 @@ function getSSLPage($url) {
3837
//$spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1');
3938
// $spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1'); // Enable only with Appwrite local server running on port 80
4039
// $spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform=console'); // Enable only with Appwrite local server running on port 80
41-
40+
// $spec = file_get_contents('https://appwrite.io/specs/swagger2?platform=client');
4241
$spec = file_get_contents('./specs/swagger-appwrite.0.8.0.json');
4342

4443
if(empty($spec)) {
@@ -97,30 +96,6 @@ function getSSLPage($url) {
9796

9897
$sdk->generate(__DIR__ . '/examples/web');
9998

100-
// TypeScript
101-
$sdk = new SDK(new Typescript(), new Swagger2($spec));
102-
103-
$sdk
104-
->setName('NAME')
105-
->setDescription('Repo description goes here')
106-
->setShortDescription('Repo short description goes here')
107-
->setVersion('0.0.0')
108-
->setURL('https://example.com')
109-
->setLogo('https://appwrite.io/v1/images/console.png')
110-
->setLicenseContent('test test test')
111-
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
112-
->setChangelog('**CHANGELOG**')
113-
->setGitUserName('repoowner')
114-
->setGitRepoName('reponame')
115-
->setTwitter('appwrite_io')
116-
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
117-
->setDefaultHeaders([
118-
'X-Appwrite-Response-Format' => '0.7.0',
119-
])
120-
;
121-
122-
$sdk->generate(__DIR__ . '/examples/typescript');
123-
12499
// Deno
125100
$sdk = new SDK(new Deno(), new Swagger2($spec));
126101

@@ -293,31 +268,6 @@ function getSSLPage($url) {
293268

294269
$sdk->generate(__DIR__ . '/examples/go');
295270

296-
// Java
297-
298-
$sdk = new SDK(new Java(), new Swagger2($spec));
299-
300-
$sdk
301-
->setName('NAME')
302-
->setNamespace('io appwrite')
303-
->setDescription('Repo description goes here')
304-
->setShortDescription('Repo short description goes here')
305-
->setURL('https://example.com')
306-
->setGitUserName('appwrite')
307-
->setGitRepoName('java-sdk')
308-
->setLogo('https://appwrite.io/v1/images/console.png')
309-
->setLicenseContent('test test test')
310-
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
311-
->setChangelog('**CHANGELOG**')
312-
->setVersion('0.0.1')
313-
->setTwitter('appwrite_io')
314-
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
315-
->setDefaultHeaders([
316-
'X-Appwrite-Response-Format' => '0.7.0',
317-
])
318-
;
319-
320-
$sdk->generate(__DIR__ . '/examples/java');
321271

322272
// Swift
323273
$sdk = new SDK(new Swift(), new Swagger2($spec));
@@ -420,8 +370,32 @@ function getSSLPage($url) {
420370
;
421371
$sdk->generate(__DIR__ . '/examples/CLI');
422372

423-
// Kotlin
373+
// Android
424374

375+
$sdk = new SDK(new Android(), new Swagger2($spec));
376+
377+
$sdk
378+
->setName('Android')
379+
->setNamespace('io appwrite')
380+
->setDescription('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 Flutter 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')
381+
->setShortDescription('Appwrite Android SDK')
382+
->setURL('https://example.com')
383+
->setGitUserName('appwrite')
384+
->setGitRepoName('sdk-for-android')
385+
->setLogo('https://appwrite.io/v1/images/console.png')
386+
->setLicenseContent('test test test')
387+
->setWarning('**This SDK is compatible with Appwrite server version 0.7.x. For older versions, please check previous releases.**')
388+
->setChangelog('**CHANGELOG**')
389+
->setVersion('0.0.0-SNAPSHOT')
390+
->setTwitter('appwrite_io')
391+
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
392+
->setDefaultHeaders([
393+
'x-appwrite-response-format' => '0.7.0',
394+
])
395+
;
396+
$sdk->generate(__DIR__ . '/examples/android');
397+
398+
// Kotlin
425399
$sdk = new SDK(new Kotlin(), new Swagger2($spec));
426400

427401
$sdk
@@ -435,95 +409,15 @@ function getSSLPage($url) {
435409
->setLogo('https://appwrite.io/v1/images/console.png')
436410
->setLicenseContent('test test test')
437411
->setWarning('**This SDK is compatible with Appwrite server version 0.7.x. For older versions, please check previous releases.**')
438-
->setGettingStarted("
439-
### Add your Android Platform
440-
To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button.
441-
442-
From the options, choose to add a new **Flutter** platform and add your app credentials, ignoring iOS.
443-
444-
Add your app <u>name</u> and <u>package name</u>, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API.
445-
446-
### OAuth
447-
In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console.
448-
449-
```xml
450-
<manifest>
451-
<application>
452-
<activity android:name=\"io.appwrite.views.CallbackActivity\" >
453-
<intent-filter android:label=\"android_web_auth\">
454-
<action android:name=\"android.intent.action.VIEW\" />
455-
<category android:name=\"android.intent.category.DEFAULT\" />
456-
<category android:name=\"android.intent.category.BROWSABLE\" />
457-
<data android:scheme=\"appwrite-callback-[PROJECT_ID]\" />
458-
</intent-filter>
459-
</activity>
460-
</application>
461-
</manifest>
462-
```
463-
464-
### Init your SDK
465-
466-
<p>Initialize your SDK code with your project ID, which can be found in your project settings page.
467-
468-
```kotlin
469-
import io.appwrite.Client
470-
import io.appwrite.services.Account
471-
472-
val client = Client(context)
473-
.setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint
474-
.setProject(\"5df5acd0d48c2\") // Your project ID
475-
.setSelfSigned(true) // Remove in production
476-
```
477-
478-
Before starting to send any API calls to your new Appwrite instance, make sure your Android emulators has network access to the Appwrite server hostname or IP address.
479-
480-
When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API.
481-
482-
### Make Your First Request
483-
484-
<p>Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
485-
486-
```kotlin
487-
// Register User
488-
val accountService = Account(client)
489-
val user = accountService.create(
490-
491-
\"password\"
492-
)
493-
```
494-
495-
### Full Example
496-
497-
```kotlin
498-
import io.appwrite.Client
499-
import io.appwrite.services.Account
500-
501-
val client = Client(context)
502-
.setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint
503-
.setProject(\"5df5acd0d48c2\") // Your project ID
504-
.setSelfSigned(true) // Remove in production
505-
506-
val accountService = Account(client)
507-
val user = accountService.create(
508-
509-
\"password\"
510-
)
511-
```
512-
513-
### Learn more
514-
You can use following resources to learn more and get help
515-
- 📜 [Appwrite Docs](https://appwrite.io/docs)
516-
- 💬 [Discord Community](https://appwrite.io/discord)
517-
")
518412
->setChangelog('**CHANGELOG**')
519-
->setVersion('0.7.0')
413+
->setVersion('0.0.0-SNAPSHOT')
520414
->setTwitter('appwrite_io')
521415
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
522416
->setDefaultHeaders([
523-
'x-appwrite-response-format' => '0.7.0',
417+
'x-appwrite-response-format' => '0.8.0',
524418
])
525419
;
526-
$sdk->generate(__DIR__ . '/examples/kotlin-android');
420+
$sdk->generate(__DIR__ . '/examples/kotlin');
527421
}
528422
catch (Exception $exception) {
529423
echo 'Error: ' . $exception->getMessage() . ' on ' . $exception->getFile() . ':' . $exception->getLine() . "\n";

specs/swagger-appwrite.0.8.0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)