Example #1
0
 private createRequest(type: string,data ?: Object) : Observable<any> {
   let _url : string = this.buildUrl(data);
   let _request : Observable<any>
   let stringParam : string = '';
   let _jsonBuild : any = {}
   if(_url.split('?')[1] && _url.split('?')[1].length) {
     (_url.split('?')[1].split('&')).forEach( _paramPart => {
       _jsonBuild[_paramPart.split('=')[0]] = _paramPart.split('=')[1]; 
     });
     stringParam = JSON.stringify(_jsonBuild);
   }
   switch (type) {
     case "post":
       _request = this._http.post(_url.split('?')[0], stringParam);
       break;
     case "patch":
       _request = this._http.patch(_url.split('?')[0], stringParam);
       break;
     case "put":
       _request = this._http.put(_url.split('?')[0], stringParam);
       break;
     case "delete":
       _request = this._http.delete(_url);
       break;
     case "head":
       _request = this._http.head(_url);
       break;
     default:
       _request = this._http.get(_url);
       break;
   }
   this._request = _request.map((response: Response) => response.json());
   return this._request;
 }
 follow(link: XLink) {
     console.log(link);
     if (link.method == "PATCH") {
         this.http.patch(link.href, "")
             .subscribe(resp => console.log(resp));
     } else if (link.method == "DELETE")
         this.http.delete(link.href)
             .subscribe(resp => console.log(resp));
 }
    changePassword(form) {
        
        let credentials = {
            old_password: form.value.old_password ? form.value.old_password : "",
            new_password: form.value.new_password ? form.value.new_password : "",
            confirm_new_password: form.value.confirm_new_password ? form.value.confirm_new_password : ""
        };

        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        return this._http.patch('/password', JSON.stringify(credentials), {
            headers: headers
        }).map(res => res.json());

    }
    updateProfile(form) {

        let credentials = {
            email: form.value.email,
            first_name: form.value.first_name,
            last_name: form.value.last_name
        };
        
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');

        return this._http.patch('/users', JSON.stringify(credentials), {
            headers: headers
        }).map(res => res.json());

    }
Example #5
0
    /**update a question*/
    public update(entity:T, onComplete?:() => void) {
        var headers:Headers = SecurityUtils.tokenHeaders();
        headers.append('Content-Type', 'application/json');

        this.http.patch(BaseService.getServerUrl() + this.getUrl()+"/"+this.getId(entity), JSON.stringify(entity), {
                headers: this.getSecurityHeaders()
            })
            .map(res => res.json())
            .subscribe(
                data => console.log('data = ' + data),
                err => console.log(err),
                () => {
                    console.log('Patch complete');
                    if (onComplete) {
                        onComplete();
                    };
                }
            );
        console.log('Question saved');
    }
Example #6
0
File: api.ts Project: nhurman/Lorre
	patch(url: string, body: string, options?: RequestOptionsArgs): Observable<Response>
	{
		url = this.getApiRoot() + url;
		return this.chainLoader(this.http.patch(url, body, options));
	}
 patch(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> {
     url = this.buildUrl(url);
     options = this.prepareOptions(options);
     return this._http.patch(url, body, options);
 }
Example #8
0
 like(item) {
   let body = JSON.stringify({ likes : item.likes });
   let headers = new Headers({'Content-Type' : 'application/json'});
   let options = new RequestOptions({headers : headers});
   return this.http.patch(itemsURL + item.id, body, options).map(res => res.json()).catch(this.handleError);
 }
 patch(url:string, body:string, options?:RequestOptionsArgs):Observable<Response> {
   return this.http.patch(url, body, mergeAuthToken(options));
 }
Example #10
0
 public update(invoice:Invoice):Observable<Response> {
     return this.http.patch('/api/invoice/'+invoice.id, JSON.stringify(invoice));
 }
Example #11
0
 protected patch(route: string, obj : any) {
     return this._http.patch(this._serviceBaseRouteName + route, obj);
 }