import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { environment } from 'src/environments/environment'; import { AuthService } from '../auth/services/auth.service'; import { Billing } from '../models/billing.model'; import { Checkout } from '../models/checkout.model'; import { Departamento } from '../models/departamento.model'; import { PartnerSales } from '../models/partners-sales.model'; import { PaymentPlan } from '../models/payment-plan.model'; import { Place } from '../models/places.model'; import { ResultApi } from '../models/result-api.model'; import { StoreERP } from '../models/store.model'; import { User } from '../models/user.model'; import { Seller } from '../models/seller.model'; import { CategoryPartner } from '../models/category-partner.model'; import { Ramo } from '../models/ramo.model'; @Injectable({ providedIn: 'root' }) export class LookupService { constructor( private http: HttpClient, private authService: AuthService, ) { } getStore(): Observable { const url = environment.url + `lists/store/user/${this.authService.getUser()}`; try { const response = this.http.get(url); return response; } catch (e) { console.log('Erro ao consultar filiais'); console.log(e); } } getCheckout(store: string): Observable { const url = environment.url + `lists/checkout/${store}`; try { const response = this.http.get(url); return response; } catch (e) { console.log('Erro ao consultar caixas da filial'); console.log(e); } } getUser(store: string): Observable { const url = environment.url + `lists/user/${store}`; try { const response = this.http.get(url); return response; } catch (e) { console.log('Erro ao consultar usuários da filial'); console.log(e); } } getPaymentPlan(billingId: string = '9999', customerId: number = 1): Observable { const url = environment.url + `lists/paymentplan/${billingId}/${customerId}`; try { const response = this.http.get(url); return response; } catch (e) { console.log('Erro ao consultar planos de pagamentos'); console.log(e); } } getBilling(customerId: number): Observable { const url = environment.url + `lists/billing/${customerId}`; try { const response = this.http.get(url); return response; } catch (e) { console.log('Erro ao consultar cobrancas'); console.log(e); } } getDepartments(): Observable { const url = environment.url + `department/all`; try { const response = this.http.get(url).pipe(map(result => result.data)); return response; } catch (e) { console.log('Erro ao consultar departamentos'); console.log(e); } } getPartners(): Observable { const url = environment.url + `lists/partners`; return this.http.get(url); } getSellers(): Observable { console.log('pesquisando sellers'); const url = environment.url + `sellers`; return this.http.get(url); } getCategoryPartner(): Observable { const url = environment.url + `partner/category`; return this.http.get(url); } getPlaces(): Observable { const url = environment.url + `lists/places`; return this.http.get(url); } getStorePlaces(): Observable { const url = environment.url + `lists/store-places`; return this.http.get(url); } getRamos(): Observable { const url = environment.url + `lists/ramo`; return this.http.get(url); } getSupervisores(): Observable { const url = environment.url + `lists/supervisores`; return this.http.get(url); } }