import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { ICandidateCreateInput , ICandidateFindInput , ICandidate , ICandidateUpdateInput , CandidateStatus } from '@gauzy/contracts' ; import { Observable } from 'rxjs' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class CandidatesService { constructor ( private http ) { } getAll ( relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return this . http . get < { items : ICandidate [ ] ; total : number ; } > ( `${ API_PREFIX }/candidate` , { params : { data } } ) ; } getCandidateById ( id , relations ? , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` , { params : { data } } ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put ( `${ API_PREFIX }/candidate/${ id }` , updateInput ) ) ; } create ( createInput ) { return this . http . post < ICandidate > ( `${ API_PREFIX }/candidate` , createInput ) ; } createBulk ( createInput ) { return this . http . post < ICandidate [ ] > ( `${ API_PREFIX }/candidate/bulk` , createInput ) ; } setCandidateAsArchived ( id ) { return firstValueFrom ( this . http . put < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` , { isArchived : true } ) ) ; } setCandidateAsHired ( id ) { return firstValueFrom ( this . http . put < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` , { status : CandidateStatus . HIRED } ) ) ; } setCandidateAsRejected ( id ) { return firstValueFrom ( this . http . put < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` , { status : CandidateStatus . REJECTED } ) ) ; } setCandidateAsApplied ( id ) { return firstValueFrom ( this . http . put < ICandidate > ( `${ API_PREFIX }/candidate/${ id }` , { status : CandidateStatus . APPLIED } ) ) ; } }