mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
* PW-7514: Update models * PW-7514: Switch to JAR based installation * PW-7514: Default API template * PW-7514: Customize API template * PW-7514: Serialize request * PW-7514: Query string * PW-7514: Fix version patch * PW-7514: Client generated * PW-7514: Export class by default * PW-7514: Make path and body params required * PW-7514: Dynamic service name * PW-7514: Link all classes into one parent * PW-7514: Dynamic method names * PW-7514: Fix merge issues * PW-7514: Generate using latest specs Co-authored-by: jillingk <93914435+jillingk@users.noreply.github.com>
44 lines
2.1 KiB
Plaintext
44 lines
2.1 KiB
Plaintext
{{>licenseInfo}}
|
|
|
|
import getJsonResponse from "../../helpers/getJsonResponse";
|
|
import Service from "../../service";
|
|
/* tslint:disable:no-unused-locals */
|
|
{{#imports}}
|
|
import { {{classname}} } from '../../typings/{{serviceName}}/models';
|
|
{{/imports}}
|
|
import { IRequest } from "../../typings/requestOptions";
|
|
import {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}Resource from "../resource/{{serviceName}}/{{serviceName}}Resource";
|
|
import { ObjectSerializer } from "../../typings/{{serviceName}}/models";
|
|
|
|
{{#operations}}
|
|
|
|
export default class {{classname}} extends Service {
|
|
{{#operation}}
|
|
/**
|
|
{{#summary}}
|
|
* @summary {{&summary}}
|
|
{{/summary}}
|
|
{{#allParams}}
|
|
* @param {{paramName}} {{description}}
|
|
{{/allParams}}
|
|
*/
|
|
public async {{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}({{#pathParams}}{{paramName}}: {{{dataType}}}, {{/pathParams}}{{#bodyParams}}{{paramName}}: {{{dataType}}}, {{/bodyParams}}requestOptions?: IRequest.Options): Promise<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
|
const localVarPath = "{{{path}}}"{{#pathParams}}
|
|
.replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
|
const resource = new {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}Resource(this, localVarPath);
|
|
{{#bodyParam}}
|
|
const request: {{{dataType}}} = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}");
|
|
{{/bodyParam}}
|
|
{{#returnType}}const response = {{/returnType}}await getJsonResponse<{{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{^bodyParam}}string{{/bodyParam}}, {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}>(
|
|
resource,
|
|
{{#bodyParam}}request{{/bodyParam}}{{^bodyParam}}""{{/bodyParam}},
|
|
{ ...requestOptions, method: "{{httpMethod}}" }
|
|
);
|
|
{{#returnType}}
|
|
return ObjectSerializer.deserialize(response, "{{{.}}}");
|
|
{{/returnType}}
|
|
}
|
|
{{/operation}}
|
|
}
|
|
{{/operations}}
|