import { Injectable } from '@angular/core' ; import { HttpClient , HttpHeaders , HttpParams } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { ApiResponse , PushApiResponse } from '../models' ; import { defaultUrlConfig } from '../shared/url-config' ; @ Injectable ( { providedIn : 'root' } ) export class PushService { constructor ( private http ) { } public postData ( data ) { const httpUrl = defaultUrlConfig . loklak . apiServer + '/api/push.json' ; const headers = new HttpHeaders ( { 'Content-Type' : 'application/x-www-form-urlencoded' , 'Accept' : 'application/json' , 'cache-control' : 'no-cache' } ) ; const { statuses } = data ; const searchMetadata = data . search_metadata ; const dataToSend = JSON . stringify ( { search_metadata : searchMetadata , statuses } ) ; const body = new HttpParams ( ) . set ( 'data' , dataToSend ) ; return this . http . post < PushApiResponse > ( httpUrl , body , { headers } ) ; } }