import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { ICreateEmailInvitesInput , ICreateEmailInvitesOutput , IInvite , IInviteFindInput , IPublicInviteFindInput , IInviteAcceptInput , IInviteResendInput , IOrganizationContact , IOrganizationContactAcceptInviteInput } from '@gauzy/contracts' ; import { firstValueFrom } from 'rxjs' ; import { API_PREFIX } from '../constants/app.constants' ; @ Injectable ( ) export class InviteService { constructor ( private http ) { } createWithEmails ( createInput ) { return firstValueFrom ( this . http . post < ICreateEmailInvitesOutput > ( `${ API_PREFIX }/invite/emails` , createInput ) ) ; } getAll ( relations , findInput ? ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < { items : IInvite [ ] ; total : number ; } > ( `${ API_PREFIX }/invite` , { params : { data } } ) ) ; } validateInvite ( relations , findInput ) { const data = JSON . stringify ( { relations , findInput } ) ; return firstValueFrom ( this . http . get < IInvite > ( `${ API_PREFIX }/invite/validate` , { params : { data } } ) ) ; } update ( id , updateInput ) { return firstValueFrom ( this . http . put ( `${ API_PREFIX }/invite/${ id }` , updateInput ) ) ; } acceptEmployeeInvite ( acceptInviteInput ) { return firstValueFrom ( this . http . post ( `${ API_PREFIX }/invite/employee` , acceptInviteInput ) ) ; } acceptCandidateInvite ( acceptInviteInput ) { return firstValueFrom ( this . http . post ( `${ API_PREFIX }/invite/candidate` , acceptInviteInput ) ) ; } acceptUserInvite ( acceptInviteInput ) { return firstValueFrom ( this . http . post ( `${ API_PREFIX }/invite/user` , acceptInviteInput ) ) ; } resendInvite ( inviteResendInput ) { return firstValueFrom ( this . http . post ( `${ API_PREFIX }/invite/resend` , inviteResendInput ) ) ; } delete ( id ) { return firstValueFrom ( this . http . delete ( `${ API_PREFIX }/invite/${ id }` ) ) ; } inviteOrganizationContact ( organizationContactId ) { return firstValueFrom ( this . http . put < IOrganizationContact > ( `${ API_PREFIX }/invite/organization-contact/${ organizationContactId }` , { } ) ) ; } acceptOrganizationContactInvite ( acceptInviteInput ) { return firstValueFrom ( this . http . post ( `${ API_PREFIX }/invite/contact` , acceptInviteInput ) ) ; } }