updateLocales(map: Map<String, String>, lang) {
   let body = '{';
   if (map) {
     map.forEach((value: string, key: string) => {
       body += '"' + key + '":' + '"' + value + '",';
     });
   }
   body = body.slice(0, -1);
   body += '}';
   return this.http.put(httpApiHost + '/locales/' + lang, body, httpJsonOptions);
 }
 update<T extends Identifiable>(kind: ResourceType<T>, item: T): Observable<T> {
   const collectionPath = getCollectionPath(kind.typeId);
   const uri = `${API_BASE_URL}/${collectionPath}/${item.id}`;
   return this.http
     .put<T>(uri, item)
     .pipe(
       tap(entity => this.logger.log(`Updated ${kind.typeId}: ${JSON.stringify(entity)}.`)),
       retryAfter(2, 1000),
       catchError(this.handleError),
     );
 }
 updateVoucher(){
   var id = 1002;
   var url = "/api/vouchers/" + id;
   var vtu = { "ID": id, "Text": "Updated by Angular", "Date": "2016-04-22T16:59:32.086", "Amount": 99, "Paid": true, "Expense": false, "VATRate" : 20 };
   
   this.httpClient.put('http://localhost:5000/api/vouchers', vtu)
   .toPromise()
   .then((response)=>{
     console.log('voucher updated');
     this.result = response;})
 }
Ejemplo n.º 4
0
 public updateApi(
   api: Api,
   namespace: string,
   token: string,
 ): Observable<Api> {
   const httpOptions = this.getHTTPOptions(token);
   const url = `${AppConfig.apisApiUrl}/namespaces/${namespace}/apis/${
     api.metadata.name
   }`;
   return this.http.put<Api>(url, api, httpOptions);
 }
    /**
     * Manage an existing user or create a new one.
     *
     * @param {User} user
     * @param operation whether we're creating a new user or updating an existing one
     */
    manageUser(user: User, operation: UserOperations = UserOperations.CREATE): Observable<any> {
        let url = '/api/users';

        if (operation === UserOperations.UPDATE) {
            url += `/${user.username}`;
        }

        return this.http
            .put(url, user)
            .pipe(map(r => plainToClass(ApiResponse, r)));
    }
Ejemplo n.º 6
0
 save_changes_to_comic(comic: Comic, series: string, volume: string, issue_number: string): Observable<any> {
   const params = new HttpParams()
     .set('series', series)
     .set('volume', volume)
     .set('issue_number', issue_number);
   return this.http.put(`${COMIC_SERVICE_API_URL}/comics/${comic.id}`, params)
     .finally(() => {
       comic.series = series;
       comic.volume = volume;
       comic.issue_number = issue_number;
     });
 }
 update<T extends Identifiable>(kind: Type<T>, item: T): Observable<T> {
   const uri = `${BASE_API_URI}${API_ENDPOINTS[kind.name]}/${item.id}`;
   return this.http
     .put<CustomResponse<T>>(uri, item)
     .pipe(
       tap(entity => this.logger.log(`Response: ${JSON.stringify(entity)}.`)),
       map(productResponse => productResponse.data),
       tap(entity => this.logger.log(`Updated: ${JSON.stringify(entity)}.`)),
       retryAfter(3, 1000),
       catchError(this.handleError),
     );
 }
 /**
  *
  *
  * @param {any} params
  * @returns
  *
  * @memberof CheckoutService
  */
 updateOrder(params: any) {
   const url = `api/v1/checkouts/${
     this.orderNumber
     }.json?order_token=${this.getOrderToken()}`;
   return this.http
     .put<Order>(url, params)
     .pipe(
       map(order =>
         this.store.dispatch(this.actions.updateOrderSuccess(order))
       )
     );
 }
 /**
  *
  *
  * @returns
  *
  * @memberof CheckoutService
  */
 changeOrderState() {
   const url = `api/v1/checkouts/${
     this.orderNumber
     }/next.json?order_token=${this.getOrderToken()}`;
   return this.http
     .put<Order>(url, {})
     .pipe(
       map(order =>
         this.store.dispatch(this.actions.changeOrderStateSuccess(order))
       )
     );
 }
Ejemplo n.º 10
0
	/**
	 * Responds to a message by calling a trigger endpoint for a given workflow's execution ID.
	 * @param workflow_execution_id Execution ID of workflow to trigger
	 * @param action Action to send to trigger endpoint
	 */
	respondToMessage(workflow_execution_id: string, action: string): Promise<string[]> {
		const arg = new Argument();
		arg.name = 'action';
		arg.value = action;
		const body: object = {
			execution_ids: [workflow_execution_id],
			data_in: action,
			arguments: [arg],
		};
		return this.http.put('/api/triggers/send_data', body)
			.toPromise()
			.catch(this.utils.handleResponseError);
	}
