import { Injectable, Inject } from '@angular/core'; // import { Response } from '@angular/http'; import { throwError, Observable } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; // import { Moment } from 'moment'; import { PodAppConfig, POD_APP_PARAMS, PodHttpService } from '@monsantoit/pod-ui-commons-lib'; import { MASTERDATA_STATE_IT_URL, MASTERDATA_CITY_IT_URL } from '../utils/endpoints'; @Injectable({ providedIn: 'root' }) export class LocationService { constructor( @Inject(POD_APP_PARAMS) private appConfig: PodAppConfig, private http: PodHttpService ) {} /** * get all registered states */ getStates(): Observable { return this.http.get( MASTERDATA_STATE_IT_URL, true ); } /** * get cities for the provided state code * * @param stateCode IBGE state code */ getCities(stateCode: string): Observable { return this.http.get( MASTERDATA_STATE_IT_URL + `${stateCode}/city`, true ); } /** * * @param zipCode */ getAddress(zipCode: string): Observable { return this.http.get(`http://localhost:3000/v1/growers/location/${zipCode}`, true); } }