Skip to content

Commit b157e9b

Browse files
Merge branch 'appwrite:master' into feat-add-interfaces-contributing
2 parents e3fdb04 + 127c11b commit b157e9b

40 files changed

+1411
-81
lines changed

example.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Appwrite\SDK\Language\DotNet;
1919
use Appwrite\SDK\Language\Flutter;
2020
use Appwrite\SDK\Language\Android;
21+
use Appwrite\SDK\Language\Kotlin;
2122

2223
try {
2324

@@ -393,6 +394,30 @@ function getSSLPage($url) {
393394
])
394395
;
395396
$sdk->generate(__DIR__ . '/examples/android');
397+
398+
// Kotlin
399+
$sdk = new SDK(new Kotlin(), new Swagger2($spec));
400+
401+
$sdk
402+
->setName('Kotlin')
403+
->setNamespace('io appwrite')
404+
->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')
405+
->setShortDescription('Appwrite Kotlin SDK')
406+
->setURL('https://example.com')
407+
->setGitUserName('appwrite')
408+
->setGitRepoName('sdk-for-kotlin')
409+
->setLogo('https://appwrite.io/v1/images/console.png')
410+
->setLicenseContent('test test test')
411+
->setWarning('**This SDK is compatible with Appwrite server version 0.7.x. For older versions, please check previous releases.**')
412+
->setChangelog('**CHANGELOG**')
413+
->setVersion('0.0.0-SNAPSHOT')
414+
->setTwitter('appwrite_io')
415+
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
416+
->setDefaultHeaders([
417+
'x-appwrite-response-format' => '0.8.0',
418+
])
419+
;
420+
$sdk->generate(__DIR__ . '/examples/kotlin');
396421
}
397422
catch (Exception $exception) {
398423
echo 'Error: ' . $exception->getMessage() . ' on ' . $exception->getFile() . ':' . $exception->getLine() . "\n";

src/SDK/Language/Android.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ public function getFiles()
110110
'minify' => false,
111111
],
112112
// Config for project :library
113-
[
114-
'scope' => 'default',
115-
'destination' => '/library/example/README.md',
116-
'template' => '/android/library/example/README.md.twig',
117-
'minify' => false,
118-
],
119113
[
120114
'scope' => 'default',
121115
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Client.kt',

src/SDK/Language/Kotlin.php

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function getParamExample(array $param)
190190
if(empty($example) && $example !== 0 && $example !== false) {
191191
switch ($type) {
192192
case self::TYPE_FILE:
193-
$output .= 'new File("./path-to-files/image.jpg")';
193+
$output .= 'File("./path-to-files/image.jpg")';
194194
break;
195195
case self::TYPE_NUMBER:
196196
case self::TYPE_INTEGER:
@@ -203,16 +203,18 @@ public function getParamExample(array $param)
203203
$output .= "\"\"";
204204
break;
205205
case self::TYPE_OBJECT:
206-
$output .= 'Any()';
206+
$output .= 'mapOf( "a" to "b" )';
207207
break;
208208
case self::TYPE_ARRAY:
209-
$output .= 'List<Any>()';
209+
$output .= 'listOf()';
210210
break;
211211
}
212212
}
213213
else {
214214
switch ($type) {
215215
case self::TYPE_OBJECT:
216+
$output .= 'mapOf( "a" to "b" )';
217+
break;
216218
case self::TYPE_FILE:
217219
case self::TYPE_NUMBER:
218220
case self::TYPE_INTEGER:
@@ -237,7 +239,132 @@ public function getParamExample(array $param)
237239
public function getFiles()
238240
{
239241
return [
240-
242+
// Config for root project
243+
[
244+
'scope' => 'copy',
245+
'destination' => '.github/workflows/publish.yml',
246+
'template' => '/kotlin/.github/workflows/publish.yml',
247+
'minify' => false,
248+
],
249+
[
250+
'scope' => 'method',
251+
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
252+
'template' => '/kotlin/docs/example.md.twig',
253+
'minify' => false,
254+
],
255+
[
256+
'scope' => 'copy',
257+
'destination' => 'gradle/wrapper/gradle-wrapper.jar',
258+
'template' => 'kotlin/gradle/wrapper/gradle-wrapper.jar',
259+
],
260+
[
261+
'scope' => 'copy',
262+
'destination' => 'gradle/wrapper/gradle-wrapper.properties',
263+
'template' => '/kotlin/gradle/wrapper/gradle-wrapper.properties',
264+
'minify' => false,
265+
],
266+
[
267+
'scope' => 'copy',
268+
'destination' => 'scripts/publish.gradle',
269+
'template' => '/kotlin/scripts/publish.gradle',
270+
'minify' => false,
271+
],
272+
[
273+
'scope' => 'copy',
274+
'destination' => 'scripts/setup.gradle',
275+
'template' => '/kotlin/scripts/setup.gradle',
276+
'minify' => false,
277+
],
278+
[
279+
'scope' => 'copy',
280+
'destination' => '.gitignore',
281+
'template' => '/kotlin/.gitignore',
282+
'minify' => false,
283+
],
284+
[
285+
'scope' => 'default',
286+
'destination' => 'build.gradle',
287+
'template' => '/kotlin/build.gradle.twig',
288+
'minify' => false,
289+
],
290+
[
291+
'scope' => 'default',
292+
'destination' => 'CHANGELOG.md',
293+
'template' => '/kotlin/CHANGELOG.md.twig',
294+
'minify' => false,
295+
],
296+
[
297+
'scope' => 'copy',
298+
'destination' => 'gradle.properties',
299+
'template' => '/kotlin/gradle.properties',
300+
'minify' => false,
301+
],
302+
[
303+
'scope' => 'copy',
304+
'destination' => 'gradlew',
305+
'template' => '/kotlin/gradlew',
306+
'minify' => false,
307+
],
308+
[
309+
'scope' => 'copy',
310+
'destination' => 'gradlew.bat',
311+
'template' => '/kotlin/gradlew.bat',
312+
'minify' => false,
313+
],
314+
[
315+
'scope' => 'default',
316+
'destination' => 'LICENSE.md',
317+
'template' => '/kotlin/LICENSE.md.twig',
318+
'minify' => false,
319+
],
320+
[
321+
'scope' => 'default',
322+
'destination' => 'README.md',
323+
'template' => '/kotlin/README.md.twig',
324+
'minify' => false,
325+
],
326+
[
327+
'scope' => 'default',
328+
'destination' => 'settings.gradle',
329+
'template' => '/kotlin/settings.gradle.twig',
330+
'minify' => false,
331+
],
332+
[
333+
'scope' => 'default',
334+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/Client.kt',
335+
'template' => '/kotlin/src/main/kotlin/io/appwrite/Client.kt.twig',
336+
'minify' => false,
337+
],
338+
[
339+
'scope' => 'default',
340+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/exceptions/{{spec.title | caseUcfirst}}Exception.kt',
341+
'template' => '/kotlin/src/main/kotlin/io/appwrite/exceptions/Exception.kt.twig',
342+
'minify' => false,
343+
],
344+
[
345+
'scope' => 'default',
346+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/extensions/JsonExtensions.kt',
347+
'template' => '/kotlin/src/main/kotlin/io/appwrite/extensions/JsonExtensions.kt.twig',
348+
'minify' => false,
349+
],
350+
[
351+
'scope' => 'default',
352+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/models/Error.kt',
353+
'template' => '/kotlin/src/main/kotlin/io/appwrite/models/Error.kt.twig',
354+
'minify' => false,
355+
],
356+
[
357+
'scope' => 'default',
358+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/services/BaseService.kt',
359+
'template' => '/kotlin/src/main/kotlin/io/appwrite/services/Service.kt.twig',
360+
'minify' => false,
361+
],
362+
[
363+
'scope' => 'service',
364+
'destination' => '/src/main/kotlin/{{ sdk.namespace | caseSlash }}/services/{{service.name | caseUcfirst}}.kt',
365+
'template' => '/kotlin/src/main/kotlin/io/appwrite/services/ServiceTemplate.kt.twig',
366+
'minify' => false,
367+
]
241368
];
242369
}
243370
}

templates/android/README.md.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# {{ spec.title }} {{sdk.name}} SDK
22

3+
![Maven Central](https://img.shields.io/maven-central/v/{{ sdk.namespace | caseDot }}/{{ sdk.gitRepoName | caseDash }}.svg?color=green&style=flat-square)
34
![License](https://img.shields.io/github/license/{{ sdk.gitUserName|url_encode }}/{{ sdk.gitRepoName|url_encode }}.svg?style=flat-square)
45
![Version](https://img.shields.io/badge/api%20version-{{ spec.version|url_encode }}-blue.svg?style=flat-square)
56
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)

templates/android/build.gradle.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ buildscript {
2121

2222
allprojects {
2323
repositories {
24-
maven { url "https://jitpack.io" }
2524
google()
2625
mavenCentral()
2726
}

templates/android/example/src/main/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
<category android:name="android.intent.category.LAUNCHER" />
1616
</intent-filter>
1717
</activity>
18+
19+
<activity android:name="io.appwrite.views.CallbackActivity" >
20+
<intent-filter android:label="android_web_auth">
21+
<action android:name="android.intent.action.VIEW" />
22+
<category android:name="android.intent.category.DEFAULT" />
23+
<category android:name="android.intent.category.BROWSABLE" />
24+
<data android:scheme="appwrite-callback-6070749e6acd4" />
25+
</intent-filter>
26+
</activity>
1827
</application>
1928

2029
</manifest>

templates/android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ import android.widget.Toast
88
import androidx.activity.ComponentActivity
99
import androidx.databinding.DataBindingUtil
1010
import androidx.fragment.app.Fragment
11+
import androidx.fragment.app.viewModels
1112
import androidx.lifecycle.Observer
12-
import androidx.lifecycle.ViewModelProvider
1313
import {{ sdk.namespace | caseDot }}.android.R
1414
import {{ sdk.namespace | caseDot }}.android.databinding.FragmentAccountBinding
1515

1616

1717
class AccountsFragment : Fragment() {
1818

1919
private lateinit var binding: FragmentAccountBinding
20-
private lateinit var viewModel: AccountsViewModel
20+
private val viewModel: AccountsViewModel by viewModels()
2121

2222
override fun onCreateView(
2323
inflater: LayoutInflater ,
2424
container: ViewGroup? ,
2525
savedInstanceState: Bundle?
26-
): View? {
27-
viewModel = ViewModelProvider(this).get(AccountsViewModel::class.java)
26+
): View {
2827
binding = DataBindingUtil.inflate(
2928
inflater,
3029
R.layout.fragment_account,

templates/android/library/build.gradle.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ android {
2828
targetSdkVersion(30)
2929
versionCode = 1
3030
versionName = "1.0"
31-
31+
buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\""
3232
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3333
consumerProguardFiles("consumer-rules.pro")
3434
}
3535

3636
buildTypes {
37-
named("release") {
37+
release {
3838
minifyEnabled false
3939
proguardFiles(
4040
getDefaultProguardFile("proguard-android-optimize.txt"),
@@ -60,15 +60,15 @@ dependencies {
6060
api("com.squareup.okhttp3:okhttp")
6161
implementation("com.squareup.okhttp3:okhttp-urlconnection")
6262
implementation("com.squareup.okhttp3:logging-interceptor")
63-
implementation("com.google.code.gson:gson:2.8.5")
63+
implementation("com.google.code.gson:gson:2.8.7")
6464

65+
implementation("net.gotev:cookie-store:1.3.5")
6566
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
6667
implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1")
6768
implementation("androidx.appcompat:appcompat:1.2.0")
6869
implementation("androidx.fragment:fragment-ktx:1.3.2")
6970
implementation("androidx.activity:activity-ktx:1.2.2")
7071
implementation("androidx.browser:browser:1.3.0")
71-
implementation("com.github.franmontiel:PersistentCookieJar:v1.0.1")
7272

7373
testImplementation 'junit:junit:4.+'
7474
testImplementation "androidx.test.ext:junit-ktx:1.1.2"

templates/android/library/example/README.md.twig

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)