handlebars.htmlDocs2.sample_perl.mustache Maven / Gradle / Ivy
use Data::Dumper;
use {{{perlModuleName}}}::Configuration;
use {{perlModuleName}}::{{classname}};
{{#hasAuthMethods}}{{#authMethods}}{{#is this 'basic'}}
# Configure HTTP basic authorization: {{{name}}}
${{{perlModuleName}}}::Configuration::username = 'YOUR_USERNAME';
${{{perlModuleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/is}}{{#is this 'api-key'}}
# Configure API key authorization: {{{name}}}
${{{perlModuleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#${{{perlModuleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/is}}{{#is this 'oauth'}}
# Configure OAuth2 access token for authorization: {{{name}}}
${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/is}}{{/authMethods}}
{{/hasAuthMethods}}
my $api_instance = {{perlModuleName}}::{{classname}}->new();
{{#parameters}}my ${{paramName}} = {{#is this 'list-container'}}[{{/is}}{{#is this 'body-param'}}{{{perlModuleName}}}::Object::{{dataType}}->new(){{/is}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#is this 'list-container'}}]{{/is}}; # {{{dataType}}} | {{{unescapedDescription}}}
{{/parameters}}
eval {
{{#returnType}}my $result = {{/returnType}}$api_instance->{{{operationId}}}({{#parameters}}{{paramName}} => ${{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}});{{#returnType}}
print Dumper($result);{{/returnType}}
};
if ($@) {
warn "Exception when calling {{classname}}->{{operationId}}: $@\n";
}