From 90b3ff5e49350ac6dc9437449a31b720ad697176 Mon Sep 17 00:00:00 2001 From: ThomasFransolet Date: Thu, 11 Jul 2019 23:10:35 +0200 Subject: [PATCH] CP # Generate model via Swagger + Log In test --- ng-swagger-gen.json | 17 ++ package-lock.json | 113 +++++++++- package.json | 1 + src/app/api/api-configuration.ts | 16 ++ src/app/api/api.module.ts | 52 +++++ src/app/api/base-service.ts | 63 ++++++ src/app/api/models.ts | 8 + src/app/api/models/azure-adauth-model.ts | 4 + src/app/api/models/book.ts | 8 + src/app/api/models/facebook-auth-model.ts | 4 + src/app/api/models/google-auth-model.ts | 5 + src/app/api/models/smart-garden-message.ts | 11 + src/app/api/models/smart-printer-message.ts | 9 + src/app/api/models/twitter-auth-model.ts | 4 + src/app/api/models/user.ts | 5 + src/app/api/services.ts | 9 + src/app/api/services/azure.service.ts | 62 ++++++ src/app/api/services/books.service.ts | 222 ++++++++++++++++++++ src/app/api/services/facebook.service.ts | 62 ++++++ src/app/api/services/google.service.ts | 62 ++++++ src/app/api/services/iot.service.ts | 200 ++++++++++++++++++ src/app/api/services/mqtt.service.ts | 52 +++++ src/app/api/services/token.service.ts | 114 ++++++++++ src/app/api/services/twitter.service.ts | 62 ++++++ src/app/api/services/values.service.ts | 219 +++++++++++++++++++ src/app/api/strict-http-response.ts | 9 + src/app/app.component.css | 2 - src/app/app.component.html | 12 +- src/app/app.component.ts | 22 +- src/app/app.module.ts | 32 ++- src/app/app.service.ts | 21 ++ swagger.json | 1 + 32 files changed, 1456 insertions(+), 27 deletions(-) create mode 100644 ng-swagger-gen.json create mode 100644 src/app/api/api-configuration.ts create mode 100644 src/app/api/api.module.ts create mode 100644 src/app/api/base-service.ts create mode 100644 src/app/api/models.ts create mode 100644 src/app/api/models/azure-adauth-model.ts create mode 100644 src/app/api/models/book.ts create mode 100644 src/app/api/models/facebook-auth-model.ts create mode 100644 src/app/api/models/google-auth-model.ts create mode 100644 src/app/api/models/smart-garden-message.ts create mode 100644 src/app/api/models/smart-printer-message.ts create mode 100644 src/app/api/models/twitter-auth-model.ts create mode 100644 src/app/api/models/user.ts create mode 100644 src/app/api/services.ts create mode 100644 src/app/api/services/azure.service.ts create mode 100644 src/app/api/services/books.service.ts create mode 100644 src/app/api/services/facebook.service.ts create mode 100644 src/app/api/services/google.service.ts create mode 100644 src/app/api/services/iot.service.ts create mode 100644 src/app/api/services/mqtt.service.ts create mode 100644 src/app/api/services/token.service.ts create mode 100644 src/app/api/services/twitter.service.ts create mode 100644 src/app/api/services/values.service.ts create mode 100644 src/app/api/strict-http-response.ts create mode 100644 src/app/app.service.ts create mode 100644 swagger.json diff --git a/ng-swagger-gen.json b/ng-swagger-gen.json new file mode 100644 index 0000000..9e608c3 --- /dev/null +++ b/ng-swagger-gen.json @@ -0,0 +1,17 @@ +{ + "$schema": "./node_modules/ng-swagger-gen/ng-swagger-gen-schema.json", + "swagger": "swagger.json", + "output": "src/app/api", + "prefix": "Api", + "ignoreUnusedModels": true, + "minParamsForContainer": 2, + "sortParams": "desc", + "defaultTag": "Api", + "removeStaleFiles": true, + "modelIndex": true, + "serviceIndex": true, + "apiModule": true, + "enumModule": true, + "generateExamples": false, + "camelCase": false +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 05d07ad..06834cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2562,6 +2562,11 @@ "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==" }, + "call-me-maybe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", + "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=" + }, "caller-callsite": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", @@ -3005,6 +3010,15 @@ "typedarray": "^0.0.6" } }, + "config-chain": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz", + "integrity": "sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==", + "requires": { + "ini": "^1.3.4", + "proto-list": "~1.2.1" + } + }, "connect": { "version": "3.6.6", "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", @@ -4554,6 +4568,11 @@ "mime-types": "^2.1.12" } }, + "format-util": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.3.tgz", + "integrity": "sha1-Ay3KShFiYqEsQ/TD7IVmQWxbLZU=" + }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", @@ -4657,11 +4676,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4678,7 +4699,8 @@ }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", @@ -4807,6 +4829,7 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5237,6 +5260,17 @@ } } }, + "global-tunnel-ng": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/global-tunnel-ng/-/global-tunnel-ng-2.7.1.tgz", + "integrity": "sha512-4s+DyciWBV0eK148wqXxcmVAbFVPqtc3sEtUE/GTQfuU80rySLcMhUmHKSHI7/LDj8q0gDYI1lIhRRB7ieRAqg==", + "requires": { + "encodeurl": "^1.0.2", + "lodash": "^4.17.10", + "npm-conf": "^1.1.3", + "tunnel": "^0.0.6" + } + }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", @@ -5816,8 +5850,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inline-source-map": { "version": "0.6.2", @@ -6647,6 +6680,32 @@ "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, + "json-schema-ref-parser": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-5.1.3.tgz", + "integrity": "sha512-CpDFlBwz/6la78hZxyB9FECVKGYjIIl3Ms3KLqFj99W7IIb7D00/RDgc++IGB4BBALl0QRhh5m4q5WNSopvLtQ==", + "requires": { + "call-me-maybe": "^1.0.1", + "debug": "^3.1.0", + "js-yaml": "^3.12.0", + "ono": "^4.0.6" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -7799,6 +7858,11 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "mustache": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.2.tgz", + "integrity": "sha512-KpMNwdQsYz3O/SBS1qJ/o3sqUJ5wSb8gb0pul8CO0S56b9Y2ALm8zCfsjPXsqGFfoNBkDwZuZIAjhsZI03gYVQ==" + }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -7845,6 +7909,17 @@ "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "dev": true }, + "ng-swagger-gen": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/ng-swagger-gen/-/ng-swagger-gen-1.7.1.tgz", + "integrity": "sha512-54bLd5+7Nnyyw0MNkmbqg0M+ftn/SrbNS09pO3OvVzI7qD51rFR7crk6GkAiKIEUtA7WIPmKEoTvcm7JnlNXjA==", + "requires": { + "argparse": "^1.0.10", + "global-tunnel-ng": "^2.7.1", + "json-schema-ref-parser": "^5.1.3", + "mustache": "^2.3.2" + } + }, "ngrok": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/ngrok/-/ngrok-3.1.1.tgz", @@ -8104,6 +8179,15 @@ "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", "dev": true }, + "npm-conf": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/npm-conf/-/npm-conf-1.1.3.tgz", + "integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==", + "requires": { + "config-chain": "^1.1.11", + "pify": "^3.0.0" + } + }, "npm-package-arg": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-6.1.0.tgz", @@ -8337,6 +8421,14 @@ } } }, + "ono": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/ono/-/ono-4.0.11.tgz", + "integrity": "sha512-jQ31cORBFE6td25deYeD80wxKBMj+zBmHTrVxnc6CKhx8gho6ipmWM5zj/oeoqioZ99yqBls9Z/9Nss7J26G2g==", + "requires": { + "format-util": "^1.0.3" + } + }, "open": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/open/-/open-6.0.0.tgz", @@ -8808,8 +8900,7 @@ "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" }, "pinkie": { "version": "2.0.4", @@ -9015,6 +9106,11 @@ "retry": "^0.10.0" } }, + "proto-list": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", + "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=" + }, "protoduck": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/protoduck/-/protoduck-5.0.1.tgz", @@ -11738,6 +11834,11 @@ "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index 939b659..339b596 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "core-js": "^2.5.4", "font-awesome": "^4.7.0", "jquery": "^3.3.1", + "ng-swagger-gen": "^1.7.1", "ngx-bootstrap": "^3.2.0", "popper": "^1.0.1", "primeicons": "^1.0.0", diff --git a/src/app/api/api-configuration.ts b/src/app/api/api-configuration.ts new file mode 100644 index 0000000..34f0bb1 --- /dev/null +++ b/src/app/api/api-configuration.ts @@ -0,0 +1,16 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; + +/** + * Global configuration for Api services + */ +@Injectable({ + providedIn: 'root', +}) +export class ApiConfiguration { + rootUrl: string = ''; +} + +export interface ApiConfigurationInterface { + rootUrl?: string; +} diff --git a/src/app/api/api.module.ts b/src/app/api/api.module.ts new file mode 100644 index 0000000..a1411d4 --- /dev/null +++ b/src/app/api/api.module.ts @@ -0,0 +1,52 @@ +/* tslint:disable */ +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { HttpClientModule } from '@angular/common/http'; +import { ApiConfiguration, ApiConfigurationInterface } from './api-configuration'; + +import { AzureService } from './services/azure.service'; +import { BooksService } from './services/books.service'; +import { FacebookService } from './services/facebook.service'; +import { GoogleService } from './services/google.service'; +import { IOTService } from './services/iot.service'; +import { MQTTService } from './services/mqtt.service'; +import { TokenService } from './services/token.service'; +import { TwitterService } from './services/twitter.service'; +import { ValuesService } from './services/values.service'; + +/** + * Provider for all Api services, plus ApiConfiguration + */ +@NgModule({ + imports: [ + HttpClientModule + ], + exports: [ + HttpClientModule + ], + declarations: [], + providers: [ + ApiConfiguration, + AzureService, + BooksService, + FacebookService, + GoogleService, + IOTService, + MQTTService, + TokenService, + TwitterService, + ValuesService + ], +}) +export class ApiModule { + static forRoot(customParams: ApiConfigurationInterface): ModuleWithProviders { + return { + ngModule: ApiModule, + providers: [ + { + provide: ApiConfiguration, + useValue: {rootUrl: customParams.rootUrl} + } + ] + } + } +} diff --git a/src/app/api/base-service.ts b/src/app/api/base-service.ts new file mode 100644 index 0000000..ee9c3ce --- /dev/null +++ b/src/app/api/base-service.ts @@ -0,0 +1,63 @@ +/* tslint:disable */ +import { HttpClient, HttpParameterCodec, HttpParams } from '@angular/common/http'; +import { ApiConfiguration } from './api-configuration'; + +/** + * Custom parameter codec to correctly handle the plus sign in parameter + * values. See https://github.com/angular/angular/issues/18261 + */ +class ParameterCodec implements HttpParameterCodec { + encodeKey(key: string): string { + return encodeURIComponent(key); + } + + encodeValue(value: string): string { + return encodeURIComponent(value); + } + + decodeKey(key: string): string { + return decodeURIComponent(key); + } + + decodeValue(value: string): string { + return decodeURIComponent(value); + } +} +const PARAMETER_CODEC = new ParameterCodec(); + +/** + * Base class for API services + */ +export class BaseService { + constructor( + protected config: ApiConfiguration, + protected http: HttpClient + ) { + } + + private _rootUrl: string = ''; + + /** + * Returns the root url for API operations. If not set directly in this + * service, will fallback to ApiConfiguration.rootUrl. + */ + get rootUrl(): string { + return this._rootUrl || this.config.rootUrl; + } + + /** + * Sets the root URL for API operations in this service. + */ + set rootUrl(rootUrl: string) { + this._rootUrl = rootUrl; + } + + /** + * Creates a new `HttpParams` with the correct codec + */ + protected newParams(): HttpParams { + return new HttpParams({ + encoder: PARAMETER_CODEC + }); + } +} diff --git a/src/app/api/models.ts b/src/app/api/models.ts new file mode 100644 index 0000000..99c4ab5 --- /dev/null +++ b/src/app/api/models.ts @@ -0,0 +1,8 @@ +export { AzureADAuthModel } from './models/azure-adauth-model'; +export { Book } from './models/book'; +export { FacebookAuthModel } from './models/facebook-auth-model'; +export { GoogleAuthModel } from './models/google-auth-model'; +export { SmartPrinterMessage } from './models/smart-printer-message'; +export { SmartGardenMessage } from './models/smart-garden-message'; +export { User } from './models/user'; +export { TwitterAuthModel } from './models/twitter-auth-model'; diff --git a/src/app/api/models/azure-adauth-model.ts b/src/app/api/models/azure-adauth-model.ts new file mode 100644 index 0000000..f95df2d --- /dev/null +++ b/src/app/api/models/azure-adauth-model.ts @@ -0,0 +1,4 @@ +/* tslint:disable */ +export interface AzureADAuthModel { + apiKey?: string; +} diff --git a/src/app/api/models/book.ts b/src/app/api/models/book.ts new file mode 100644 index 0000000..984b5b2 --- /dev/null +++ b/src/app/api/models/book.ts @@ -0,0 +1,8 @@ +/* tslint:disable */ +export interface Book { + id?: string; + bookName?: string; + price?: number; + category?: string; + author?: string; +} diff --git a/src/app/api/models/facebook-auth-model.ts b/src/app/api/models/facebook-auth-model.ts new file mode 100644 index 0000000..a647260 --- /dev/null +++ b/src/app/api/models/facebook-auth-model.ts @@ -0,0 +1,4 @@ +/* tslint:disable */ +export interface FacebookAuthModel { + userAccessToken?: string; +} diff --git a/src/app/api/models/google-auth-model.ts b/src/app/api/models/google-auth-model.ts new file mode 100644 index 0000000..6456e7e --- /dev/null +++ b/src/app/api/models/google-auth-model.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +export interface GoogleAuthModel { + authorizationCode?: string; + apiKey?: string; +} diff --git a/src/app/api/models/smart-garden-message.ts b/src/app/api/models/smart-garden-message.ts new file mode 100644 index 0000000..05c333f --- /dev/null +++ b/src/app/api/models/smart-garden-message.ts @@ -0,0 +1,11 @@ +/* tslint:disable */ +export interface SmartGardenMessage { + id?: string; + type?: string; + time?: string; + temperature?: number; + pressure?: number; + humidity?: number; + water?: number; + light?: number; +} diff --git a/src/app/api/models/smart-printer-message.ts b/src/app/api/models/smart-printer-message.ts new file mode 100644 index 0000000..06f5f53 --- /dev/null +++ b/src/app/api/models/smart-printer-message.ts @@ -0,0 +1,9 @@ +/* tslint:disable */ +export interface SmartPrinterMessage { + id?: string; + type?: string; + time?: string; + temperature?: number; + pressure?: number; + smoke?: number; +} diff --git a/src/app/api/models/twitter-auth-model.ts b/src/app/api/models/twitter-auth-model.ts new file mode 100644 index 0000000..68ce12c --- /dev/null +++ b/src/app/api/models/twitter-auth-model.ts @@ -0,0 +1,4 @@ +/* tslint:disable */ +export interface TwitterAuthModel { + apiKey?: string; +} diff --git a/src/app/api/models/user.ts b/src/app/api/models/user.ts new file mode 100644 index 0000000..f15177c --- /dev/null +++ b/src/app/api/models/user.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +export interface User { + id?: string; + password?: string; +} diff --git a/src/app/api/services.ts b/src/app/api/services.ts new file mode 100644 index 0000000..94a6431 --- /dev/null +++ b/src/app/api/services.ts @@ -0,0 +1,9 @@ +export { AzureService } from './services/azure.service'; +export { BooksService } from './services/books.service'; +export { FacebookService } from './services/facebook.service'; +export { GoogleService } from './services/google.service'; +export { IOTService } from './services/iot.service'; +export { MQTTService } from './services/mqtt.service'; +export { TokenService } from './services/token.service'; +export { TwitterService } from './services/twitter.service'; +export { ValuesService } from './services/values.service'; diff --git a/src/app/api/services/azure.service.ts b/src/app/api/services/azure.service.ts new file mode 100644 index 0000000..500880e --- /dev/null +++ b/src/app/api/services/azure.service.ts @@ -0,0 +1,62 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { AzureADAuthModel } from '../models/azure-adauth-model'; +@Injectable({ + providedIn: 'root', +}) +class AzureService extends __BaseService { + static readonly CreatePath = '/azure'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param user undefined + */ + CreateResponse(user?: AzureADAuthModel): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = user; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/azure`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param user undefined + */ + Create(user?: AzureADAuthModel): __Observable { + return this.CreateResponse(user).pipe( + __map(_r => _r.body as null) + ); + } +} + +module AzureService { +} + +export { AzureService } diff --git a/src/app/api/services/books.service.ts b/src/app/api/services/books.service.ts new file mode 100644 index 0000000..0670269 --- /dev/null +++ b/src/app/api/services/books.service.ts @@ -0,0 +1,222 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { Book } from '../models/book'; +@Injectable({ + providedIn: 'root', +}) +class BooksService extends __BaseService { + static readonly GetPath = '/api/books'; + static readonly CreatePath = '/api/books'; + static readonly GetBookPath = '/api/books/{id}'; + static readonly UpdatePath = '/api/books/{id}'; + static readonly DeletePath = '/api/books/{id}'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @return Success + */ + GetResponse(): __Observable<__StrictHttpResponse>> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/books`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse>; + }) + ); + } + /** + * @return Success + */ + Get(): __Observable> { + return this.GetResponse().pipe( + __map(_r => _r.body as Array) + ); + } + + /** + * @param book undefined + * @return Success + */ + CreateResponse(book?: Book): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = book; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/api/books`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param book undefined + * @return Success + */ + Create(book?: Book): __Observable { + return this.CreateResponse(book).pipe( + __map(_r => _r.body as Book) + ); + } + + /** + * @param id undefined + * @return Success + */ + GetBookResponse(id: string): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/books/${id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param id undefined + * @return Success + */ + GetBook(id: string): __Observable { + return this.GetBookResponse(id).pipe( + __map(_r => _r.body as Book) + ); + } + + /** + * @param params The `BooksService.UpdateParams` containing the following parameters: + * + * - `id`: + * + * - `bookIn`: + */ + UpdateResponse(params: BooksService.UpdateParams): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + __body = params.bookIn; + let req = new HttpRequest( + 'PUT', + this.rootUrl + `/api/books/${params.id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param params The `BooksService.UpdateParams` containing the following parameters: + * + * - `id`: + * + * - `bookIn`: + */ + Update(params: BooksService.UpdateParams): __Observable { + return this.UpdateResponse(params).pipe( + __map(_r => _r.body as null) + ); + } + + /** + * @param id undefined + */ + DeleteResponse(id: string): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + let req = new HttpRequest( + 'DELETE', + this.rootUrl + `/api/books/${id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param id undefined + */ + Delete(id: string): __Observable { + return this.DeleteResponse(id).pipe( + __map(_r => _r.body as null) + ); + } +} + +module BooksService { + + /** + * Parameters for Update + */ + export interface UpdateParams { + id: string; + bookIn?: Book; + } +} + +export { BooksService } diff --git a/src/app/api/services/facebook.service.ts b/src/app/api/services/facebook.service.ts new file mode 100644 index 0000000..231963b --- /dev/null +++ b/src/app/api/services/facebook.service.ts @@ -0,0 +1,62 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { FacebookAuthModel } from '../models/facebook-auth-model'; +@Injectable({ + providedIn: 'root', +}) +class FacebookService extends __BaseService { + static readonly CreatePath = '/facebook'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param user undefined + */ + CreateResponse(user?: FacebookAuthModel): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = user; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/facebook`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param user undefined + */ + Create(user?: FacebookAuthModel): __Observable { + return this.CreateResponse(user).pipe( + __map(_r => _r.body as null) + ); + } +} + +module FacebookService { +} + +export { FacebookService } diff --git a/src/app/api/services/google.service.ts b/src/app/api/services/google.service.ts new file mode 100644 index 0000000..02b8536 --- /dev/null +++ b/src/app/api/services/google.service.ts @@ -0,0 +1,62 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { GoogleAuthModel } from '../models/google-auth-model'; +@Injectable({ + providedIn: 'root', +}) +class GoogleService extends __BaseService { + static readonly CreatePath = '/google'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param user undefined + */ + CreateResponse(user?: GoogleAuthModel): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = user; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/google`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param user undefined + */ + Create(user?: GoogleAuthModel): __Observable { + return this.CreateResponse(user).pipe( + __map(_r => _r.body as null) + ); + } +} + +module GoogleService { +} + +export { GoogleService } diff --git a/src/app/api/services/iot.service.ts b/src/app/api/services/iot.service.ts new file mode 100644 index 0000000..3211202 --- /dev/null +++ b/src/app/api/services/iot.service.ts @@ -0,0 +1,200 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { SmartPrinterMessage } from '../models/smart-printer-message'; +import { SmartGardenMessage } from '../models/smart-garden-message'; +@Injectable({ + providedIn: 'root', +}) +class IOTService extends __BaseService { + static readonly GetSmartPrinterMessagesPath = '/api/iot/smartprinter/{idDevice}'; + static readonly PostToDBPrinterPath = '/api/iot/smartprinter/{idDevice}'; + static readonly PostToDBSmartGardenPath = '/api/iot/smartgarden/{idDevice}'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param params The `IOTService.GetSmartPrinterMessagesParams` containing the following parameters: + * + * - `idDevice`: + * + * - `id`: Id of the smart printer message + * + * @return Success + */ + GetSmartPrinterMessagesResponse(params: IOTService.GetSmartPrinterMessagesParams): __Observable<__StrictHttpResponse>> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + if (params.id != null) __params = __params.set('id', params.id.toString()); + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/iot/smartprinter/${params.idDevice}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse>; + }) + ); + } + /** + * @param params The `IOTService.GetSmartPrinterMessagesParams` containing the following parameters: + * + * - `idDevice`: + * + * - `id`: Id of the smart printer message + * + * @return Success + */ + GetSmartPrinterMessages(params: IOTService.GetSmartPrinterMessagesParams): __Observable> { + return this.GetSmartPrinterMessagesResponse(params).pipe( + __map(_r => _r.body as Array) + ); + } + + /** + * @param params The `IOTService.PostToDBPrinterParams` containing the following parameters: + * + * - `idDevice`: Id of the device to upload to DB + * + * - `content`: Content that will be uploaded + */ + PostToDBPrinterResponse(params: IOTService.PostToDBPrinterParams): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + __body = params.content; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/api/iot/smartprinter/${params.idDevice}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param params The `IOTService.PostToDBPrinterParams` containing the following parameters: + * + * - `idDevice`: Id of the device to upload to DB + * + * - `content`: Content that will be uploaded + */ + PostToDBPrinter(params: IOTService.PostToDBPrinterParams): __Observable { + return this.PostToDBPrinterResponse(params).pipe( + __map(_r => _r.body as null) + ); + } + + /** + * @param params The `IOTService.PostToDBSmartGardenParams` containing the following parameters: + * + * - `idDevice`: + * + * - `content`: + */ + PostToDBSmartGardenResponse(params: IOTService.PostToDBSmartGardenParams): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + __body = params.content; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/api/iot/smartgarden/${params.idDevice}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param params The `IOTService.PostToDBSmartGardenParams` containing the following parameters: + * + * - `idDevice`: + * + * - `content`: + */ + PostToDBSmartGarden(params: IOTService.PostToDBSmartGardenParams): __Observable { + return this.PostToDBSmartGardenResponse(params).pipe( + __map(_r => _r.body as null) + ); + } +} + +module IOTService { + + /** + * Parameters for GetSmartPrinterMessages + */ + export interface GetSmartPrinterMessagesParams { + idDevice: string; + + /** + * Id of the smart printer message + */ + id?: number; + } + + /** + * Parameters for PostToDBPrinter + */ + export interface PostToDBPrinterParams { + + /** + * Id of the device to upload to DB + */ + idDevice: number; + + /** + * Content that will be uploaded + */ + content?: Array; + } + + /** + * Parameters for PostToDBSmartGarden + */ + export interface PostToDBSmartGardenParams { + idDevice: number; + content?: Array; + } +} + +export { IOTService } diff --git a/src/app/api/services/mqtt.service.ts b/src/app/api/services/mqtt.service.ts new file mode 100644 index 0000000..23d95c5 --- /dev/null +++ b/src/app/api/services/mqtt.service.ts @@ -0,0 +1,52 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root', +}) +class MQTTService extends __BaseService { + static readonly GetToPublishMqttPath = '/api/mqtt'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + GetToPublishMqttResponse(): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/mqtt`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } GetToPublishMqtt(): __Observable { + return this.GetToPublishMqttResponse().pipe( + __map(_r => _r.body as null) + ); + } +} + +module MQTTService { +} + +export { MQTTService } diff --git a/src/app/api/services/token.service.ts b/src/app/api/services/token.service.ts new file mode 100644 index 0000000..f64dbf3 --- /dev/null +++ b/src/app/api/services/token.service.ts @@ -0,0 +1,114 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { User } from '../models/user'; +@Injectable({ + providedIn: 'root', +}) +class TokenService extends __BaseService { + static readonly CreatePath = '/api/token'; + static readonly Create_1Path = '/token'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param params The `TokenService.CreateParams` containing the following parameters: + * + * - `username`: + * + * - `password`: + */ + CreateResponse(params: TokenService.CreateParams): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + if (params.username != null) __params = __params.set('username', params.username.toString()); + if (params.password != null) __params = __params.set('password', params.password.toString()); + let req = new HttpRequest( + 'POST', + this.rootUrl + `/api/token`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param params The `TokenService.CreateParams` containing the following parameters: + * + * - `username`: + * + * - `password`: + */ + Create(params: TokenService.CreateParams): __Observable { + return this.CreateResponse(params).pipe( + __map(_r => _r.body as null) + ); + } + + /** + * @param user undefined + */ + Create_1Response(user?: User): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = user; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/token`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param user undefined + */ + Create_1(user?: User): __Observable { + return this.Create_1Response(user).pipe( + __map(_r => _r.body as null) + ); + } +} + +module TokenService { + + /** + * Parameters for Create + */ + export interface CreateParams { + username?: string; + password?: string; + } +} + +export { TokenService } diff --git a/src/app/api/services/twitter.service.ts b/src/app/api/services/twitter.service.ts new file mode 100644 index 0000000..fdbf425 --- /dev/null +++ b/src/app/api/services/twitter.service.ts @@ -0,0 +1,62 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +import { TwitterAuthModel } from '../models/twitter-auth-model'; +@Injectable({ + providedIn: 'root', +}) +class TwitterService extends __BaseService { + static readonly CreatePath = '/twitter'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @param user undefined + */ + CreateResponse(user?: TwitterAuthModel): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = user; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/twitter`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param user undefined + */ + Create(user?: TwitterAuthModel): __Observable { + return this.CreateResponse(user).pipe( + __map(_r => _r.body as null) + ); + } +} + +module TwitterService { +} + +export { TwitterService } diff --git a/src/app/api/services/values.service.ts b/src/app/api/services/values.service.ts new file mode 100644 index 0000000..69e4f51 --- /dev/null +++ b/src/app/api/services/values.service.ts @@ -0,0 +1,219 @@ +/* tslint:disable */ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpRequest, HttpResponse, HttpHeaders } from '@angular/common/http'; +import { BaseService as __BaseService } from '../base-service'; +import { ApiConfiguration as __Configuration } from '../api-configuration'; +import { StrictHttpResponse as __StrictHttpResponse } from '../strict-http-response'; +import { Observable as __Observable } from 'rxjs'; +import { map as __map, filter as __filter } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root', +}) +class ValuesService extends __BaseService { + static readonly GetPath = '/api/test'; + static readonly PostPath = '/api/test'; + static readonly Get_1Path = '/api/test/{id}'; + static readonly PutPath = '/api/test/{id}'; + static readonly DeletePath = '/api/test/{id}'; + + constructor( + config: __Configuration, + http: HttpClient + ) { + super(config, http); + } + + /** + * @return Success + */ + GetResponse(): __Observable<__StrictHttpResponse>> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/test`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse>; + }) + ); + } + /** + * @return Success + */ + Get(): __Observable> { + return this.GetResponse().pipe( + __map(_r => _r.body as Array) + ); + } + + /** + * @param value undefined + */ + PostResponse(value?: string): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + __body = value; + let req = new HttpRequest( + 'POST', + this.rootUrl + `/api/test`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param value undefined + */ + Post(value?: string): __Observable { + return this.PostResponse(value).pipe( + __map(_r => _r.body as null) + ); + } + + /** + * @param id undefined + * @return Success + */ + Get_1Response(id: number): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + let req = new HttpRequest( + 'GET', + this.rootUrl + `/api/test/${id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'text' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param id undefined + * @return Success + */ + Get_1(id: number): __Observable { + return this.Get_1Response(id).pipe( + __map(_r => _r.body as string) + ); + } + + /** + * @param params The `ValuesService.PutParams` containing the following parameters: + * + * - `id`: + * + * - `value`: + */ + PutResponse(params: ValuesService.PutParams): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + __body = params.value; + let req = new HttpRequest( + 'PUT', + this.rootUrl + `/api/test/${params.id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param params The `ValuesService.PutParams` containing the following parameters: + * + * - `id`: + * + * - `value`: + */ + Put(params: ValuesService.PutParams): __Observable { + return this.PutResponse(params).pipe( + __map(_r => _r.body as null) + ); + } + + /** + * @param id undefined + */ + DeleteResponse(id: number): __Observable<__StrictHttpResponse> { + let __params = this.newParams(); + let __headers = new HttpHeaders(); + let __body: any = null; + + let req = new HttpRequest( + 'DELETE', + this.rootUrl + `/api/test/${id}`, + __body, + { + headers: __headers, + params: __params, + responseType: 'json' + }); + + return this.http.request(req).pipe( + __filter(_r => _r instanceof HttpResponse), + __map((_r) => { + return _r as __StrictHttpResponse; + }) + ); + } + /** + * @param id undefined + */ + Delete(id: number): __Observable { + return this.DeleteResponse(id).pipe( + __map(_r => _r.body as null) + ); + } +} + +module ValuesService { + + /** + * Parameters for Put + */ + export interface PutParams { + id: number; + value?: string; + } +} + +export { ValuesService } diff --git a/src/app/api/strict-http-response.ts b/src/app/api/strict-http-response.ts new file mode 100644 index 0000000..ebdeada --- /dev/null +++ b/src/app/api/strict-http-response.ts @@ -0,0 +1,9 @@ +/* tslint:disable */ +import { HttpResponse } from '@angular/common/http'; + +/** + * Constrains the http to not expand the response type with `| null` + */ +export type StrictHttpResponse = HttpResponse & { + readonly body: T; +} diff --git a/src/app/app.component.css b/src/app/app.component.css index 50b0158..4592116 100644 --- a/src/app/app.component.css +++ b/src/app/app.component.css @@ -23,8 +23,6 @@ p-toolbar { } - - p-toolbar .ui-button { background-color: transparent ; opacity: 1; diff --git a/src/app/app.component.html b/src/app/app.component.html index 7a70cd6..69990fe 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -10,8 +10,8 @@ - - + + @@ -20,22 +20,22 @@ - + Log In
- +
- +
- +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3658f5e..7d1286e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; -import {MenuItem} from 'primeng/api'; +import { MenuItem } from 'primeng/api'; +import { AppService } from './app.service'; @Component({ @@ -13,9 +14,13 @@ export class AppComponent implements OnInit{ items : MenuItem[]; public Connected : false; - display: boolean = false; + public DisplayModalLogin: boolean = false; + public Username: string = null; + public Password: string = null; - constructor(){} + constructor( + private _appService: AppService + ){} ngOnInit(){ this.items = [ {label: 'Update', icon: 'pi pi-refresh'}, @@ -24,10 +29,15 @@ export class AppComponent implements OnInit{ } - public logIn() + public LogIn() { - this.display = true; - console.log('helloooo'); + this._appService.GetToken(this.Username, this.Password) + .subscribe(res => { + console.log(res.Token); + }, () => { + console.log('ERROR'); + }); + // change route -> /login } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4b10c23..f510e22 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,10 +1,11 @@ import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { NgModule } from '@angular/core'; +import { NgModule, Provider, APP_INITIALIZER } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { HomePageComponent } from './home-page/home-page.component'; +import { HttpClientModule } from '@angular/common/http'; import { AlertModule } from 'ngx-bootstrap/alert'; import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; @@ -14,11 +15,25 @@ import { BorderCardDirective } from './directives/border-card.directive'; import { ToolbarModule } from 'primeng/toolbar'; import { ButtonModule } from 'primeng/button'; import { SplitButtonModule } from 'primeng/splitbutton'; -import {DialogModule} from 'primeng/dialog'; -import {InputTextModule} from 'primeng/inputtext'; +import { DialogModule } from 'primeng/dialog'; +import { InputTextModule } from 'primeng/inputtext'; +import { ApiConfiguration } from './api/api-configuration'; +import { AppService } from './app.service'; +import { FormsModule } from '@angular/forms'; +export function initApiConfiguration(config: ApiConfiguration): Function { + return () => { + config.rootUrl='https://localhost:5001'; // None = same rooturl + }; +} +export const INIT_API_CONFIGURATION: Provider = { + provide:APP_INITIALIZER, + useFactory:initApiConfiguration, + deps: [ApiConfiguration], + multi:true +}; @@ -40,11 +55,14 @@ import {InputTextModule} from 'primeng/inputtext'; ButtonModule, SplitButtonModule, DialogModule, - InputTextModule - - + InputTextModule, + HttpClientModule, + FormsModule + ], + providers: [ + INIT_API_CONFIGURATION, + AppService ], - providers: [], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/app/app.service.ts b/src/app/app.service.ts new file mode 100644 index 0000000..9d5c714 --- /dev/null +++ b/src/app/app.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { TokenService } from './api/services/token.service'; + + +@Injectable({ + providedIn: 'root' +}) + +export class AppService { + constructor( + protected http: HttpClient, + private _tokenService: TokenService + ) { } + + public GetToken(username: string, password: string): Observable { + return this._tokenService.Create({username: username, password: password}); + } + +} diff --git a/swagger.json b/swagger.json new file mode 100644 index 0000000..2bfdff3 --- /dev/null +++ b/swagger.json @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"version":"v1","title":"MyCoreApi"},"paths":{"/azure":{"post":{"tags":["Azure"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/AzureADAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/books":{"get":{"tags":["Books"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Book"}}}}},"post":{"tags":["Books"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"book","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}}},"/api/books/{id}":{"get":{"tags":["Books"],"operationId":"GetBook","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}},"put":{"tags":["Books"],"operationId":"Update","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"},{"name":"bookIn","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Books"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/facebook":{"post":{"tags":["Facebook"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/FacebookAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/google":{"post":{"tags":["Google"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/GoogleAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/iot/smartprinter/{idDevice}":{"get":{"tags":["IOT"],"summary":"Retrieve all SmartPrinterMessage","operationId":"GetSmartPrinterMessages","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"query","description":"Id of the smart printer message","required":false,"type":"integer","format":"int32"},{"name":"idDevice","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}}},"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBPrinter","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device to upload to DB","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","description":"Content that will be uploaded","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}],"responses":{"200":{"description":"Success"},"201":{"description":"Content successfully posted to DB"},"500":{"description":"Unexpected error"}}}},"/api/iot/smartgarden/{idDevice}":{"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBSmartGarden","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartGardenMessage"}}}],"responses":{"200":{"description":"Success"}}}},"/api/mqtt":{"get":{"tags":["MQTT"],"summary":"It's a mqtt publish test ! :)","operationId":"GetToPublishMqtt","consumes":[],"produces":[],"parameters":[],"responses":{"200":{"description":"Success"}}}},"/api/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":[],"produces":[],"parameters":[{"name":"username","in":"query","required":false,"type":"string"},{"name":"password","in":"query","required":false,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/User"}}],"responses":{"200":{"description":"Success"}}}},"/twitter":{"post":{"tags":["Twitter"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/TwitterAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/test":{"get":{"tags":["Values"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"type":"string"}}}}},"post":{"tags":["Values"],"operationId":"Post","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/test/{id}":{"get":{"tags":["Values"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success","schema":{"type":"string"}}}},"put":{"tags":["Values"],"operationId":"Put","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Values"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success"}}}}},"definitions":{"AzureADAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"Book":{"type":"object","properties":{"id":{"type":"string"},"bookName":{"type":"string"},"price":{"format":"double","type":"number"},"category":{"type":"string"},"author":{"type":"string"}}},"FacebookAuthModel":{"type":"object","properties":{"userAccessToken":{"type":"string"}}},"GoogleAuthModel":{"type":"object","properties":{"authorizationCode":{"type":"string"},"apiKey":{"type":"string"}}},"SmartPrinterMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"smoke":{"format":"int32","type":"integer"}}},"SmartGardenMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"humidity":{"format":"double","type":"number"},"water":{"format":"int32","type":"integer"},"light":{"format":"int32","type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"}}},"TwitterAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please enter JWT with Bearer into field"}},"security":[{"Bearer":[]}]} \ No newline at end of file