Guest User

Untitled

a guest
Oct 19th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Swagger Petstore
  3.  * This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters.
  4.  *
  5.  * OpenAPI spec version: 1.0.0
  6.  * Contact: apiteam@swagger.io
  7.  *
  8.  * NOTE: This class is auto generated by the swagger code generator program.
  9.  * https://github.com/swagger-api/swagger-codegen.git
  10.  * Do not edit the class manually.
  11.  */
  12. /* tslint:disable:no-unused-variable member-ordering */
  13.  
  14. import { Inject, Injectable, Optional }                      from '@angular/core';
  15. import { HttpClient, HttpHeaders, HttpParams,
  16.          HttpResponse, HttpEvent }                           from '@angular/common/http';
  17. import { CustomHttpUrlEncodingCodec }                        from '../encoder';
  18.  
  19. import { Observable }                                        from 'rxjs/Observable';
  20.  
  21. import { User } from '../model/user';
  22.  
  23. import { BASE_PATH, COLLECTION_FORMATS }                     from '../variables';
  24. import { Configuration }                                     from '../configuration';
  25.  
  26.  
  27. @Injectable()
  28. export class UserService {
  29.  
  30.     protected basePath = 'https://petstore.swagger.io/v2';
  31.     public defaultHeaders = new HttpHeaders();
  32.     public configuration = new Configuration();
  33.  
  34.     constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
  35.         if (basePath) {
  36.             this.basePath = basePath;
  37.         }
  38.         if (configuration) {
  39.             this.configuration = configuration;
  40.             this.basePath = basePath || configuration.basePath || this.basePath;
  41.         }
  42.     }
  43.  
  44.     /**
  45.      * @param consumes string[] mime-types
  46.      * @return true: consumes contains 'multipart/form-data', false: otherwise
  47.      */
  48.     private canConsumeForm(consumes: string[]): boolean {
  49.         const form = 'multipart/form-data';
  50.         for (let consume of consumes) {
  51.             if (form === consume) {
  52.                 return true;
  53.             }
  54.         }
  55.         return false;
  56.     }
  57.  
  58.  
  59.     /**
  60.      * Create user
  61.      * This can only be done by the logged in user.
  62.      * @param body Created user object
  63.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  64.      * @param reportProgress flag to report request and response progress.
  65.      */
  66.     public createUser(body: User, observe?: 'body', reportProgress?: boolean): Observable<any>;
  67.     public createUser(body: User, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  68.     public createUser(body: User, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  69.     public createUser(body: User, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  70.         if (body === null || body === undefined) {
  71.             throw new Error('Required parameter body was null or undefined when calling createUser.');
  72.         }
  73.  
  74.         let headers = this.defaultHeaders;
  75.  
  76.         // to determine the Accept header
  77.         let httpHeaderAccepts: string[] = [
  78.             'application/xml',
  79.             'application/json'
  80.         ];
  81.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  82.         if (httpHeaderAcceptSelected != undefined) {
  83.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  84.         }
  85.  
  86.         // to determine the Content-Type header
  87.         let consumes: string[] = [
  88.         ];
  89.         let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes);
  90.         if (httpContentTypeSelected != undefined) {
  91.             headers = headers.set("Content-Type", httpContentTypeSelected);
  92.         }
  93.  
  94.         return this.httpClient.post<any>(`${this.basePath}/user`,
  95.             body,
  96.             {
  97.                 withCredentials: this.configuration.withCredentials,
  98.                 headers: headers,
  99.                 observe: observe,
  100.                 reportProgress: reportProgress
  101.             }
  102.         );
  103.     }
  104.  
  105.     /**
  106.      * Creates list of users with given input array
  107.      *
  108.      * @param body List of user object
  109.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  110.      * @param reportProgress flag to report request and response progress.
  111.      */
  112.     public createUsersWithArrayInput(body: Array<User>, observe?: 'body', reportProgress?: boolean): Observable<any>;
  113.     public createUsersWithArrayInput(body: Array<User>, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  114.     public createUsersWithArrayInput(body: Array<User>, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  115.     public createUsersWithArrayInput(body: Array<User>, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  116.         if (body === null || body === undefined) {
  117.             throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.');
  118.         }
  119.  
  120.         let headers = this.defaultHeaders;
  121.  
  122.         // to determine the Accept header
  123.         let httpHeaderAccepts: string[] = [
  124.             'application/xml',
  125.             'application/json'
  126.         ];
  127.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  128.         if (httpHeaderAcceptSelected != undefined) {
  129.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  130.         }
  131.  
  132.         // to determine the Content-Type header
  133.         let consumes: string[] = [
  134.         ];
  135.         let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes);
  136.         if (httpContentTypeSelected != undefined) {
  137.             headers = headers.set("Content-Type", httpContentTypeSelected);
  138.         }
  139.  
  140.         return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
  141.             body,
  142.             {
  143.                 withCredentials: this.configuration.withCredentials,
  144.                 headers: headers,
  145.                 observe: observe,
  146.                 reportProgress: reportProgress
  147.             }
  148.         );
  149.     }
  150.  
  151.     /**
  152.      * Creates list of users with given input array
  153.      *
  154.      * @param body List of user object
  155.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  156.      * @param reportProgress flag to report request and response progress.
  157.      */
  158.     public createUsersWithListInput(body: Array<User>, observe?: 'body', reportProgress?: boolean): Observable<any>;
  159.     public createUsersWithListInput(body: Array<User>, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  160.     public createUsersWithListInput(body: Array<User>, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  161.     public createUsersWithListInput(body: Array<User>, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  162.         if (body === null || body === undefined) {
  163.             throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.');
  164.         }
  165.  
  166.         let headers = this.defaultHeaders;
  167.  
  168.         // to determine the Accept header
  169.         let httpHeaderAccepts: string[] = [
  170.             'application/xml',
  171.             'application/json'
  172.         ];
  173.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  174.         if (httpHeaderAcceptSelected != undefined) {
  175.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  176.         }
  177.  
  178.         // to determine the Content-Type header
  179.         let consumes: string[] = [
  180.         ];
  181.         let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes);
  182.         if (httpContentTypeSelected != undefined) {
  183.             headers = headers.set("Content-Type", httpContentTypeSelected);
  184.         }
  185.  
  186.         return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
  187.             body,
  188.             {
  189.                 withCredentials: this.configuration.withCredentials,
  190.                 headers: headers,
  191.                 observe: observe,
  192.                 reportProgress: reportProgress
  193.             }
  194.         );
  195.     }
  196.  
  197.     /**
  198.      * Delete user
  199.      * This can only be done by the logged in user.
  200.      * @param username The name that needs to be deleted
  201.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  202.      * @param reportProgress flag to report request and response progress.
  203.      */
  204.     public deleteUser(username: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
  205.     public deleteUser(username: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  206.     public deleteUser(username: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  207.     public deleteUser(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  208.         if (username === null || username === undefined) {
  209.             throw new Error('Required parameter username was null or undefined when calling deleteUser.');
  210.         }
  211.  
  212.         let headers = this.defaultHeaders;
  213.  
  214.         // to determine the Accept header
  215.         let httpHeaderAccepts: string[] = [
  216.             'application/xml',
  217.             'application/json'
  218.         ];
  219.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  220.         if (httpHeaderAcceptSelected != undefined) {
  221.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  222.         }
  223.  
  224.         // to determine the Content-Type header
  225.         let consumes: string[] = [
  226.         ];
  227.  
  228.         return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
  229.             {
  230.                 withCredentials: this.configuration.withCredentials,
  231.                 headers: headers,
  232.                 observe: observe,
  233.                 reportProgress: reportProgress
  234.             }
  235.         );
  236.     }
  237.  
  238.     /**
  239.      * Get user by user name
  240.      *
  241.      * @param username The name that needs to be fetched. Use user1 for testing.
  242.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  243.      * @param reportProgress flag to report request and response progress.
  244.      */
  245.     public getUserByName(username: string, observe?: 'body', reportProgress?: boolean): Observable<User>;
  246.     public getUserByName(username: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<User>>;
  247.     public getUserByName(username: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<User>>;
  248.     public getUserByName(username: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  249.         if (username === null || username === undefined) {
  250.             throw new Error('Required parameter username was null or undefined when calling getUserByName.');
  251.         }
  252.  
  253.         let headers = this.defaultHeaders;
  254.  
  255.         // to determine the Accept header
  256.         let httpHeaderAccepts: string[] = [
  257.             'application/xml',
  258.             'application/json'
  259.         ];
  260.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  261.         if (httpHeaderAcceptSelected != undefined) {
  262.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  263.         }
  264.  
  265.         // to determine the Content-Type header
  266.         let consumes: string[] = [
  267.         ];
  268.  
  269.         return this.httpClient.get<User>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
  270.             {
  271.                 withCredentials: this.configuration.withCredentials,
  272.                 headers: headers,
  273.                 observe: observe,
  274.                 reportProgress: reportProgress
  275.             }
  276.         );
  277.     }
  278.  
  279.     /**
  280.      * Logs user into the system
  281.      *
  282.      * @param username The user name for login
  283.      * @param password The password for login in clear text
  284.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  285.      * @param reportProgress flag to report request and response progress.
  286.      */
  287.     public loginUser(username: string, password: string, observe?: 'body', reportProgress?: boolean): Observable<string>;
  288.     public loginUser(username: string, password: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<string>>;
  289.     public loginUser(username: string, password: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<string>>;
  290.     public loginUser(username: string, password: string, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  291.         if (username === null || username === undefined) {
  292.             throw new Error('Required parameter username was null or undefined when calling loginUser.');
  293.         }
  294.         if (password === null || password === undefined) {
  295.             throw new Error('Required parameter password was null or undefined when calling loginUser.');
  296.         }
  297.  
  298.         let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
  299.         if (username !== undefined) {
  300.             queryParameters = queryParameters.set('username', <any>username);
  301.         }
  302.         if (password !== undefined) {
  303.             queryParameters = queryParameters.set('password', <any>password);
  304.         }
  305.  
  306.         let headers = this.defaultHeaders;
  307.  
  308.         // to determine the Accept header
  309.         let httpHeaderAccepts: string[] = [
  310.             'application/xml',
  311.             'application/json'
  312.         ];
  313.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  314.         if (httpHeaderAcceptSelected != undefined) {
  315.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  316.         }
  317.  
  318.         // to determine the Content-Type header
  319.         let consumes: string[] = [
  320.         ];
  321.  
  322.         return this.httpClient.get<string>(`${this.basePath}/user/login`,
  323.             {
  324.                 params: queryParameters,
  325.                 withCredentials: this.configuration.withCredentials,
  326.                 headers: headers,
  327.                 observe: observe,
  328.                 reportProgress: reportProgress
  329.             }
  330.         );
  331.     }
  332.  
  333.     /**
  334.      * Logs out current logged in user session
  335.      *
  336.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  337.      * @param reportProgress flag to report request and response progress.
  338.      */
  339.     public logoutUser(observe?: 'body', reportProgress?: boolean): Observable<any>;
  340.     public logoutUser(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  341.     public logoutUser(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  342.     public logoutUser(observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  343.  
  344.         let headers = this.defaultHeaders;
  345.  
  346.         // to determine the Accept header
  347.         let httpHeaderAccepts: string[] = [
  348.             'application/xml',
  349.             'application/json'
  350.         ];
  351.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  352.         if (httpHeaderAcceptSelected != undefined) {
  353.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  354.         }
  355.  
  356.         // to determine the Content-Type header
  357.         let consumes: string[] = [
  358.         ];
  359.  
  360.         return this.httpClient.get<any>(`${this.basePath}/user/logout`,
  361.             {
  362.                 withCredentials: this.configuration.withCredentials,
  363.                 headers: headers,
  364.                 observe: observe,
  365.                 reportProgress: reportProgress
  366.             }
  367.         );
  368.     }
  369.  
  370.     /**
  371.      * Updated user
  372.      * This can only be done by the logged in user.
  373.      * @param username name that need to be updated
  374.      * @param body Updated user object
  375.      * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
  376.      * @param reportProgress flag to report request and response progress.
  377.      */
  378.     public updateUser(username: string, body: User, observe?: 'body', reportProgress?: boolean): Observable<any>;
  379.     public updateUser(username: string, body: User, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
  380.     public updateUser(username: string, body: User, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
  381.     public updateUser(username: string, body: User, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
  382.         if (username === null || username === undefined) {
  383.             throw new Error('Required parameter username was null or undefined when calling updateUser.');
  384.         }
  385.         if (body === null || body === undefined) {
  386.             throw new Error('Required parameter body was null or undefined when calling updateUser.');
  387.         }
  388.  
  389.         let headers = this.defaultHeaders;
  390.  
  391.         // to determine the Accept header
  392.         let httpHeaderAccepts: string[] = [
  393.             'application/xml',
  394.             'application/json'
  395.         ];
  396.         let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
  397.         if (httpHeaderAcceptSelected != undefined) {
  398.             headers = headers.set("Accept", httpHeaderAcceptSelected);
  399.         }
  400.  
  401.         // to determine the Content-Type header
  402.         let consumes: string[] = [
  403.         ];
  404.         let httpContentTypeSelected:string | undefined = this.configuration.selectHeaderContentType(consumes);
  405.         if (httpContentTypeSelected != undefined) {
  406.             headers = headers.set("Content-Type", httpContentTypeSelected);
  407.         }
  408.  
  409.         return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
  410.             body,
  411.             {
  412.                 withCredentials: this.configuration.withCredentials,
  413.                 headers: headers,
  414.                 observe: observe,
  415.                 reportProgress: reportProgress
  416.             }
  417.         );
  418.     }
  419.  
  420. }
Add Comment
Please, Sign In to add comment