-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from appwrite/feat-dotnet-response-models
- Loading branch information
Showing
29 changed files
with
1,757 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% import 'dotnet/base/utils.twig' as utils %} | ||
{%~ for parameter in method.parameters.path %} | ||
.Replace("{{ '{' ~ parameter.name | caseCamel ~ '}' }}", {{ parameter.name | caseCamel | escapeKeyword }}){% if loop.last %};{% endif %} | ||
|
||
{%~ endfor %} | ||
|
||
var parameters = new Dictionary<string, object?>() | ||
{ | ||
{%~ for parameter in method.parameters.query | merge(method.parameters.body) %} | ||
{ "{{ parameter.name }}", {{ utils.map_parameter(parameter) }} }{% if not loop.last %},{% endif %} | ||
|
||
{%~ endfor %} | ||
}; | ||
|
||
var headers = new Dictionary<string, string>() | ||
{ | ||
{%~ for key, header in method.headers %} | ||
{ "{{ key }}", "{{ header }}" }{% if not loop.last %},{% endif %} | ||
|
||
{%~ endfor %} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% import 'dotnet/base/utils.twig' as utils %} | ||
return _client.Call{% if method.type != 'webAuth' %}<{{ utils.resultType(spec.title, method) }}>{% endif %}( | ||
method: "{{ method.method | caseUpper }}", | ||
path: path, | ||
headers: headers, | ||
{%~ if not method.responseModel %} | ||
parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); | ||
{%~ else %} | ||
parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, | ||
convert: Convert); | ||
{%~ endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
string? idParamName = {% if method.parameters.all | filter(p => p.isUploadID) | length > 0 %}{% for parameter in method.parameters.all | filter(parameter => parameter.isUploadID) %}"{{ parameter.name }}"{% endfor %}{% else %}null{% endif %}; | ||
|
||
{%~ for parameter in method.parameters.all %} | ||
{%~ if parameter.type == 'file' %} | ||
var paramName = "{{ parameter.name }}"; | ||
{%~ endif %} | ||
{%~ endfor %} | ||
|
||
return _client.ChunkedUpload( | ||
path, | ||
headers, | ||
parameters, | ||
{%~ if method.responseModel %} | ||
Convert, | ||
{%~ endif %} | ||
paramName, | ||
idParamName, | ||
onProgress); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
return _client.Call<byte[]>( | ||
method: "{{ method.method | caseUpper }}", | ||
path: path, | ||
headers: headers, | ||
parameters: parameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% macro parameter(parameter) %} | ||
{% if parameter.name == 'orderType' %}{{ 'OrderType orderType = OrderType.ASC' }}{% else %} | ||
{{ parameter | typeName }}{% if not parameter.required %}?{% endif %} {{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %} = null{% endif %}{% endif %} | ||
{% endmacro %} | ||
{% macro method_parameters(parameters, consumes) %} | ||
{% if parameters.all|length > 0 %}{% for parameter in parameters.all | filter((param) => not param.isGlobal) %}{{ _self.parameter(parameter) }}{% if not loop.last %}{{ ', ' }}{% endif %}{% endfor %}{% if 'multipart/form-data' in consumes %},{% endif %}{% endif %}{% if 'multipart/form-data' in consumes %} Action<UploadProgress>? onProgress = null{% endif %} | ||
{% endmacro %} | ||
{% macro map_parameter(parameter) %} | ||
{% if parameter.name == 'orderType' %}{{ parameter.name | caseCamel ~ '.ToString()'}}{% elseif parameter.isGlobal %}{{ parameter.name | caseUcfirst | escapeKeyword }}{% else %}{{ parameter.name | caseCamel | escapeKeyword }}{% endif %} | ||
{% endmacro %} | ||
{% macro methodNeedsSecurityParameters(method) %} | ||
{% if (method.type == "webAuth" or method.type == "location") and method.auth|length > 0 %}{{ true }}{% else %}{{false}}{% endif %} | ||
{% endmacro %} | ||
{% macro resultType(namespace, method) %} | ||
{% if method.type == "webAuth" %}bool{% elseif method.type == "location" %}byte[]{% elseif not method.responseModel or method.responseModel == 'any' %}object{% else %}Models.{{method.responseModel | caseUcfirst | overrideIdentifier }}{% endif %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
using {{ spec.title | caseUcfirst }}; | ||
using {{ spec.title | caseUcfirst }}.Models; | ||
|
||
Client client = new Client(); | ||
|
||
Client client = new Client() | ||
{% if method.auth|length > 0 %} | ||
client | ||
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint | ||
{% for node in method.auth %} | ||
{% for key,header in node|keys %} | ||
.Set{{header | caseUcfirst}}("{{node[header]["x-appwrite"]["demo"]}}") // {{node[header].description}} | ||
{% endfor %} | ||
{% endfor %}; | ||
.Set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo']}}"){% if loop.last %};{% endif %} // {{node[header].description}} | ||
{% endfor %}{% endfor %}{% endif %} | ||
|
||
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = new {{ service.name | caseUcfirst }}(client); | ||
|
||
{% endif %} | ||
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = new {{ service.name | caseUcfirst }}(client{% if service.globalParams | length %}{% for parameter in service.globalParams %}, {{ parameter | paramExample }}{% endfor %}{% endif %}); | ||
{% if method.type == 'location' %}byte[]{% else %}{{ method.responseModel | caseUcfirst | overrideIdentifier }}{% endif %} result = await {{ service.name | caseCamel }}.{{ method.name | caseUcfirst }}({% if method.parameters.all | length == 0 %});{% endif %} | ||
{% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %},{% endif %} | ||
|
||
{% if method.type == 'location' %}string{% else %}HttpResponseMessage{% endif %} result = await {{ service.name | caseCamel }}.{{ method.name | caseUcfirst }}({% for parameter in method.parameters.all %}{% if parameter.required %}{% if not loop.first %}, {% endif %}{{ parameter | paramExample }}{% endif %}{% endfor %}); | ||
{{ parameter.name }}: {{ parameter | paramExample }}{% endif %}{% endfor %}{% if method.parameters.all | length > 0 %});{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.