Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add user-agent to templates #507

Merged
merged 46 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8de2bbf
add user-agent to php SDK
everly-gif Aug 5, 2022
3413467
add user-agent to node header
everly-gif Aug 5, 2022
0c8bf17
add user-agent to python
everly-gif Aug 5, 2022
13a1e43
add user-agent to deno
everly-gif Aug 5, 2022
3eaba15
add user-agent to .NET
everly-gif Aug 5, 2022
4cb2fb8
add user-agent to Go
everly-gif Aug 5, 2022
c71771c
add user-agent to remaining sdks
everly-gif Aug 5, 2022
7f71f10
add user-agent to .NET
everly-gif Aug 5, 2022
7fa43d9
add user-agent to .NET
everly-gif Aug 5, 2022
2dd161c
Debug tests
everly-gif Aug 5, 2022
24cd303
fix kotlin tests
everly-gif Aug 5, 2022
beef731
Add user-agent to kotlin
everly-gif Aug 8, 2022
69b0a2c
Add user-agent to kotlin
everly-gif Aug 8, 2022
33d1175
fix kotlin tests
everly-gif Aug 8, 2022
8831bde
Merge branch 'master' of https://github.com/appwrite/sdk-generator in…
everly-gif Aug 9, 2022
6c005bc
add user-agent to python
everly-gif Aug 23, 2022
f9050a1
modify user-agent for php SDK
everly-gif Aug 23, 2022
0befe1b
modify user-agent for Deno SDK
everly-gif Aug 23, 2022
28519b8
Finish first draft
everly-gif Aug 23, 2022
acc47cd
minor fix
everly-gif Aug 23, 2022
054a250
fix merge conflicts
everly-gif Mar 10, 2023
eccdea8
fix dart tests
everly-gif Mar 10, 2023
910bc9f
add user-agent for dart
everly-gif Mar 10, 2023
64d8aa6
fix issues
everly-gif Mar 10, 2023
685a0d7
fix dart package issues
everly-gif Mar 10, 2023
c24136c
fix node failing tests
everly-gif Mar 11, 2023
1a2449c
fix go tests and revert dart
everly-gif Mar 11, 2023
619f9da
fix tests
everly-gif Mar 11, 2023
d0d1968
remove unused import
everly-gif Mar 11, 2023
a44d4f1
style: run linter
everly-gif Mar 11, 2023
6aa2980
fix dart tests
everly-gif Mar 11, 2023
0209ab5
Update templates/node/lib/client.js.twig
lohanidamodar Apr 20, 2023
788b1a3
Update templates/dart/pubspec.yaml.twig
lohanidamodar Apr 20, 2023
75c4631
Update templates/dart/lib/src/client_io.dart.twig
lohanidamodar Apr 20, 2023
1e9d549
move device infor to PHP
lohanidamodar Apr 20, 2023
57ad011
fix typo
lohanidamodar Apr 20, 2023
b52164d
remove extra space
lohanidamodar Apr 26, 2023
270287a
fix
lohanidamodar Apr 26, 2023
ae0bf76
fix golang
lohanidamodar Apr 26, 2023
06bd218
remove extra lines
lohanidamodar Apr 26, 2023
0cf1ab8
Update client_io.dart.twig
lohanidamodar May 2, 2023
ee33347
Update client.js.twig
lohanidamodar May 2, 2023
ca476ab
Update client.go.twig
lohanidamodar May 2, 2023
5d5fbe4
Update templates/node/lib/client.js.twig
lohanidamodar May 3, 2023
aaa1816
Update client.go.twig
lohanidamodar May 3, 2023
f7883d5
Update PHP.php
lohanidamodar May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/SDK/Language/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ public function getFilters(): array
return [
new TwigFilter('getReturn', function ($value) {
return $this->getReturn($value);
})
}),
new TwigFilter('deviceInfo', function ($value) {
return php_uname('s') . '; ' . php_uname('v') . '; ' . php_uname('m');
}),
];
}
}
1 change: 1 addition & 0 deletions templates/dart/lib/src/client_io.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-platform': '{{ sdk.platform }}',
'x-sdk-language': '{{ language.name | caseLower }}',
'x-sdk-version': '{{ sdk.version }}',
'user-agent' : '{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} ({{Platform.operatingSystem}}; {{Platform.operatingSystemVersion}})',
{% for key,header in spec.global.defaultHeaders %}
'{{key}}' : '{{header}}',
{% endfor %}
Expand Down
1 change: 1 addition & 0 deletions templates/deno/src/client.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Client {
endpoint: string = '{{spec.endpoint}}';
headers: Payload = {
'content-type': '',
'user-agent' : `{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} (${Deno.build.os}; ${Deno.build.arch})`,
stnguyen90 marked this conversation as resolved.
Show resolved Hide resolved
'x-sdk-name': '{{ sdk.name }}',
'x-sdk-platform': '{{ sdk.platform }}',
'x-sdk-language': '{{ language.name | caseLower }}',
Expand Down
1 change: 1 addition & 0 deletions templates/dotnet/src/Appwrite/Client.cs.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace {{ spec.title | caseUcfirst }}
this.headers = new Dictionary<string, string>()
{
{ "content-type", "application/json" },
{ "user-agent" , "{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} (${Environment.OSVersion.Platform}; ${Environment.OSVersion.VersionString})"},
{ "x-sdk-name", "{{ sdk.name }}" },
{ "x-sdk-platform", "{{ sdk.platform }}" },
{ "x-sdk-language", "{{ language.name | caseLower }}" },
Expand Down
4 changes: 3 additions & 1 deletion templates/go/client.go.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"strconv"
"strings"
"time"
"runtime"
)

const (
Expand Down Expand Up @@ -65,6 +66,7 @@ func NewClient() Client {
headers := map[string]string{
{% for key,header in spec.global.defaultHeaders %}
"{{key}}" : "{{header}}",
"user-agent" : fmt.Sprintf("{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} (%s; %s)", runtime.GOOS, runtime.GOARCH),
abnegate marked this conversation as resolved.
Show resolved Hide resolved
"x-sdk-name": "{{ sdk.name }}",
"x-sdk-platform": "{{ sdk.platform }}",
"x-sdk-language": "{{ language.name | caseLower }}",
Expand Down Expand Up @@ -387,4 +389,4 @@ func toString(arg interface{}) string {
default:
return fmt.Sprintf("%s", v)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
"user-agent" to "{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} ${System.getProperty("http.agent")}",
stnguyen90 marked this conversation as resolved.
Show resolved Hide resolved
"x-sdk-name" to "{{ sdk.name }}",
"x-sdk-platform" to "{{ sdk.platform }}",
"x-sdk-language" to "{{ language.name | caseLower }}",
"x-sdk-version" to "{{ sdk.version }}"{% if spec.global.defaultHeaders | length > 0 %},{% endif %}

{% for key,header in spec.global.defaultHeaders %}
"{{ key | caseLower }}" to "{{ header }}"{% if not loop.last %},{% endif %}
{% endfor %}
Expand Down
2 changes: 2 additions & 0 deletions templates/node/lib/client.js.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const os = require('os');
const URL = require('url').URL;
const axios = require('axios');
const FormData = require('form-data');
Expand All @@ -11,6 +12,7 @@ class Client {
this.headers = {
'accept-encoding': '*',
'content-type': '',
'user-agent' : `{{spec.title | caseUcfirst}}{{language.name | caseUcfirst}}SDK/{{ sdk.version }} (${os.type()}; ${os.version()}; ${os.arch()})`,
'x-sdk-name': '{{ sdk.name }}',
'x-sdk-platform': '{{ sdk.platform }}',
'x-sdk-language': '{{ language.name | caseLower }}',
Expand Down
1 change: 1 addition & 0 deletions templates/php/src/Client.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Client
*/
protected $headers = [
'content-type' => '',
'user-agent' => '{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} ({{deviceInfo}})',
'x-sdk-name'=> '{{ sdk.name }}',
'x-sdk-platform'=> '{{ sdk.platform }}',
'x-sdk-language'=> '{{ language.name | caseLower }}',
Expand Down
1 change: 1 addition & 0 deletions templates/python/package/client.py.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Client:
self._endpoint = '{{spec.endpoint}}'
self._global_headers = {
'content-type': '',
'user-agent' : '{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
stnguyen90 marked this conversation as resolved.
Show resolved Hide resolved
'x-sdk-name': '{{ sdk.name }}',
'x-sdk-platform': '{{ sdk.platform }}',
'x-sdk-language': '{{ language.name | caseLower }}',
Expand Down