All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.endpoints.examples.0.3.0.source-code.lomboktypescriptendpoint.generated.ts Maven / Gradle / Ivy

import { LombokRequest } from './lombokrequest.model.generated';
import { SubType } from './subtype.model.generated';
import { SimpleEnum } from './simpleenum.model.generated';
import { MapValueType } from './mapvaluetype.model.generated';
import { MyTypeScriptType } from './mytypescripttype.model.generated';
import { MapKeyType } from './mapkeytype.model.generated';
import { LombokResponse } from './lombokresponse.model.generated';
import { ServiceConfig } from './api.module';

import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';

@Injectable()
export class LombokTypeScriptEndpoint {
    private get serviceBaseURL(): string {
        return this.serviceConfig.context + '/api';
    }
    private get onError(): Function {
        return this.serviceConfig.onError || this.handleError.bind(this);
    }
    constructor(private httpClient: HttpClient, private serviceConfig: ServiceConfig) { }
    /* GET */

    /* HEAD */

    /* POST */
    public setIdPost(idPathVariable: number, typeRef: string, body?: LombokRequest, queryRequestParam?: string): Observable> {
        const url = this.serviceBaseURL + '/type/' + idPathVariable + '/' + typeRef + '';
        const params = new HttpParams().set('queryRequestParam', queryRequestParam);
        return this.httpClient.post>(url, body, {params: params})
            .catch((error: Response) => this.onError(error));
    }

    public setFooPost(idPathVariable: number, typeRef: string, body?: LombokRequest, queryRequestParam?: string): Observable> {
        const url = this.serviceBaseURL + '/foo/' + idPathVariable + '/' + typeRef + '';
        const params = new HttpParams().set('queryRequestParam', queryRequestParam);
        return this.httpClient.post>(url, body, {params: params})
            .catch((error: Response) => this.onError(error));
    }

    public setResponseEntityPost(idPathVariable: number, typeRef: string, body?: LombokRequest, queryRequestParam?: string): Observable> {
        const url = this.serviceBaseURL + '/foo/' + idPathVariable + '/' + typeRef + '';
        const params = new HttpParams().set('queryRequestParam', queryRequestParam);
        return this.httpClient.post>(url, body, {params: params})
            .catch((error: Response) => this.onError(error));
    }

    public fileUploadPost(uploadfile: FormData, id: number): Observable> {
        const url = this.serviceBaseURL + '/upload/' + id + '';
        const params = new HttpParams();
        return this.httpClient.post>(url, uploadfile, {params: params})
            .catch((error: Response) => this.onError(error));
    }


    /* PUT */

    /* PATCH */

    /* DELETE */

    /* OPTIONS */


    private handleError(error: Response) {
        // in a real world app, we may send the error to some remote logging infrastructure
        // instead of just logging it to the console
        this.log('error', error);
        return Observable.throw(error);
    }

    private log(level: string, message: any) {
        if (this.serviceConfig.debug) {
            console[level](message);
        }
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy