2020-08-06 13:50:08 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {HttpClient} from '@angular/common/http';
|
2020-09-08 16:33:06 +02:00
|
|
|
import {Observable} from 'rxjs';
|
|
|
|
import {properties} from '../../../environments/environment';
|
|
|
|
import {CustomOptions} from './servicesUtils/customOptions.class';
|
|
|
|
import {map} from 'rxjs/operators';
|
2020-08-06 13:50:08 +02:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class UserRegistryService {
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
constructor(private http: HttpClient) {
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public getSubscribersCount(type: string, id: string): Observable<any> {
|
|
|
|
return this.http.get(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/subscribers/count');
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public subscribeTo(type: string, id: string): Observable<any> {
|
|
|
|
return this.http.post(properties.registryUrl + 'subscribe/' + encodeURIComponent(type) + '/' + encodeURIComponent(id),
|
2020-09-08 16:33:06 +02:00
|
|
|
null, CustomOptions.registryOptions());
|
2020-08-06 13:50:08 +02:00
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public unsubscribeFrom(type: string, id: string): Observable<any> {
|
|
|
|
return this.http.post(properties.registryUrl + 'unsubscribe/' + encodeURIComponent(type) + '/' + encodeURIComponent(id),
|
2020-09-08 16:33:06 +02:00
|
|
|
null, CustomOptions.registryOptions());
|
2020-08-06 13:50:08 +02:00
|
|
|
}
|
2020-08-31 13:33:48 +02:00
|
|
|
|
|
|
|
public removeManagerRole(type: string, id: string, email: string): Observable<any> {
|
|
|
|
return this.http.delete<any>(properties.registryUrl +
|
|
|
|
encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/manager/' + encodeURIComponent(email), CustomOptions.registryOptions());
|
|
|
|
}
|
|
|
|
|
2020-09-08 16:33:06 +02:00
|
|
|
public invite(type: string, id: string, email: string, details: any): Observable<any[]> {
|
2020-08-31 13:33:48 +02:00
|
|
|
return this.http.post<any>(properties.registryUrl + 'invite/' +
|
2020-09-08 16:33:06 +02:00
|
|
|
encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/manager/' + encodeURIComponent(email), details,
|
2020-08-31 13:33:48 +02:00
|
|
|
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
|
|
|
}
|
|
|
|
|
|
|
|
public cancelInvitation(type: string, id: string, email: string): Observable<any> {
|
|
|
|
return this.http.delete<any>(properties.registryUrl + 'invite/' +
|
|
|
|
encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/manager/' + encodeURIComponent(email),
|
|
|
|
CustomOptions.registryOptions());
|
|
|
|
}
|
|
|
|
|
|
|
|
public getPendingManagers(type: string, id: string): Observable<any[]> {
|
|
|
|
return this.http.get<any>(properties.registryUrl + 'invite/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/managers/',
|
|
|
|
CustomOptions.registryOptions()).pipe(map((response: any) => response.response));
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public getSubscribers(type: string, id: string): Observable<any[]> {
|
|
|
|
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/subscribers/').pipe(map(response => response.response));
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public getManagers(type: string, id: string): Observable<any[]> {
|
|
|
|
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/managers/').pipe(map(response => response.response));
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public getSubscribersEmail(type: string, id: string): Observable<any[]> {
|
|
|
|
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/subscribers/email').pipe(map(response => response.response));
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-12 17:16:09 +02:00
|
|
|
public getInvitation(id: string): Observable<any> {
|
2020-09-08 16:33:06 +02:00
|
|
|
return this.http.get<any>(properties.registryUrl + 'verification/' + encodeURIComponent(id), CustomOptions.registryOptions())
|
2020-08-14 11:54:12 +02:00
|
|
|
.pipe(map((response: any) => response.response));
|
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-14 11:54:12 +02:00
|
|
|
public verify(id: string, code: string): Observable<any> {
|
2020-09-08 16:33:06 +02:00
|
|
|
return this.http.post<any>(properties.registryUrl + 'verification/' + encodeURIComponent(id), code, CustomOptions.registryOptions());
|
2020-08-14 11:54:12 +02:00
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-14 11:54:12 +02:00
|
|
|
public deleteVerification(id: string): Observable<any> {
|
2020-09-08 16:33:06 +02:00
|
|
|
return this.http.delete<any>(properties.registryUrl + 'verification/' + encodeURIComponent(id), CustomOptions.registryOptions());
|
2020-08-12 17:16:09 +02:00
|
|
|
}
|
2020-09-08 16:33:06 +02:00
|
|
|
|
2020-08-06 13:50:08 +02:00
|
|
|
public getManagersEmail(type: string, id: string): Observable<any[]> {
|
|
|
|
return this.http.get<any>(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/managers/email').pipe(map(response => response.response));
|
|
|
|
}
|
|
|
|
}
|