Files
Jobhero_front/src/app/services/ichamba.service.ts
Carlos aa8b0061c9 feat: Actualización general de la aplicación
- Contratos, tarjetas, postulaciones, categorías y reportes
- Servicios: auth, ichamba, env, language, firebase, interceptor
- Guards, modelos, componentes y páginas de verificación
- Configuración: angular.json, tsconfig, polyfills, environments
- Capacitor: capacitor.config.json y android settings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 08:18:40 -06:00

216 lines
8.8 KiB
TypeScript
Executable File

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { EnvService } from './env.service';
import { AuthService } from './auth.service';
@Injectable({
providedIn: 'root'
})
export class IchambaService {
constructor(
private http: HttpClient,
private env: EnvService,
private authService: AuthService,
) { }
getCategories() {
return this.http.get<any[]>(this.env.API_URL + 'categories-name');
}
getEnCategories() {
return this.http.get<any[]>(this.env.API_URL + 'en-categories-name');
}
getParameters() {
return this.http.get<any[]>(this.env.API_URL + 'parameters');
}
getBanks() {
return this.http.get<any[]>(this.env.API_URL + 'banks');
}
checkCategories(category_string: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'check-category' + '?category=' + category_string,
{ headers: headers });
}
addCard(token: String, device_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'payments/addcard',
{token: token, device_id: device_id}, { headers: headers });
}
addPostulation(category: String, address: String, int_number: String, references: String, lat: Number, lng: Number, setdate: String, sethour:String, details: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'create-postulation',
{category: category, address: address, int_number: int_number, references: references, lat: lat, lng: lng, setdate: setdate, sethour:sethour, details: details}, { headers: headers });
}
deleteCard(card_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'payments/deletecard',
{card_id: card_id}, { headers: headers });
}
getCard() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'payments/getcards',
{ headers: headers });
}
getPostulation() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'get-postulations',
{ headers: headers });
}
getContractedPostulation() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'get-contracted-postulations',
{ headers: headers });
}
getFinishedPostulation() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'get-finished-postulations',
{ headers: headers });
}
getPendingcontracts() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'contracts/pending',
{ headers: headers });
}
getCurrentcontracts() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'contracts/current',
{ headers: headers });
}
getFinishedcontracts() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'contracts/finished',
{ headers: headers });
}
setPostulation(postulation_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'postulate',
{postulation_id: postulation_id}, { headers: headers });
}
getPostulants(postulation_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'get-postulants' + '?postulation_id=' + postulation_id,
{ headers: headers });
}
checkCoupon(postulation_id: String, supplier_id: String, coupon: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/coupon',
{ postulation_id: postulation_id, supplier_id: supplier_id, coupon: coupon}, { headers: headers });
}
createContract(postulation_id: String, supplier_id: String, card_id: String, coupon: String, code: String, device_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/create',
{ postulation_id: postulation_id, supplier_id: supplier_id, card_id: card_id, coupon: coupon, code: code, device_id: device_id }, { headers: headers });
}
cancelContract(contract_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/cancel',
{ contract_id: contract_id }, { headers: headers });
}
startContract(contract_pin: Number) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/start',
{ contract_pin: contract_pin }, { headers: headers });
}
reviewContract(contract_id: Number, rate: Number, comment: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/review',
{ contract_id: contract_id, rate: rate, comment: comment }, { headers: headers });
}
reportContract(contract_id: Number, comment: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/report',
{ contract_id: contract_id, comment: comment }, { headers: headers });
}
noHomeCheck() {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.get<any[]>(this.env.API_URL + 'contracts/nohome-check',
{ headers: headers });
}
noHomeConfirm(contract_id: String, lat: Number, lng: Number, description: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/nohome-confirm',
{ contract_id: contract_id, lat: lat, lng: lng, description: description }, { headers: headers });
}
addExtra(contract_id: Number, amount: Number, card_id: String, code: String, device_id: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'contracts/extra',
{ contract_id: contract_id, amount: amount, card_id: card_id, code: code, device_id: device_id }, { headers: headers });
}
addHero(name: String, rfc: String, categories: String, tags: String, address: String, lat: Number, lng: Number, bank: Number, bank_account: Number, fee: Number, reference_options: Number, reference: String) {
const headers = new HttpHeaders({
'Authorization': this.authService.token["token_type"]+" "+this.authService.token["access_token"]
});
return this.http.post(this.env.API_URL + 'add-hero',
{name: name, rfc: rfc, categories: categories, tags: tags, address: address, lat: lat, lng: lng, bank: bank, bank_account: bank_account, fee: fee, reference_options: reference_options, reference: reference}, { headers: headers });
}
}