Ejemplo n.º 11
0
 shield(post){
   this.http.put('/api/post/'+post._id, {isShielded: true}).subscribe();
   post.isShielded = true;
   this._notificationsService.alert(
     '成功隐藏博客',
     '管理员大大辛苦啦~',
     {
         timeOut: 2000,
         showProgressBar: true,
         pauseOnHover: true,
         clickToClose: false
     });
 }
Ejemplo n.º 12
0
    saveArticle(id: number, edits: string, title: string, description: string, tags: string[], coverPhoto?: FormData): Observable<any> {
        const author = this.authorService.getAuthorUsername();

        const post = {
            text: edits,
            title: title,
            description: description,
            tags,
            author: author
        };

        if (coverPhoto) {
            return forkJoin(
                this.http.put(`${environment.URL}/article/${id}`, post),
                this.http.post(`${environment.URL}/article/${id}`, coverPhoto)
            );
        } else {
            return forkJoin(
                this.http.put(`${environment.URL}/article/${id}`, post)
            );
        }
    }
Ejemplo n.º 13
0
 Unshield(post){
   this.http.put('/api/post/'+post._id, {isShielded: false}).subscribe();
   post.isShielded = false;
   this._notificationsService.info(
     '取消隐藏博客',
     '文明上网~',
     {
         timeOut: 2000,
         showProgressBar: true,
         pauseOnHover: true,
         clickToClose: false
     });
 }
Ejemplo n.º 14
0
 updateAddress(updatedAddress, addressId,orderNumber){
 const url = `api/v1/orders/${orderNumber}/addresses/${addressId}?`
 +`address[firstname]=${updatedAddress.firstname}`
 +`&address[lastname]=${updatedAddress.lastname}`
 +`&address[address1]=${updatedAddress.address1}`
 +`&address[address2]=${updatedAddress.address2}`
 +`&address[city]=${updatedAddress.city}`
 +`&address[state_name]=${updatedAddress.state_name}`
 +`&address[phone]=${updatedAddress.phone}`
 +`&address[zipcode]=${updatedAddress.zipcode}`
 +`&address[state_id]=${updatedAddress.state_id}`
 +`&address[country_id]=${updatedAddress.country_id}`
 return this.http.put(url, {})
 }
 updateResource(jsonData) {
   return this.httpClient
     .put(`${AppConfig.k8sServerUrl}${jsonData.metadata.selfLink}`, jsonData)
     .pipe(
       map(
         data => {
           return data;
         },
         err => {
           throw err;
         }
       )
     );
 }
Ejemplo n.º 16
0
 saveNote(note: Note): Observable<any> {
   if (note.url) {
     if (note.content) {
       return this.httpClient.put(note.url, note.toObject(), this.getHttpOptions()).map(resp => note);
     }
     return this.httpClient.delete(note.url, this.getHttpOptions()).map(resp => {
       note.url = '';
       return note;
     });
   }
   return this.httpClient.post(this.urlFixer.fixAnno(this.annotationSet._links['add-annotation'].href),
                               note.toObject(),
                               this.getHttpOptions())
     .map(annotation => this.newNoteFromAnnotation(annotation));
 }
Ejemplo n.º 17
0
  public submitRequest(request: any): Observable<any> {

    console.log('submitRequest');
    console.log(this.globals_service.site.restApiUrl);
    console.log(request);

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

    return this.authHttp.put(
      this.globals_service.site.restApiUrl + '/requests',
      JSON.stringify({request:request}),
      {headers:header}
    );
    // .map(res => res.json());
  }
Ejemplo n.º 18
0
 addNewObject(rootDn:string, mustAttrMap:any, mayAttrMap:any): Observable<string[]> {
     let headers = this.authService.getAuthHeader();
     if(mustAttrMap['cn'] && mustAttrMap['cn'].length){
         mayAttrMap['cn'] = '';
     }
     let jsonObj:any = {};
     jsonObj.dn = rootDn;
     jsonObj.attributes = this.constructObjectAddJsonBody(mustAttrMap, mayAttrMap);
     let body = JSON.stringify(jsonObj);
     let addUrl = 'https://' + this.domain + ':' + this.configService.API_PORT + '/v1/vmdir/ldap';
     console.log(addUrl);
     return this.httpClient.put(addUrl, body, {headers})
            .share()
            .map((res: Response) => res)
            .catch(this.handleError)
 }
Ejemplo n.º 19
0
 /**
  *
  *
  * @param {User} data
  * @returns {Observable<any>}
  * @memberof AuthService
  */
 updatePassword(data: User): Observable<void | ActiveToast<any>> {
   return this.http
     .put(`auth/passwords/${data.id}`, { spree_user: data })
     .pipe(
       map(_ =>
         this.toastrService.success(
           'Password updated success fully!',
           'Success'
         )
       ),
       tap(
         _ => _,
         _ => this.toastrService.error('Unable to update password', 'ERROR!')
       )
     );
 }
