/** * NymOS Playground apis 1.0.0 * * The contents of this file are subject to the NymOS License, version 1.0. * It is forbidden the use of the codes included on this file, even partially, * for third parties, such as its copy, without express authorization of the * intelectual property and commercial rights owners. A copy of the license * may be obtained at http://nymos.io/source-license. The intelectual * property and comercial rights of this file and codes belong to NymOS S.A. * * Copyright (c) 2017. All rights reserved. * */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { CustomHttpUrlEncodingCodec } from '../internal/encoder'; import { DataTypes } from '../models/data-types.model'; import { Pong } from '../models/pong.model'; import { Problem } from '../models/problem.model'; @Injectable() export class PlaygroundService { constructor(protected httpClient: HttpClient) { } /** * Echo service that repply back to client the data type sent on the request * This endpoint can be used to validate type conversions while creating client libraries. * @param dataTypes * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public echoDataTypes(dataTypes?: DataTypes): Observable { let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://playground-dot-nymos-dev.appspot.com/v1/playground/data-types-echo`, dataTypes, { headers: headers, } ); } /** * Gets an example response containing all primitive data types * This endpoint can be used to validate type conversions while creating client libraries. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public loadDataTypes(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/data-types`, { headers: headers, } ); } /** * Send a ping request to the server * This endpoint will always return `200 OK`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public ping(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/ping`, { headers: headers, } ); } /** * Send a ping request to the server and get a collection of Pongs * This endpoint will always return `200 OK`. * @param limit This is the maximum number of objects that may be returned. A query may return fewer than the value of `limit` once reached the end of the list of data. * @param after This is the cursor that points to the `end` of the page of data that has been returned. * @param before This is the cursor that points to the `start` of the page of data that has been returned. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public pingCollection(limit?: number, after?: string, before?: string): Observable> { let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (limit !== undefined) { queryParameters = queryParameters.set('limit', limit); } if (after !== undefined) { queryParameters = queryParameters.set('after', after); } if (before !== undefined) { queryParameters = queryParameters.set('before', before); } let headers = new HttpHeaders(); return this.httpClient.get>(`https://playground-dot-nymos-dev.appspot.com/v1/playground/ping-collection`, { params: queryParameters, headers: headers, } ); } /** * Send a ping request to the server * This endpoint will always return `200 OK` for *authenticated* in `admins`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public pingFromAdmin(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/ping-admin`, { headers: headers, } ); } /** * Send a ping request to the server * This endpoint will always return `200 OK` only if call is made from another microservice. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public pingFromMicroservice(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/ping-internal`, { headers: headers, } ); } /** * Send a ping request to the server * This endpoint will always return `200 OK` for *authenticated* `users`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public pingFromUser(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/ping-user`, { headers: headers, } ); } /** * Throws 403 Forbidden * This endpoint will always return `403 Forbidden`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public throwForbiddenProblem(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/throw-forbidden-problem`, { headers: headers, } ); } /** * Throws 500 Internal Server Error * This endpoint will always return `500 Internal Server Error`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public throwInternalServerErrorProblem(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/throw-internal-server-error-problem`, { headers: headers, } ); } /** * Throws 401 Unauthorized * This endpoint will always return `401 Unauthorized`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public throwUnauthorizedProblem(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/throw-unauthorized-problem`, { headers: headers, } ); } /** * Throws Validation Problem * This endpoint will always return `403 Forbidden` + validation fields. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public throwValidationProblem(): Observable { let headers = new HttpHeaders(); return this.httpClient.get(`https://playground-dot-nymos-dev.appspot.com/v1/playground/throw-validation-problem`, { headers: headers, } ); } /** * Returns and empty response * This endpoint will always return `200 OK`. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public voidReturn(): Observable { let headers = new HttpHeaders(); return this.httpClient.post(`https://playground-dot-nymos-dev.appspot.com/v1/playground/void`, { headers: headers, } ); } }