2018-01-05 16:40:19 +01:00
|
|
|
import { HttpHeaders } from '@angular/common/http';
|
2018-11-27 15:13:56 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
2018-10-12 17:17:31 +02:00
|
|
|
import { Observable } from 'rxjs';
|
2018-11-27 15:13:56 +01:00
|
|
|
import { environment } from '../../../environments/environment';
|
|
|
|
import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInvitationCriteria';
|
2018-01-05 16:40:19 +01:00
|
|
|
import { RequestItem } from '../../models/criteria/RequestItem';
|
2018-11-27 15:13:56 +01:00
|
|
|
import { Invitation } from '../../models/invitation/Invitation';
|
|
|
|
import { User } from '../../models/invitation/User';
|
|
|
|
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
|
2018-01-05 16:40:19 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class InvitationService {
|
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
private actionUrl: string;
|
|
|
|
private headers: HttpHeaders;
|
2018-01-05 16:40:19 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
constructor(private http: BaseHttpService) {
|
2018-01-05 16:40:19 +01:00
|
|
|
|
2018-11-27 15:13:56 +01:00
|
|
|
this.actionUrl = environment.Server + 'invite/';
|
2018-01-05 16:40:19 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
this.headers = new HttpHeaders();
|
|
|
|
this.headers = this.headers.set('Content-Type', 'application/json');
|
|
|
|
this.headers = this.headers.set('Accept', 'application/json');
|
|
|
|
}
|
2018-01-05 16:40:19 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public inviteUsers(invitation: Invitation): Observable<User[]> {
|
|
|
|
return this.http.post<User[]>(this.actionUrl + 'users', invitation, { headers: this.headers });
|
|
|
|
}
|
2018-01-05 16:40:19 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public getUsers(usersInvitationRequestItem: RequestItem<UserInvitationCriteria>): Observable<User[]> {
|
|
|
|
return this.http.post<User[]>(this.actionUrl + 'getUsers', usersInvitationRequestItem, { headers: this.headers });
|
|
|
|
}
|
2018-01-08 12:44:48 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public exchange(id: String): Observable<String> {
|
|
|
|
return this.http.get<String>(this.actionUrl + 'exchange/' + id, { headers: this.headers });
|
|
|
|
}
|
|
|
|
}
|