#!/usr/bin/env python
"""
{{classname}}.py
Copyright 2015 SmartBear Software

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
"""
import sys
import os

from .models import *


{{#operations}}
class {{classname}}(object):

    def __init__(self, apiClient):
      self.apiClient = apiClient

    {{newline}}
    {{#operation}}
    def {{nickname}}(self, {{#requiredParams}}{{paramName}}{{#defaultValue}} = None{{/defaultValue}}, {{/requiredParams}}**kwargs):
        """{{{summary}}}
        {{{notes}}}

        Args:
            {{#allParams}}{{paramName}}, {{dataType}}: {{{description}}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
            {{/allParams}}

        Returns: {{returnType}}
        """

        allParams = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}]

        params = locals()
        for (key, val) in params['kwargs'].items():
            if key not in allParams:
                raise TypeError("Got an unexpected keyword argument '%s' to method {{nickname}}" % key)
            params[key] = val
        del params['kwargs']

        resourcePath = '{{path}}'
        resourcePath = resourcePath.replace('{format}', 'json')
        method = '{{httpMethod}}'

        queryParams = {}
        headerParams = {}

        {{#queryParams}}
        if ('{{paramName}}' in params):
            queryParams['{{paramName}}'] = self.apiClient.toPathValue(params['{{paramName}}'])
        {{/queryParams}}

        {{#headerParams}}
        if ('{{paramName}}' in params):
            headerParams['{{paramName}}'] = params['{{paramName}}']
        {{/headerParams}}

        {{#pathParams}}
        if ('{{paramName}}' in params):
            replacement = str(self.apiClient.toPathValue(params['{{paramName}}']))
            resourcePath = resourcePath.replace('{' + '{{baseName}}' + '}',
                                                replacement)
        {{/pathParams}}

        postData = (params['body'] if 'body' in params else None)

        response = self.apiClient.callAPI(resourcePath, method, queryParams,
                                          postData, headerParams)

        {{#returnType}}
        if not response:
            return None

        responseObject = self.apiClient.deserialize(response, '{{returnType}}')
        return responseObject
        {{/returnType}}
        {{newline}}
        {{newline}}
    {{/operation}}
{{newline}}
{{/operations}}
{{newline}}
