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

handlebars.htmlDocs2.sample_js.mustache Maven / Gradle / Ivy

There is a newer version: 1.0.54
Show newest version
var {{{jsModuleName}}} = require('{{{jsProjectName}}}');
{{#hasAuthMethods}}
var defaultClient = {{{jsModuleName}}}.ApiClient.instance;
{{#authMethods}}{{#is this 'basic'}}
// Configure HTTP basic authorization: {{{name}}}
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
{{{name}}}.username = 'YOUR USERNAME'
{{{name}}}.password = 'YOUR PASSWORD'{{/is}}{{#is this 'api-key'}}
// Configure API key authorization: {{{name}}}
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
{{{name}}}.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/is}}{{#is this 'oauth'}}
// Configure OAuth2 access token for authorization: {{{name}}}
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/is}}
{{/authMethods}}
{{/hasAuthMethods}}

var api = new {{{jsModuleName}}}.{{{classname}}}(){{#hasParams}}
{{#vendorExtensions.x-codegen-hasRequiredParams}}{{#parameters}}{{#required}}
var {{{paramName}}} = {{{example}}}; // {{braces "left" 2}}{{&dataType}}{{braces "right" 2}} {{{unescapedDescription}}}
{{/required}}{{/parameters}}{{/vendorExtensions.x-codegen-hasRequiredParams}}{{#hasOptionalParams}}
var opts = { {{#parameters}}{{^required}}
  '{{{paramName}}}': {{{example}}}{{#vendorExtensions.x-codegen-hasMoreOptional}},{{/vendorExtensions.x-codegen-hasMoreOptional}} // {{braces "left" 2}}{{&dataType}}{{braces "right" 2}} {{{unescapedDescription}}}{{/required}}{{/parameters}}
};{{/hasOptionalParams}}{{/hasParams}}
{{#usePromises}}
api.{{{operationId}}}({{#parameters}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/parameters}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}).then(function({{#returnType}}data{{/returnType}}) {
  {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}}
}, function(error) {
  console.error(error);
});

{{/usePromises}}{{^usePromises}}
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}}
  }
};
api.{{{operationId}}}({{#parameters}}{{#required}}{{{paramName}}}{{#vendorExtensions.x-codegen-hasMoreRequired}}, {{/vendorExtensions.x-codegen-hasMoreRequired}}{{/required}}{{/parameters}}{{#hasOptionalParams}}{{#vendorExtensions.x-codegen-hasRequiredParams}}, {{/vendorExtensions.x-codegen-hasRequiredParams}}opts{{/hasOptionalParams}}{{#hasParams}}, {{/hasParams}}callback);
{{/usePromises}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy