All Downloads are FREE. Search and download functionalities are using the official Maven repository.

apex.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
{{>licenseInfo}}
{{#operations}}
public class {{classname}} {
    {{classPrefix}}Client client;

    public {{classname}}({{classPrefix}}Client client) {
        this.client = client;
    }

    public {{classname}}() {
        this.client = new {{classPrefix}}Client();
    }

    public {{classPrefix}}Client getClient() {
        return this.client;
    }

    {{#operation}}
    /**
     * {{summary}}
     * {{notes}}
     {{#allParams}}
     * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
     {{/allParams}}
     {{#returnType}}
     * @return {{{.}}}
     {{/returnType}}
     * @throws OAS.ApiException if fails to make API call
     */
    public {{{returnType}}}{{^returnType}}void{{/returnType}} {{operationId}}({{#hasParams}}Map params{{/hasParams}}) {
    {{#allParams}}
      {{#required}}
        client.assertNotNull(params.get('{{paramName}}'), '{{paramName}}');
      {{/required}}
    {{/allParams}}
        List query = new List();
    {{#hasQueryParams}}

        // cast query params to verify their expected type
    {{/hasQueryParams}}
    {{#queryParams}}
      {{#isArray}}
        {{#isCollectionFormatMulti}}
        query.addAll(client.makeParams('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}')));
        {{/isCollectionFormatMulti}}
        {{^isCollectionFormatMulti}}
        query.addAll(client.makeParam('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}'), '{{collectionFormat}}'));
        {{/isCollectionFormatMulti}}
      {{/isArray}}
      {{^isArray}}
        query.addAll(client.makeParam('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}')));
      {{/isArray}}
      {{#-last}}

      {{/-last}}
    {{/queryParams}}
        List form = new List();
    {{#hasFormParams}}

        // cast form params to verify their expected type
    {{/hasFormParams}}
    {{#formParams}}
      {{#isArray}}
        {{#isCollectionFormatMulti}}
        form.addAll(client.makeParams('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}')));
        {{/isCollectionFormatMulti}}
        {{^isCollectionFormatMulti}}
        form.addAll(client.makeParam('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}'), '{{collectionFormat}}'));
        {{/isCollectionFormatMulti}}
      {{/isArray}}
      {{^isArray}}
        form.addAll(client.makeParam('{{baseName}}', ({{{dataType}}}) params.get('{{paramName}}')));
      {{/isArray}}
    {{/formParams}}

        {{#returnType}}return ({{{.}}}) {{/returnType}}client.invoke(
            '{{httpMethod}}', '{{path}}',{{#bodyParam}}
            ({{{dataType}}}) params.get('{{paramName}}'){{/bodyParam}}{{^bodyParam}} ''{{/bodyParam}},
            query, form,
            new Map{{#hasPathParams}}{
              {{#pathParams}}
                '{{baseName}}' => ({{{dataType}}}) params.get('{{paramName}}'){{^-last}},{{/-last}}
              {{/pathParams}}
            }{{/hasPathParams}}{{^hasPathParams}}(){{/hasPathParams}},
            new Map{{#hasHeaderParams}}{
              {{#headerParams}}
                '{{baseName}}' => ({{{dataType}}}) params.get('{{paramName}}'){{^-last}},{{/-last}}
              {{/headerParams}}
            }{{/hasHeaderParams}}{{^hasHeaderParams}}(){{/hasHeaderParams}},
          {{#hasProduces}}
            new List{ {{#produces}}'{{mediaType}}'{{^-last}}, {{/-last}}{{/produces}} },
          {{/hasProduces}}
          {{^hasProduces}}
            new List(),
          {{/hasProduces}}
          {{#hasConsumes}}
            new List{ {{#consumes}}'{{mediaType}}'{{^-last}}, {{/-last}}{{/consumes}} },
          {{/hasConsumes}}
          {{^hasConsumes}}
            new List(),
          {{/hasConsumes}}
          {{#hasAuthMethods}}
            new List { {{#authMethods}}'{{name}}'{{^-last}}, {{/-last}}{{/authMethods}} },
          {{/hasAuthMethods}}
          {{^hasAuthMethods}}
            new List(),
          {{/hasAuthMethods}}
          {{#returnType}}
            {{{.}}}.class
          {{/returnType}}
          {{^returnType}}
            null
          {{/returnType}}
        );
    }
  {{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy