saveStory(userId, story:Story):Observable<Story> {
        let headers = new Headers({
            'Content-Type': 'application/x-www-form-urlencoded'
        });

        let options = new RequestOptions({
            headers: headers
        });
        story.userId = userId;

        if (!!story._id) {
            story.createdAt = story.createdAt || (new Date());
            story.lastModifiedAt = (new Date());
            return this.http.put(this.configuration.apiBasePath + '/story/' + userId + '/'+ story._id , "data=" + JSON.stringify(story), options)
                .map(res => res.json())
                .catch(this.logger.errorCatcher());
        }
        else {
            story.createdAt = (new Date());
            story.lastModifiedAt = (new Date());
            return this.http.post(this.configuration.apiBasePath + '/story/' + userId + '/', "data=" + JSON.stringify(story), options)
                .map(res => res.json())
                .catch(this.logger.errorCatcher());
        }
    }
Example #2
0
 getUseRestriction(questions: string): Observable<Response> {
     let headers = new Headers();
     headers.append('Content-Type', 'application/json');
     return this.http.put(AppSettings.DAR_USERESTRICTION_ENDPOINT, questions, {
         headers: headers
     });
 }
Example #3
0
	update(form: Form) {
		return this._http.put(
			Config.api('form/'+form.id),
			JSON.stringify(form),
			this.headers()
		);	
	}
Example #4
0
 saveSelectionForComp(compId:String, selection:Selection):Observable<Response> {
     // /auth/ URLs are protected by the middleware
     return this._http.put(BASE_URL + '/auth/competition/selection/push/' + compId, JSON.stringify(selection), {
             headers: json()
         })
         .share();
 }
    updatePerson(data: string, http: Http) {
        var config = new Config();
        let headers = new Headers({ 'Content-Type': 'application/json' });
        var options = new RequestOptions({ headers: headers });

        return http.put(config.apiBaseUrl + "People", data, options).toPromise();
    };
 saveBlog(blog: BlogEntry): Observable<Response> {
     if (blog.id) {
         return this.http.put('/api/blogs/' + blog.id, blog.json(), this.opts);
     } else {
         return this.http.post('/api/blogs', blog.json(), this.opts);
     }
 }
Example #7
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;
 }
 updateGame(game: Game) {
     this.http.put(`${BASE_URL}/${game.id}`, JSON.stringify(game), HEADER)
         .subscribe(
             action => this.store.dispatch({ type: 'UPDATE_GAME', payload: game }),
             error => console.log('Error: ' + error)
         );
 }
 update(band: Band) {
     return this._http.put(this.baseAPIUrl + 'band/' + band.id + '/', JSON.stringify({
         name: band.name,
         description: band.description
     }), this.getHeaders())
         .map(res => res.json())
 }
Example #10
0
 //AƱadir contenido al usuario
 addContenido(producto: Prod, usuario: Usuario){
   usuario.coleccion.push(producto);
   if(producto.tipoprod == 3){
     usuario.nPelis = usuario.nPelis + 1;
   }
   if(producto.tipoprod == 2){
     usuario.nSeries = usuario.nSeries + 1;
   }
   if(producto.tipoprod == 1){
     usuario.nJuegos = usuario.nJuegos + 1;
   }
   let cambio = JSON.stringify(usuario);
   let headers = new Headers({
     'Content-Type': 'application/json',
     'X-Requested-With': 'XMLHttpRequest'
   });
   let options = new RequestOptions({headers});
   return this.http.put(BASE_URL + usuario.id, cambio, options)
   .map(
     response => response.json()
   )
   .catch(
     error => this.handleError(error)
   );
 }
  addFollow(idSeguidor:string,idSeguido:string){
    let url = URL + 'add'+'/'+idSeguidor+'/'+idSeguido;

    return this.http.put(url,'')
        .map(response => response.json())
        .catch(error => this.handleError(error));
  }
  removeFollow(idSeguidor,idSeguido){
    let url = URL + 'remove' + '/'+idSeguidor+'/'+idSeguido;

    return this.http.put(url,'')
      .map(response => response.json())
      .catch(error => this.handleError(error));
  }
	update(participant: Participant) {
		return this._http.put(
			Config.api('participant/'+participant.id),
			JSON.stringify(participant),
			this.headers()
		);	
	}
 put(url: string, body: string) {
   let headers = new Headers({ 'Content-Type': 'application/json' });
   let options = new RequestOptions({ headers: headers });
   return this.http.put(url, body, options)
     .map(this.extractData)
     .catch(this.handleError);
 }
Example #15
0
 updateStatus(compId:String, status:Status):Observable<Response> {
     var payload = {
         status: status.value
     };
     return this._http.put(BASE_URL + '/auth/competition/status/' + compId, JSON.stringify(payload), {
         headers: json()
     });
 }
  involveInCrisis(collection, superId, crisisId): Rx.Observable<Crisis> {
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this._http.put(`api/v1/${collection}/${superId}/crises/${crisisId}`, null, options)
      .map(res => res.json().data)
      .catch(this._handleError);
  }
  setFecha (date, id){
    let body = date;
    let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
    let options = new RequestOptions({headers});

    return this.http.put('/editDateEvent/'+id, body, options);

  }
 saveBlog(blog: BlogEntry): Observable<Response> {
   console.log('saving', blog.json());
   if (blog.id) {
     return this.http.put('/api/blogs/' + blog.id, blog.json(), this.getOptions());
   } else {
     return this.http.post('/api/blogs', blog.json(), this.getOptions());
   }
 }
Example #19
0
    getAllPag(pag, filters) {
        var queryHeaders = new Headers();
        queryHeaders.append('Content-Type', 'application/json');

        return  this.http.put('http://localhost:8000/api/todopag/' + pag, JSON.stringify(filters),{headers : queryHeaders}).
        toPromise().
        then((res:Response) => res.json(), err => console.log(err));
    }
  deleteInstrument(inst){
    let body = inst;

    let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
    let options = new RequestOptions({headers});

    return this.http.put('/deleteInstr/' + Info.userId, body, options);
  }
  setFacebook(link){
    let body = link;

    let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
    let options = new RequestOptions({headers});

    return this.http.put('/editFacebookLink/' + Info.userId , body, options);
  }
  deleteGenre(genre:Genre){
    let body = '{ "name": "' + genre.name + '"}';

    let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
    let options = new RequestOptions({headers});

    return this.http.put('/deleteGenre/' + Info.userId, body, options);
  }
    /* Http POSTs */
    setRead(id){
        let body = "";

        let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
        let options = new RequestOptions({headers});

        return this.http.put('/message/setRead/' + id , body, options);
    }
  setCity(city){
    let body = city;

    let headers = new Headers({'Content-Type': 'application/json;charset=UTF-8'});
    let options = new RequestOptions({headers});

    return this.http.put('/editCity/' + Info.userId , body, options);
  }
Example #25
0
 public editOrder(value){
   let params = JSON.stringify(value);
   console.log(params);
   let headers = new Headers({ 'Content-Type': 'application/json' });
   let options = new RequestOptions({ headers: headers });
   let url = Config.RESTServer + `orders?_id=` + value.id;
   return this.http.put(url, params,options).map((res) => res.json());
 }
  updateCrisis(crisis: Crisis): Rx.Observable<Crisis> {
    let body = JSON.stringify({ crisis });
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this._http.put(`api/v1/crises/${crisis['_id']}`, body, options)
      .map(res => res.json().data)
      .catch(this._handleError);
  }
	addfriend(id){
		let add = '/api/account/user/'+id +'/';
		return this._http.put(add,'{}')
					.map((res:Response)=>{return 'success'} )
					.catch((err: Response) => {
						console.log(err);
						return Observable.throw(err.json() || "Server Error");
					});
	}
	accept(id){
		let url = '/api/msg/friend/' + id +'/';
		return this._http.put(url,'{}')
					.map((res:Response)=>{return 'success'} )
					.catch((err: Response) => {
						console.log(err);
						return Observable.throw(err.json() || "Server Error");
					});
	}
Example #29
0
    put(name: string, body?: Object): Observable<Response> {
        body = this.getBody(body);

        return this._http.put(CONSTANTS.getURL(name), JSON.stringify(body), {
            headers: this.getHeaders()
        }).map(response => {
            return response.json();
        });
    }
  updateSuper(collection: string, model: Super): Rx.Observable<I> {
    let body = JSON.stringify({ model });
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this._http.put(`api/v1/${collection}/${model['_id']}`, body, options)
      .map(res => res.json().data)
      .catch(this._handleError);
  }