Commit ccd3620a authored by shalithadeshan's avatar shalithadeshan

add all the necessary service

parent 5cfc6a6d
export interface Food {
name: string;
calories: number;
}
import {Review} from './review';
export interface Post {
id: number;
score: number;
title: string;
description: string;
reviews: Review[];
}
import { TestBed } from '@angular/core/testing';
import { PythonBackendService } from './python-backend.service';
describe('PythonBackendService', () => {
let service: PythonBackendService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PythonBackendService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {environment} from '../../environments/environment';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class PythonBackendService {
baseUrlSkinImageClassification = environment.baseUrlSkinImageClassification;
baseUrlSymptoms = environment.baseUrlSymptoms;
baseUrlOntology = environment.baseUrlOntology;
baseUrlWeight = environment.baseUrlWeight;
baseUrlWeightPuppy = environment.baseUrlWeightPuppy;
baseUrlDb = environment.baseUrlDb;
constructor(
private httpClient: HttpClient
) { }
predictSkinDisease(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlSkinImageClassification}predict`, data);
}
getImage(): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlSkinImageClassification}getImage`, null);
}
predictDiseaseWithSymptoms(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlSymptoms}predict`, data);
}
predictOntologyScore(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlOntology}predict`, data);
}
predictWeight(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlWeight}predict`, data);
}
predictWeightPuppy(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlWeightPuppy}predict`, data);
}
signup(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}signup`, data);
}
login(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}login`, data);
}
addPet(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}addPet`, data);
}
addQuestion(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}addQuestion`, data);
}
addReview(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}addReview`, data);
}
getPets(): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}getPets`, null);
}
getQuestions(): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}getQuestions`, null);
}
setQuestionVote(data: any): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}setQuestionVote`, data);
}
getReviews(): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrlDb}getReviews`, null);
}
}
export interface Review {
content: string;
}
import { Injectable } from '@angular/core';
import {environment} from "../environments/environment";
import {HttpHeaders} from "@angular/common/http";
@Injectable({
providedIn: 'root'
})
export class RestCallsService {
baseUrl = environment.baseUrlSpring;
constructor() { }
getRequestHeaders() {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + localStorage.getItem('token')
})
};
return httpOptions;
}
}
import { Injectable } from '@angular/core';
import {environment} from '../environments/environment';
import {HttpClient} from '@angular/common/http';
import {RestCallsService} from './rest-calls.service';
import {Observable} from 'rxjs';
import {LoginDto} from './interfaces/login-dto';
import {UserDto} from './interfaces/user-dto';
import {Dog} from './interfaces/dog';
import {Question} from './interfaces/question';
import {Answer} from './interfaces/answer';
@Injectable({
providedIn: 'root'
})
export class SpringBackendServiceService {
baseUrl = environment.baseUrlSpring;
constructor(
private httpClient: HttpClient,
private restCallsService: RestCallsService
) { }
login(login: LoginDto): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrl}auth/signin`, login);
}
signup(userDto: UserDto): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrl}auth/createAccount`, userDto);
}
newDog(dog: Dog): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrl}dog`, dog, this.restCallsService.getRequestHeaders());
}
allDogs() {
return this.httpClient.get<any>(`${this.baseUrl}dogs`, this.restCallsService.getRequestHeaders());
}
newQuestion(question: Question): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrl}question`, question, this.restCallsService.getRequestHeaders());
}
allQuestions() {
return this.httpClient.get<any>(`${this.baseUrl}questions`, this.restCallsService.getRequestHeaders());
}
newAnswer(answer: Answer): Observable<any> {
return this.httpClient.post<any>(`${this.baseUrl}answer`, answer, this.restCallsService.getRequestHeaders());
}
answersByQuestion(id) {
return this.httpClient.get<any>(`${this.baseUrl}answers/`+id, this.restCallsService.getRequestHeaders());
}
allAnswers() {
return this.httpClient.get<any>(`${this.baseUrl}answers`, this.restCallsService.getRequestHeaders());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment