1
|
import {Injectable} from '@angular/core';
|
2
|
import {Http, Response, Headers, RequestOptions} from '@angular/http';
|
3
|
import {HttpClient} from "@angular/common/http";
|
4
|
import {Email} from './email';
|
5
|
import {CustomOptions} from '../../services/servicesUtils/customOptions.class';
|
6
|
import {EmailRecaptcha} from "../entities/EmailRecaptcha";
|
7
|
import {Observable} from "rxjs";
|
8
|
import {EnvProperties} from "../properties/env-properties";
|
9
|
|
10
|
@Injectable()
|
11
|
export class EmailService {
|
12
|
|
13
|
constructor(private http:HttpClient) {
|
14
|
}
|
15
|
|
16
|
notifyForNewManagers(properties: EnvProperties, pid: string, email: Email) {
|
17
|
let body = JSON.stringify(email);
|
18
|
|
19
|
return this.http.post(properties.adminToolsAPIURL + "/notifyForNewSubscribers/" + pid, body, CustomOptions.getAuthOptionsWithBody());
|
20
|
//.map(request => request.json());
|
21
|
}
|
22
|
|
23
|
sendEmail(properties: EnvProperties, email: Email) {
|
24
|
let body = JSON.stringify(email);
|
25
|
|
26
|
return this.http.post(properties.adminToolsAPIURL + "/sendMail/", body, CustomOptions.getAuthOptionsWithBody());
|
27
|
//.map(request => request.json());
|
28
|
}
|
29
|
|
30
|
contact(properties: EnvProperties, email: Email, recaptcha: string = null):Observable<boolean> {
|
31
|
const data: EmailRecaptcha = new EmailRecaptcha();
|
32
|
data.email = email;
|
33
|
data.recaptcha = recaptcha;
|
34
|
return this.http.post<boolean>(properties.adminToolsAPIURL + '/contact', data);
|
35
|
}
|
36
|
|
37
|
}
|