update indentation, remove export

This commit is contained in:
William Cheng 2015-06-18 02:40:15 +08:00
parent 82baa7ce4b
commit 64b46c2e15
4 changed files with 276 additions and 281 deletions

View File

@ -22,14 +22,14 @@ use WWW::{{moduleName}}::Configuration;
sub new sub new
{ {
my $class = shift; my $class = shift;
my (%args) = ( my (%args) = (
'ua' => LWP::UserAgent->new, 'ua' => LWP::UserAgent->new,
'base_url' => '{{basePath}}', 'base_url' => '{{basePath}}',
@_ @_
); );
return bless \%args, $class; return bless \%args, $class;
} }
# Set the user agent of the API client # Set the user agent of the API client
@ -37,8 +37,8 @@ sub new
# @param string $user_agent The user agent of the API client # @param string $user_agent The user agent of the API client
# #
sub set_user_agent { sub set_user_agent {
my ($self, $user_agent) = @_; my ($self, $user_agent) = @_;
$self->{http_user_agent}= $user_agent; $self->{http_user_agent}= $user_agent;
} }
# Set timeout # Set timeout
@ -46,11 +46,11 @@ sub set_user_agent {
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] # @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
# #
sub set_timeout { sub set_timeout {
my ($self, $seconds) = @_; my ($self, $seconds) = @_;
if (!looks_like_number($seconds)) { if (!looks_like_number($seconds)) {
croak('Timeout variable must be numeric.'); croak('Timeout variable must be numeric.');
} }
$self->{http_timeout} = $seconds; $self->{http_timeout} = $seconds;
} }
# make the HTTP request # make the HTTP request
@ -61,71 +61,71 @@ sub set_timeout {
# @param array $headerParams parameters to be place in request header # @param array $headerParams parameters to be place in request header
# @return mixed # @return mixed
sub call_api { sub call_api {
my $self = shift; my $self = shift;
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_; my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
# update parameters based on authentication settings # update parameters based on authentication settings
$self->update_params_for_auth($header_params, $query_params, $auth_settings); $self->update_params_for_auth($header_params, $query_params, $auth_settings);
my $_url = $self->{base_url} . $resource_path; my $_url = $self->{base_url} . $resource_path;
# build query # build query
if (%$query_params) { if (%$query_params) {
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify }); $_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
} }
# body data # body data
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string $body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
my $_body_data = %$post_params ? $post_params : $body_data; my $_body_data = %$post_params ? $post_params : $body_data;
# Make the HTTP request # Make the HTTP request
my $_request; my $_request;
if ($method eq 'POST') { if ($method eq 'POST') {
# multipart # multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ? $header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'}; 'form-data' : $header_params->{'Content-Type'};
$_request = POST($_url, %$header_params, Content => $_body_data); $_request = POST($_url, %$header_params, Content => $_body_data);
} }
elsif ($method eq 'PUT') { elsif ($method eq 'PUT') {
# multipart # multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ? $header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'}; 'form-data' : $header_params->{'Content-Type'};
$_request = PUT($_url, %$header_params, Content => $_body_data); $_request = PUT($_url, %$header_params, Content => $_body_data);
} }
elsif ($method eq 'GET') { elsif ($method eq 'GET') {
my $headers = HTTP::Headers->new(%$header_params); my $headers = HTTP::Headers->new(%$header_params);
$_request = GET($_url, %$header_params); $_request = GET($_url, %$header_params);
} }
elsif ($method eq 'HEAD') { elsif ($method eq 'HEAD') {
my $headers = HTTP::Headers->new(%$header_params); my $headers = HTTP::Headers->new(%$header_params);
$_request = HEAD($_url,%$header_params); $_request = HEAD($_url,%$header_params);
} }
elsif ($method eq 'DELETE') { #TODO support form data elsif ($method eq 'DELETE') { #TODO support form data
my $headers = HTTP::Headers->new(%$header_params); my $headers = HTTP::Headers->new(%$header_params);
$_request = DELETE($_url, %$headers); $_request = DELETE($_url, %$headers);
} }
elsif ($method eq 'PATCH') { #TODO elsif ($method eq 'PATCH') { #TODO
} }
else { else {
} }
$self->{ua}->timeout($self->{http_timeout} || $WWW::{{moduleName}}::Configuration::http_timeout); $self->{ua}->timeout($self->{http_timeout} || $WWW::{{moduleName}}::Configuration::http_timeout);
$self->{ua}->agent($self->{http_user_agent} || $WWW::{{moduleName}}::Configuration::http_user_agent); $self->{ua}->agent($self->{http_user_agent} || $WWW::{{moduleName}}::Configuration::http_user_agent);
my $_response = $self->{ua}->request($_request);
unless ($_response->is_success) {
croak("API Exception(".$_response->code."): ".$_response->message);
}
return $_response->content;
my $_response = $self->{ua}->request($_request);
unless ($_response->is_success) {
croak("API Exception(".$_response->code."): ".$_response->message);
}
return $_response->content;
} }
# Take value and turn it into a string suitable for inclusion in # Take value and turn it into a string suitable for inclusion in
@ -180,13 +180,13 @@ sub to_form_value {
# @param string $value the value of the parameter # @param string $value the value of the parameter
# @return string the header string # @return string the header string
sub to_string { sub to_string {
my ($self, $value) = @_; my ($self, $value) = @_;
if (ref($value) eq "DateTime") { # datetime in ISO8601 format if (ref($value) eq "DateTime") { # datetime in ISO8601 format
return $value->datetime(); return $value->datetime();
} }
else { else {
return $value; return $value;
} }
} }
# Deserialize a JSON string into an object # Deserialize a JSON string into an object
@ -196,55 +196,55 @@ sub to_string {
# @return object an instance of $class # @return object an instance of $class
sub deserialize sub deserialize
{ {
my ($self, $class, $data) = @_; my ($self, $class, $data) = @_;
$log->debugf("deserializing %s for %s", $data, $class); $log->debugf("deserializing %s for %s", $data, $class);
if (not defined $data) { if (not defined $data) {
return undef; return undef;
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash } elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
if ($class =~ /^HASH\[(.*),(.*)\]$/) { if ($class =~ /^HASH\[(.*),(.*)\]$/) {
my ($key_type, $type) = ($1, $2); my ($key_type, $type) = ($1, $2);
my %hash; my %hash;
my $decoded_data = decode_json $data; my $decoded_data = decode_json $data;
foreach my $key (keys %$decoded_data) { foreach my $key (keys %$decoded_data) {
if (ref $decoded_data->{$key} eq 'HASH') { if (ref $decoded_data->{$key} eq 'HASH') {
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key}); $hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
} else {
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
}
}
return \%hash;
} else { } else {
$hash{$key} = $self->deserialize($type, $decoded_data->{$key}); #TODO log error
}
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
return $data if $data eq '[]'; # return if empty array
my $_sub_class = substr($class, 6, -1);
my $_json_data = decode_json $data;
my @_values = ();
foreach my $_value (@$_json_data) {
if (ref $_value eq 'ARRAY') {
push @_values, $self->deserialize($_sub_class, encode_json $_value);
} else {
push @_values, $self->deserialize($_sub_class, $_value);
}
}
return \@_values;
} elsif ($class eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
return $data;
} else { # model
my $_instance = use_module("WWW::{{moduleName}}::Object::$class")->new;
if (ref $data eq "HASH") {
return $_instance->from_hash($data);
} else { # string, need to json decode first
return $_instance->from_hash(decode_json $data);
} }
}
return \%hash;
} else {
#TODO log error
} }
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
return $data if $data eq '[]'; # return if empty array
my $_sub_class = substr($class, 6, -1);
my $_json_data = decode_json $data;
my @_values = ();
foreach my $_value (@$_json_data) {
if (ref $_value eq 'ARRAY') {
push @_values, $self->deserialize($_sub_class, encode_json $_value);
} else {
push @_values, $self->deserialize($_sub_class, $_value);
}
}
return \@_values;
} elsif ($class eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
return $data;
} else { # model
my $_instance = use_module("WWW::{{moduleName}}::Object::$class")->new;
if (ref $data eq "HASH") {
return $_instance->from_hash($data);
} else { # string, need to json decode first
return $_instance->from_hash(decode_json $data);
}
}
} }
# return 'Accept' based on an array of accept provided # return 'Accept' based on an array of accept provided
@ -252,16 +252,16 @@ sub deserialize
# @return String Accept (e.g. application/json) # @return String Accept (e.g. application/json)
sub select_header_accept sub select_header_accept
{ {
my ($self, @header) = @_; my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) { if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return undef; return undef;
} elsif (grep(/^application\/json$/i, @header)) { } elsif (grep(/^application\/json$/i, @header)) {
return 'application/json'; return 'application/json';
} else { } else {
return join(',', @header); return join(',', @header);
} }
} }
# return the content type based on an array of content-type provided # return the content type based on an array of content-type provided
@ -269,16 +269,16 @@ sub select_header_accept
# @return String Content-Type (e.g. application/json) # @return String Content-Type (e.g. application/json)
sub select_header_content_type sub select_header_content_type
{ {
my ($self, @header) = @_; my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) { if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return 'application/json'; # default to application/json return 'application/json'; # default to application/json
} elsif (grep(/^application\/json$/i, @header)) { } elsif (grep(/^application\/json$/i, @header)) {
return 'application/json'; return 'application/json';
} else { } else {
return join(',', @header); return join(',', @header);
} }
} }
# Get API key (with prefix if set) # Get API key (with prefix if set)
@ -288,9 +288,9 @@ sub get_api_key_with_prefix
{ {
my ($self, $api_key) = @_; my ($self, $api_key) = @_;
if ($WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}) { if ($WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}) {
return $WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}." ".$WWW::{{moduleName}}::Configuration::api_key->{$api_key}; return $WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}." ".$WWW::{{moduleName}}::Configuration::api_key->{$api_key};
} else { } else {
return $WWW::{{moduleName}}::Configuration::api_key->{$api_key}; return $WWW::{{moduleName}}::Configuration::api_key->{$api_key};
} }
} }
@ -300,24 +300,24 @@ sub get_api_key_with_prefix
# @param array $queryParams query parameters (by ref) # @param array $queryParams query parameters (by ref)
# @param array $authSettings array of authentication scheme (e.g ['api_key']) # @param array $authSettings array of authentication scheme (e.g ['api_key'])
sub update_params_for_auth { sub update_params_for_auth {
my ($self, $header_params, $query_params, $auth_settings) = @_; my ($self, $header_params, $query_params, $auth_settings) = @_;
return if (!defined($auth_settings) || scalar(@$auth_settings) == 0); return if (!defined($auth_settings) || scalar(@$auth_settings) == 0);
# one endpoint can have more than 1 auth settings # one endpoint can have more than 1 auth settings
foreach my $auth (@$auth_settings) { foreach my $auth (@$auth_settings) {
# determine which one to use # determine which one to use
if (!defined($auth)) { if (!defined($auth)) {
}
{{#authMethods}}elsif ($auth eq '{{name}}') {
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}}
{{#isOAuth}}# TODO support oauth{{/isOAuth}}
}
{{/authMethods}}
else {
# TODO show warning about security definition not found
}
} }
{{#authMethods}}elsif ($auth eq '{{name}}') {
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}}
{{#isOAuth}}# TODO support oauth{{/isOAuth}}
}
{{/authMethods}}
else {
# TODO show warning about security definition not found
}
}
} }

View File

@ -21,56 +21,56 @@ use DateTime;
# return json string # return json string
sub to_hash { sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift )); return decode_json(JSON->new->convert_blessed->encode( shift ));
} }
# used by JSON for serialization # used by JSON for serialization
sub TO_JSON { sub TO_JSON {
my $self = shift; my $self = shift;
my $_data = {}; my $_data = {};
foreach my $_key (keys $self->get_attribute_map) { foreach my $_key (keys $self->get_attribute_map) {
if (defined $self->{$_key}) { if (defined $self->{$_key}) {
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key}; $_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
}
} }
} return $_data;
return $_data;
} }
# from json string # from json string
sub from_hash { sub from_hash {
my ($self, $hash) = @_; my ($self, $hash) = @_;
# loop through attributes and use swagger_types to deserialize the data # loop through attributes and use swagger_types to deserialize the data
while ( my ($_key, $_type) = each $self->get_swagger_types ) { while ( my ($_key, $_type) = each $self->get_swagger_types ) {
if ($_type =~ /^array\[/i) { # array if ($_type =~ /^array\[/i) { # array
my $_subclass = substr($_type, 6, -1); my $_subclass = substr($_type, 6, -1);
my @_array = (); my @_array = ();
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) { foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) {
push @_array, $self->_deserialize($_subclass, $_element); push @_array, $self->_deserialize($_subclass, $_element);
} }
$self->{$_key} = \@_array; $self->{$_key} = \@_array;
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime } elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key}); $self->{$_key} = $self->_deserialize($_type, $hash->{$_key});
} else { } else {
$log->debugf("warning: %s not defined\n", $_key); $log->debugf("warning: %s not defined\n", $_key);
}
} }
}
return $self;
return $self;
} }
# deserialize non-array data # deserialize non-array data
sub _deserialize { sub _deserialize {
my ($self, $type, $data) = @_; my ($self, $type, $data) = @_;
$log->debugf("deserializing %s with %s",Dumper($data), $type); $log->debugf("deserializing %s with %s",Dumper($data), $type);
if ($type eq 'DateTime') { if ($type eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data)); return DateTime->from_epoch(epoch => str2time($data));
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
return $data; return $data;
} else { # hash(model) } else { # hash(model)
my $_instance = eval "WWW::{{moduleName}}::Object::$type->new()"; my $_instance = eval "WWW::{{moduleName}}::Object::$type->new()";
return $_instance->from_hash($data); return $_instance->from_hash($data);
} }
} }
1; 1;

View File

@ -30,12 +30,6 @@ use Log::Any qw($log);
use WWW::{{moduleName}}::ApiClient; use WWW::{{moduleName}}::ApiClient;
use WWW::{{moduleName}}::Configuration; use WWW::{{moduleName}}::Configuration;
{{#operations}}
our @EXPORT_OK = qw(
{{#operation}}{{{nickname}}}
{{/operation}}
);
sub new { sub new {
my $class = shift; my $class = shift;
my $default_api_client = $WWW::{{moduleName}}::Configuration::api_client ? $WWW::{{moduleName}}::Configuration::api_client : WWW::{{moduleName}}::ApiClient->new; my $default_api_client = $WWW::{{moduleName}}::Configuration::api_client ? $WWW::{{moduleName}}::Configuration::api_client : WWW::{{moduleName}}::ApiClient->new;
@ -52,89 +46,90 @@ sub new {
bless \%self, $class; bless \%self, $class;
} }
{{#operations}}
{{#operation}} {{#operation}}
# #
# {{{nickname}}} # {{{nickname}}}
# #
# {{{summary}}} # {{{summary}}}
# #
{{#allParams}} # @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}} {{#allParams}}# @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{/allParams}}# @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
# #
sub {{nickname}} { sub {{nickname}} {
my ($self, %args) = @_; my ($self, %args) = @_;
{{#allParams}}{{#required}} {{#allParams}}{{#required}}
# verify the required parameter '{{paramName}}' is set # verify the required parameter '{{paramName}}' is set
unless (exists $args{'{{paramName}}'}) { unless (exists $args{'{{paramName}}'}) {
croak("Missing the required parameter '{{paramName}}' when calling {{nickname}}"); croak("Missing the required parameter '{{paramName}}' when calling {{nickname}}");
} }
{{/required}}{{/allParams}} {{/required}}{{/allParams}}
# parse inputs # parse inputs
my $_resource_path = '{{path}}'; my $_resource_path = '{{path}}';
$_resource_path =~ s/{format}/json/; # default format to json $_resource_path =~ s/{format}/json/; # default format to json
my $_method = '{{httpMethod}}'; my $_method = '{{httpMethod}}';
my $query_params = {}; my $query_params = {};
my $header_params = {}; my $header_params = {};
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}); my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}});
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}); $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
{{#queryParams}}# query params {{#queryParams}}# query params
if ( exists $args{'{{paramName}}'}) { if ( exists $args{'{{paramName}}'}) {
$query_params->{'{{baseName}}'} = $self->{api_client}->to_query_value($args{'{{paramName}}'}); $query_params->{'{{baseName}}'} = $self->{api_client}->to_query_value($args{'{{paramName}}'});
}{{/queryParams}} }{{/queryParams}}
{{#headerParams}}# header params {{#headerParams}}# header params
if ( exists $args{'{{paramName}}'}) { if ( exists $args{'{{paramName}}'}) {
$header_params->{'{{baseName}}'} = $self->{api_client}->to_header_value($args{'{{paramName}}'}); $header_params->{'{{baseName}}'} = $self->{api_client}->to_header_value($args{'{{paramName}}'});
}{{/headerParams}} }{{/headerParams}}
{{#pathParams}}# path params {{#pathParams}}# path params
if ( exists $args{'{{paramName}}'}) { if ( exists $args{'{{paramName}}'}) {
my $_base_variable = "{" . "{{baseName}}" . "}"; my $_base_variable = "{" . "{{baseName}}" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'{{paramName}}'}); my $_base_value = $self->{api_client}->to_path_value($args{'{{paramName}}'});
$_resource_path =~ s/$_base_variable/$_base_value/g; $_resource_path =~ s/$_base_variable/$_base_value/g;
}{{/pathParams}} }{{/pathParams}}
{{#formParams}}# form params {{#formParams}}# form params
if ( exists $args{'{{paramName}}'} ) { if ( exists $args{'{{paramName}}'} ) {
{{#isFile}}$form_params->{'{{baseName}}'} = [] unless defined $form_params->{'{{baseName}}'}; {{#isFile}}$form_params->{'{{baseName}}'} = [] unless defined $form_params->{'{{baseName}}'};
push $form_params->{'{{baseName}}'}, $args{'{{paramName}}'}; push $form_params->{'{{baseName}}'}, $args{'{{paramName}}'};
{{/isFile}} {{/isFile}}
{{^isFile}}$form_params->{'{{baseName}}'} = $self->{api_client}->to_form_value($args{'{{paramName}}'}); {{^isFile}}$form_params->{'{{baseName}}'} = $self->{api_client}->to_form_value($args{'{{paramName}}'});
{{/isFile}} {{/isFile}}
}{{/formParams}} }{{/formParams}}
my $_body_data; my $_body_data;
{{#bodyParams}}# body params {{#bodyParams}}# body params
if ( exists $args{'{{paramName}}'}) { if ( exists $args{'{{paramName}}'}) {
$_body_data = $args{'{{paramName}}'}; $_body_data = $args{'{{paramName}}'};
}{{/bodyParams}} }{{/bodyParams}}
# authentication setting, if any # authentication setting, if any
my $auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]; my $auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
# make the API Call # make the API Call
{{#returnType}}my $response = $self->{api_client}->call_api($_resource_path, $_method, {{#returnType}}my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params, $query_params, $form_params,
$header_params, $_body_data, $auth_settings); $header_params, $_body_data, $auth_settings);
if (!$response) { if (!$response) {
return; return;
} }
my $_response_object = $self->{api_client}->deserialize('{{returnType}}', $response); my $_response_object = $self->{api_client}->deserialize('{{returnType}}', $response);
return $_response_object;{{/returnType}} return $_response_object;{{/returnType}}
{{^returnType}}$self->{api_client}->call_api($_resource_path, $_method, {{^returnType}}$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params, $query_params, $form_params,
$header_params, $_body_data, $auth_settings); $header_params, $_body_data, $auth_settings);
return; return;
{{/returnType}} {{/returnType}}
} }
{{/operation}} {{/operation}}
{{newline}} {{newline}}
{{/operations}} {{/operations}}

View File

@ -22,13 +22,13 @@ use base "WWW::{{moduleName}}::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}}, {{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
}; };
my $attribute_map = { my $attribute_map = {
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}}, {{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
}; };
# new object # new object
@ -45,12 +45,12 @@ sub new {
# get swagger type of the attribute # get swagger type of the attribute
sub get_swagger_types { sub get_swagger_types {
return $swagger_types; return $swagger_types;
} }
# get attribute mappping # get attribute mappping
sub get_attribute_map { sub get_attribute_map {
return $attribute_map; return $attribute_map;
} }
1; 1;