diff --git a/src/app/services/search.service.spec.ts b/src/app/services/search.service.spec.ts new file mode 100644 index 000000000..23c42c7bb --- /dev/null +++ b/src/app/services/search.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { SearchService } from './search.service'; + +describe('SearchService', () => { + let service: SearchService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(SearchService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/search.service.ts b/src/app/services/search.service.ts new file mode 100644 index 000000000..9e3f29b4f --- /dev/null +++ b/src/app/services/search.service.ts @@ -0,0 +1,54 @@ +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Event } from '../models/event.model'; +import { Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; +import { AuthService } from '../services/auth.service'; +import { User } from '../models/user.model'; +import { EventSearch } from "src/app/models/event-search"; + +@Injectable({ + providedIn: 'root' +}) +export class SearchService { + // state + authheader = {}; + loggeduser: User; + headers: HttpHeaders; + + + + categories= Array; + + // setup + constructor(private http: HttpClient, user: AuthService) { + this.loggeduser = user.ValidatedUser; + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); + } + + + basicSearch(subject:string, date:string, sender:string, organicEntity:string, docTypeId:string): Observable{ + // Endpoint + const geturl = environment.apiURL + 'search'; + // store params + let params = new HttpParams(); + // set https params + console.log(subject); + + params = params.set("assunto", 'actividades'); + params = params.set("data", date); + params = params.set("remetente", sender); + params = params.set("entidadeOrganica", organicEntity); + params = params.set("docTypeId", docTypeId); + + + const options = { + headers: this.headers, + params: params + }; + + return this.http.get(`${geturl}`, options); + } + +}