Skip to content

Commit 3c525da

Browse files
Merge branch 'master' into go-templates-update
2 parents 09b36d8 + 9381507 commit 3c525da

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env:
2727
- SDK=FlutterStable
2828
- SDK=Go112
2929
- SDK=Go118
30+
- SDK=FlutterBeta
3031
- SDK=KotlinJava8
3132
- SDK=KotlinJava11
3233
- SDK=Node12
@@ -42,7 +43,7 @@ env:
4243
- SDK=Ruby31
4344
- SDK=SwiftClient55
4445
- SDK=SwiftServer55
45-
# - SDK=WebChromium
46+
- SDK=WebChromium
4647
- SDK=WebNode
4748

4849
notifications:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
The SDK Generator uses predefined language settings as [Twig templates](https://twig.symfony.com/) to generate codebases based on different API specs.
1414

15-
Currently, the only spec supported is Swagger 2.0, but we intend to add support for more specification in the near future. This generator is still lacking support for any definition/models specs.
15+
Currently, the only spec supported is Swagger 2.0, but we intend to add support for more specifications in the near future. This generator is still lacking support for any definition/models specs.
1616

1717
## Getting Started
1818

templates/cli/lib/commands/command.js.twig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
5555
payload['{{ parameter.name }}'] = filePath;
5656
}
5757

58+
{% elseif parameter.type == 'object' %}
59+
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
60+
payload['{{ parameter.name }}'] = JSON.parse({{ parameter.name | caseCamel | escapeKeyword}});
61+
}
62+
5863
{% else %}
5964
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
6065
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel | escapeKeyword}}{% if method.consumes[0] == "multipart/form-data" and ( parameter.type != "string" and parameter.type != "array" ) %}.toString(){% endif %};
@@ -100,7 +105,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
100105
{% for key, header in method.headers %}
101106
'{{ key }}': '{{ header }}',
102107
{% endfor %}
103-
}, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %});
108+
}, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => {
109+
fs.unlinkSync(archivePath);
110+
throw err
111+
});{% endif %}
112+
104113
} else {
105114
const streamFilePath = payload['{{ parameter.name }}'];
106115
let id = undefined;
@@ -130,7 +139,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
130139
});
131140
payload['{{ parameter.name }}'] = stream;
132141

133-
response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %});
142+
response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => {
143+
fs.unlinkSync(archivePath);
144+
throw err
145+
});{% endif %}
146+
134147

135148
if (!id) {
136149
id = response['$id'];

templates/flutter/pubspec.yaml.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
device_info_plus: ^3.2.2
1515
flutter_web_auth: ^0.4.1
1616
http: ^0.13.4
17-
package_info_plus: 1.3.0
17+
package_info_plus: 1.4.2
1818
path_provider: ^2.0.9
1919
web_socket_channel: ^2.1.0
2020

tests/FlutterBetaTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
class FlutterBetaTest extends Base
6+
{
7+
protected string $language = 'flutter';
8+
protected string $class = 'Appwrite\SDK\Language\Flutter';
9+
protected array $build = [
10+
'mkdir -p tests/sdks/flutter/test',
11+
'cp tests/languages/flutter/tests.dart tests/sdks/flutter/test/appwrite_test.dart',
12+
];
13+
protected string $command =
14+
'docker run --rm -v $(pwd):/app -w /app/tests/sdks/flutter --env PUB_CACHE=vendor cirrusci/flutter:beta sh -c "flutter pub get && flutter test test/appwrite_test.dart"';
15+
16+
protected array $expectedOutput = [
17+
...Base::FOO_RESPONSES,
18+
...Base::BAR_RESPONSES,
19+
...Base::GENERAL_RESPONSES,
20+
...Base::LARGE_FILE_RESPONSES,
21+
...Base::EXCEPTION_RESPONSES,
22+
...Base::REALTIME_RESPONSES,
23+
...Base::COOKIE_RESPONSES,
24+
];
25+
}

0 commit comments

Comments
 (0)