package {{package}};

import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiClient;
import {{invokerPackage}}.Configuration;
import {{invokerPackage}}.Pair;

import javax.ws.rs.core.GenericType;

{{#imports}}import {{import}};
{{/imports}}

{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}

import com.fasterxml.jackson.databind.JsonNode;

{{>generatedAnnotation}}
{{#operations}}
public class {{classname}} {
  private ApiClient apiClient;

  public {{classname}}() {
    this(Configuration.getDefaultApiClient());
  }

  public {{classname}}(ApiClient apiClient) {
    this.apiClient = apiClient;
  }

  public ApiClient getApiClient() {
    return apiClient;
  }

  public void setApiClient(ApiClient apiClient) {
    this.apiClient = apiClient;
  }

  {{#operation}}
  /**
   * {{summary}}
   * {{notes}}{{#allParams}}
   * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}}
   * @return a {@code {{{returnType}}}}{{/returnType}}
   * @throws ApiException if fails to make API call
   {{#isDeprecated}}
   * @deprecated
   {{/isDeprecated}}
   {{#externalDocs}}
   * {{description}}
   * @see <a href="{{url}}">{{summary}} Documentation</a>
   {{/externalDocs}}
   */
  {{#isDeprecated}}
  @Deprecated
  {{/isDeprecated}}
  public JsonNode {{operationId}}({{#allParams}}JsonNode {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
    Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
    {{#allParams}}{{#required}}
    // verify the required parameter '{{paramName}}' is set
    if ({{paramName}} == null) {
      throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{operationId}}");
    }
    {{/required}}{{/allParams}}
    // create path and map variables
    String localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
      .replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString({{{paramName}}}.asText(""))){{/pathParams}};

    // query params
    {{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
    {{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();
    {{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
    {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();

    {{#queryParams}}if ({{paramName}} != null)
       localVarQueryParams.addAll(apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}.asText("")));
    {{/queryParams}}

    {{#headerParams}}if ({{paramName}} != null)
      localVarHeaderParams.put("{{baseName}}", {{paramName}}.asText(""));
    {{/headerParams}}

    {{#cookieParams}}if ({{paramName}} != null)
      localVarCookieParams.put("{{baseName}}", {{paramName}}.asText("")));
    {{/cookieParams}}

    {{#formParams}}if ({{paramName}} != null)
      localVarFormParams.put("{{baseName}}", {{paramName}}.asText(""));
    {{/formParams}}

    final String[] localVarAccepts = {
      {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {
      {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };

    GenericType<JsonNode> localVarReturnType = new GenericType<JsonNode>() {};
    return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  }
  {{/operation}}
}
{{/operations}}

