Skip to content

Commit

Permalink
chore: update template to use custom return types (#195)
Browse files Browse the repository at this point in the history
PR: #195
  • Loading branch information
OmarAlJarrah authored Oct 15, 2024
1 parent bdcc50c commit b839970
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
* @throws ExpediaGroupApi{{.}}Exception
{{/dataTypes}}
{{/exceptionDataTypes}}
* @return a [Response] object with a body of type {{{returnType}}}{{^returnType}}Nothing{{/returnType}}
* @return a [Response] object with a body of type {{#customReturnType}}{{{returnType}}}{{/customReturnType}}{{^returnType}}Nothing{{/returnType}}
*/
fun execute(operation: {{operationIdCamelCase}}Operation) : {{#returnType}}Response<{{{returnType}}}>{{/returnType}}{{^returnType}}EmptyResponse{{/returnType}} {
{{#returnType}}
fun execute(operation: {{operationIdCamelCase}}Operation) : {{#customReturnType}}Response<{{{returnType}}}>{{/customReturnType}}{{^returnType}}EmptyResponse{{/returnType}} {
{{#customReturnType}}
return execute<{{#bodyParam}}{{dataType}}{{/bodyParam}}{{^hasBodyParam}}Nothing{{/hasBodyParam}}, {{{returnType}}}>(operation)
{{/returnType}}
{{/customReturnType}}
{{^returnType}}
return executeWithEmptyResponse<{{#bodyParam}}{{dataType}}{{/bodyParam}}{{^hasBodyParam}}Nothing{{/hasBodyParam}}>(operation)
{{/returnType}}
Expand All @@ -133,18 +133,18 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
* @throws ExpediaGroupApi{{.}}Exception
{{/dataTypes}}
{{/exceptionDataTypes}}
* @return a [CompletableFuture<Response>] object with a body of type {{{returnType}}}{{^returnType}}Nothing{{/returnType}}
* @return a [CompletableFuture<Response>] object with a body of type {{#customReturnType}}{{{returnType}}}{{/customReturnType}}{{^returnType}}Nothing{{/returnType}}
*/
fun executeAsync(operation: {{operationIdCamelCase}}Operation) : CompletableFuture<{{#returnType}}Response<{{{returnType}}}>{{/returnType}}{{^returnType}}EmptyResponse{{/returnType}}> {
{{#returnType}}
fun executeAsync(operation: {{operationIdCamelCase}}Operation) : CompletableFuture<{{#customReturnType}}Response<{{{returnType}}}>{{/customReturnType}}{{^returnType}}EmptyResponse{{/returnType}}> {
{{#customReturnType}}
return executeAsync<{{#bodyParam}}{{dataType}}{{/bodyParam}}{{^hasBodyParam}}Nothing{{/hasBodyParam}}, {{{returnType}}}>(operation)
{{/returnType}}
{{/customReturnType}}
{{^returnType}}
return executeAsyncWithEmptyResponse<{{#bodyParam}}{{dataType}}{{/bodyParam}}{{^hasBodyParam}}Nothing{{/hasBodyParam}}>(operation)
{{/returnType}}
}

private suspend {{^isKotlin}}inline {{/isKotlin}}fun {{^isKotlin}}k{{/isKotlin}}{{operationId}}WithResponse({{>client/apiParamsDecleration}}): {{#returnType}}Response<{{{returnType}}}>{{/returnType}}{{^returnType}}Response<Nothing>{{/returnType}} {
private suspend {{^isKotlin}}inline {{/isKotlin}}fun {{^isKotlin}}k{{/isKotlin}}{{operationId}}WithResponse({{>client/apiParamsDecleration}}): {{#customReturnType}}Response<{{{returnType}}}>{{/customReturnType}}{{^returnType}}Response<Nothing>{{/returnType}} {
{{#hasNonBodyParams}}
val params = {{operationIdCamelCase}}OperationParams(
{{#nonBodyParams}}
Expand Down Expand Up @@ -179,7 +179,7 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
* @throws ExpediaGroupApi{{.}}Exception
{{/dataTypes}}
{{/exceptionDataTypes}}
* @return {{{returnType}}}{{^returnType}}Nothing{{/returnType}}
* @return {{#customReturnType}}{{{returnType}}}{{/customReturnType}}{{^returnType}}Nothing{{/returnType}}
*/
@Throws(
{{#exceptionDataTypes}}
Expand All @@ -191,7 +191,7 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
)
@JvmOverloads
@Deprecated("Use execute method instead", ReplaceWith("execute(operation: {{operationIdCamelCase}}Operation)"))
fun {{operationId}}({{>client/apiParamsDecleration}}) : {{{returnType}}}{{^returnType}}Nothing{{/returnType}} {
fun {{operationId}}({{>client/apiParamsDecleration}}) : {{#customReturnType}}{{{returnType}}}{{/customReturnType}}{{^returnType}}Nothing{{/returnType}} {
return {{operationId}}WithResponse({{>client/apiParamsPassed}}).data
}

Expand All @@ -206,7 +206,7 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
* @throws ExpediaGroupApi{{.}}Exception
{{/dataTypes}}
{{/exceptionDataTypes}}
* @return a [Response] object with a body of type {{{returnType}}}{{^returnType}}Nothing{{/returnType}}
* @return a [Response] object with a body of type {{#customReturnType}}{{{returnType}}}{{/customReturnType}}{{^returnType}}Nothing{{/returnType}}
*/
@Throws(
{{#exceptionDataTypes}}
Expand All @@ -218,7 +218,7 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
)
@JvmOverloads
@Deprecated("Use execute method instead", ReplaceWith("execute(operation: {{operationIdCamelCase}}Operation)"))
fun {{operationId}}WithResponse({{>client/apiParamsDecleration}}) : {{#returnType}}Response<{{{returnType}}}>{{/returnType}}{{^returnType}}Response<Nothing>{{/returnType}} {
fun {{operationId}}WithResponse({{>client/apiParamsDecleration}}) : {{#customReturnType}}Response<{{{returnType}}}>{{/customReturnType}}{{^returnType}}Response<Nothing>{{/returnType}} {
try {
return GlobalScope.future(Dispatchers.IO) {
k{{operationId}}WithResponse({{>client/apiParamsPassed}})
Expand Down

0 comments on commit b839970

Please sign in to comment.