/**
 * Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
 * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\  *_/ ' \" =end       
 *
 * OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
 * Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 *
 * 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.
 */

import * as querystring from "querystring";
import * as url from "url";

import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign";

interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }

const BASE_PATH = "https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r";

export interface FetchArgs {
    url: string;
    options: any; 
}

export class BaseAPI {
    basePath: string;
    fetch: FetchAPI;

    constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) {
        this.basePath = basePath;
        this.fetch = fetch;
    }
}

/**
 * Model for testing reserved words  *_/ ' \" =end \\r\\n \\n \\r
 */
export interface ModelReturn {
    /**
     * property description  *_/ ' \" =end \\r\\n \\n \\r
     */
    "return"?: number;
}



/**
 * FakeApi - fetch parameter creator
 */
export const FakeApiFetchParamCreactor = {
    /** 
     * To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     * @param test code inject * &#39; &quot; &#x3D;end rn n r To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     */
    testCodeInjectEndRnNR(params: {  test code inject * &#39; &quot; &#x3D;end rn n r?: string; }): FetchArgs {
        const baseUrl = `/fake`;
        let urlObj = url.parse(baseUrl, true);
        let fetchOptions: RequestInit = { method: "PUT" };

        let contentTypeHeader: Dictionary<string>;
        contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" };
        fetchOptions.body = querystring.stringify({ 
            "test code inject */ &#39; &quot; &#x3D;end \r\n \n \r": params.test code inject * &#39; &quot; &#x3D;end rn n r,
        });
        if (contentTypeHeader) {
            fetchOptions.headers = contentTypeHeader;
        }
        return {
            url: url.format(urlObj),
            options: fetchOptions,
        };
    },
}

/**
 * FakeApi - functional programming interface
 */
export const FakeApiFp = {
    /** 
     * To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     * @param test code inject * &#39; &quot; &#x3D;end rn n r To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     */
    testCodeInjectEndRnNR(params: { test code inject * &#39; &quot; &#x3D;end rn n r?: string;  }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
        const fetchArgs = FakeApiFetchParamCreactor.testCodeInjectEndRnNR(params);
        return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
            return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
                if (response.status >= 200 && response.status < 300) {
                    return response;
                } else {
                    throw response;
                }
            });
        };
    },
};

/**
 * FakeApi - object-oriented interface
 */
export class FakeApi extends BaseAPI {
    /** 
     * To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     * @param test code inject * &#39; &quot; &#x3D;end rn n r To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
     */
    testCodeInjectEndRnNR(params: {  test code inject * &#39; &quot; &#x3D;end rn n r?: string; }) {
        return FakeApiFp.testCodeInjectEndRnNR(params)(this.fetch, this.basePath);
    }
}