Ejemplo n.º 20
0
  protected doPutRequest(path:string, pathParams?: Array<any>, queryParams?: Array<any>, body?: Array<any> | null): Observable<any> {
    let url: string = 'https://' + CONFIG.home_api_address + ':' + CONFIG.home_api_port + path;

    if (pathParams != null) {
      pathParams.forEach((param, index) => {
        for (let paramKey in param)
        url = url.replace("{" + paramKey + "}", param[paramKey]);
      });
    }
    let httpParams: HttpParams = this.getQueryParams(queryParams);

    return this.http.put(url, body, {
        headers: this.getAuthHeader(),
        params: httpParams,
        responseType: "text"
      });
  }
Ejemplo n.º 21
0
 put(row: any): Promise<any> {
   const headers = this.getAuthHeaders();
   let url;
   if (Array.isArray(this.primaryKeys) && this.primaryKeys.length > 1) {
     url = this.url + '?';
     for (const key of this.primaryKeys) {
       url += key + '=' + row[key] + '&';
     }
     url = url.slice(0, -1);
   } else {
     url = (this.primaryKeys) ? `${this.url}/${row[this.primaryKeys[0]]}` : this.url;
   }
   return this.http
     .put(url, JSON.stringify(row), {headers: headers})
     .toPromise()
     .then(res => res)
     .catch(this.handleError);
 }
Ejemplo n.º 22
0
  public set_plugin_state(name: string, operation: PluginOpRequest, pretty?: boolean): Observable<PluginOpResponse>
  {
    if (name === null || name == undefined) {
      throw new Error("Required parameter name is null or undefined (set_plugin_state)");
    }
    if (operation === null || operation == undefined) {
      throw new Error("Required parameter operation is null or undefined (set_plugin_state)");
    }
		let params = new HttpParams();
		if (pretty) {
		  params = params.set("pretty", pretty.toString());
		}
    let headers = new HttpHeaders();
		
    headers = headers.set('Accept', 'application/json');
    return this.http.put<PluginOpResponse>(`${this.backend.url_for('api')}/plugins/${encodeURIComponent(String(name))}`, operation, 
		  { headers: headers, params: params,
		    observe: 'body', responseType: 'json' })	;
	}
Ejemplo n.º 23
0
 public updateBlog(blog: Blog): any {
   if (blog.id !== undefined) {
     // update
     return this.http.put<Blog[]>(this.url + '/' + blog.id, blog)
     .pipe(
       catchError(err => {
         this.handleError(err);
         return [];
       })
     );
   }
   // new
   return this.http.post(this.url, blog)
   .pipe(
     catchError(err => {
       this.handleError(err);
       return [];
     })
   );
 }
Ejemplo n.º 24
0
  updateVisitorPassword(email: string, current_password: string, password: string): Promise<Auth | AuthError> {
    const httpOptions = {
      headers: {
        'Accept':  'application/json',
        'X-Visitor-Token': this.token
      }
    };
    const url = this.buildUrl('/visitors');

    const data = {
      email: email,
      current_password: current_password,
      password: password
    };

    return this.http
      .put<any>(url, data, httpOptions)
      .toPromise()
      .then((response) => {
        return response;
      })
      .catch(this.handleError);
  }
Ejemplo n.º 25
0
  editChannel(channelFormData: Channel, channel: Channel) {
    const payload = {
      name: channelFormData.name
    };

    const editChannel = this.http.put(environment.channelsUrl + '/' + channel.id, payload);

    return editChannel.switchMap(() => {
      const thingsToAdd = this.getThingsToAdd(channelFormData, channel);
      if (thingsToAdd.length) {
        return forkJoin(this.createThingsConnectRequests(channel.id, thingsToAdd));
      } else {
        return Observable.of([]);
      }
    }).switchMap(() => {
      const thingsToDelete = this.getThingsToDelete(channelFormData, channel);
      console.log(thingsToDelete);
      if (thingsToDelete.length) {
        return forkJoin(this.createThingsDisconnectRequests(channel.id, thingsToDelete));
      } else {
        return Observable.of([]);
      }
    });
  }
Ejemplo n.º 26
0
 updateUiDesign(designName: String): Promise<UiDesign> {
   return this.http.put<UiDesign>(`${environment.endpoint}/ui`, designName).toPromise();
 }
 put<T>(url: string, body: string): Observable<T> {
     return this.http.put<T>(url, body);
 }
Ejemplo n.º 28
0
 put(path: string, body: Object = {}): Observable<any> {
   return this.http.put(
     `${environment.backendURL}${path}`,
     JSON.stringify(body)
   ).pipe(catchError(this.formatErrors));
 }
Ejemplo n.º 29
0
 saveSettings(settings): Observable<any> {
   return this.http.put<any>(`api/settings`, { settings: settings });
 }
 put<TResponseBody>(url: string, data?: any): Observable<HttpResponse<TResponseBody>> {
     return this.httpClient.put<TResponseBody>(url, JSON.stringify(data), { observe: 'response' });
 }