forked from appwrite/sdk-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
108 lines (82 loc) · 3.07 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
include_once 'vendor/autoload.php';
use Appwrite\Spec\Swagger2;
use Appwrite\SDK\SDK;
use Appwrite\SDK\Language\JS;
use Appwrite\SDK\Language\Node;
use Appwrite\SDK\Language\PHP;
use Appwrite\SDK\Language\Python;
use Appwrite\SDK\Language\Ruby;
use Appwrite\SDK\Language\Dart;
$languages = ['js', 'node', 'php', 'python', 'ruby', 'dart'];
try {
function getSSLPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
//$spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1');
$spec = getSSLPage('https://appwrite.test/v1/open-api-2.json?extensions=1');
// PHP
$sdk = new SDK(new PHP(), new Swagger2($spec));
$sdk
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
;
$sdk->generate(__DIR__ . '/examples/php');
// JS
$sdk = new SDK(new JS(), new Swagger2($spec));
$sdk
->setVersion('0.0.0')
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
;
$sdk->generate(__DIR__ . '/examples/js');
// Node
$sdk = new SDK(new Node(), new Swagger2($spec));
$sdk
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
;
$sdk->generate(__DIR__ . '/examples/node');
// Ruby
$sdk = new SDK(new Ruby(), new Swagger2($spec));
$sdk
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
;
$sdk->generate(__DIR__ . '/examples/ruby');
// Python
$sdk = new SDK(new Python(), new Swagger2($spec));
$sdk
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
;
$sdk->generate(__DIR__ . '/examples/python');
// Dart
$sdk = new SDK(new Dart(), new Swagger2($spec));
$sdk
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
->setVersion('0.0.1')
;
$sdk->generate(__DIR__ . '/examples/dart');
}
catch (Exception $exception) {
echo 'Error: ' . $exception->getMessage() . ' on ' . $exception->getFile() . ':' . $exception->getLine() . "\n";
}
catch (Throwable $exception) {
echo 'Error: ' . $exception->getMessage() . ' on ' . $exception->getFile() . ':' . $exception->getLine() . "\n";
}