Project

General

Profile

1
import { Injectable } from '@angular/core';
2
import { Http, Response, Headers, RequestOptions } from '@angular/http';
3
import { Observable } from 'rxjs/Rx';
4
import {COOKIE} from "../../openaireLibrary/login/utils/helper.class"
5

    
6

    
7
@Injectable()
8
export class InviteService {
9

    
10
  constructor(private http:Http) {
11
    }
12
     inviteUsers(url:string, subject:string, body:string, recipients:string[]){
13
       var email = {"subject":subject, "body":body, recipients: recipients };
14
       return this.http.post(url+"/email", JSON.stringify(email), this.getAuthOptionsWithBody())
15
           .map(res => <any> res.json())
16
           .do(res => {console.log("Response is "+res)});
17
     }
18
     public getAuthOptionsWithBody():RequestOptions{
19
     let headers = new Headers();
20
     headers.append('Content-Type', 'application/json');
21
     headers.append('X-XSRF-TOKEN',  COOKIE.getCookie(COOKIE.cookieName_id));
22
     let options = new RequestOptions({ headers: headers, withCredentials:true  });
23
       return options;
24
     }
25

    
26
}
(3-3/5)