UNPKG

@experteam-mx/ngx-services

Version:

Angular common services for Experteam apps

1,132 lines (1,124 loc) 138 kB
import * as i0 from '@angular/core'; import { InjectionToken, NgModule, Injectable, Inject, inject } from '@angular/core'; import * as i1 from '@angular/common/http'; import { provideHttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http'; import { map, mergeMap, forkJoin, tap, Observable, of } from 'rxjs'; import { map as map$1, tap as tap$1 } from 'rxjs/operators'; import * as i1$1 from 'ngx-cookie-service'; import { CookieService } from 'ngx-cookie-service'; import Pusher from 'pusher-js'; /** * Injection token used to inject environment configurations. * * `ENVIRONMENT_TOKEN` is a dependency injection token that allows * for the provision and retrieval of environment-specific configurations * within the application. This token is typically associated with an * `Environment` type that defines the structure of the configuration. */ const ENVIRONMENT_TOKEN = new InjectionToken('Environments token'); class NgxServicesModule { /** * Returns a module with providers for the NgxServicesModule. * * @param {Environment} environment - The environment configuration object. * * @return {ModuleWithProviders<NgxServicesModule>} The module with providers for the NgxServicesModule. */ static forRoot(environment) { return { ngModule: NgxServicesModule, providers: [ { provide: 'env', useValue: environment } ] }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, decorators: [{ type: NgModule, args: [{ providers: [provideHttpClient()] }] }] }); class ApiBillingDOService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the shipments API from the environment configurations. * * @return {string} The URL of the shipments API. */ get url() { return this.environments.apiBillingDO ?? ''; } /** * Retrieves a list of income types * * @return {Observable<ApiSuccess<IncomeTypesOut>>} An observable that emits the income types data. */ getIncomeTypes() { return this.http.get(`${this.url}/income-types`) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: ['env'] }] }, { type: i1.HttpClient }] }); class ApiBillingMxService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the shipments API from the environment configurations. * * @return {string} The URL of the shipments API. */ get url() { return this.environments.apiBillingMX ?? ''; } /** * Fetches the tax regimen data from the server. * * @return {Observable<FiscalRegimensOut>} An observable that emits the fiscal regimen data. */ getFiscalRegimens() { return this.http.get(`${this.url}/fiscal-regimens`) .pipe(map(({ data }) => data)); } /** * Fetches a paginated list of CFDIs (Comprobante Fiscal Digital por Internet) based on the provided fiscal regimen. * * @param {number} fiscalRegimen - The fiscal regimen identifier to filter the CFDIs. * @return {Observable<FiscalRegimensAcceptedOut>} An observable containing the paginated list of CFDIs. */ getFiscalRegimensAccepted(fiscalRegimen) { const params = { 'fiscal-regimen': fiscalRegimen }; return this.http.get(`${this.url}/cfdi-uses/fiscal-regimen-accepted/list`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches and validates postal code data from the server. * * @param {QueryParams} params - Query parameters used to filter the postal code data. * @return {Observable<PostalCodesOut>} - An observable emitting the validated postal code data. */ getPostalCodes(params) { return this.http.get(`${this.url}/postal-codes`, { params }) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: ['env'] }] }, { type: i1.HttpClient }] }); class ApiBillingPaService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the Billing Pa API from the environment configurations. * * @return {string} The URL of the Billing Pa API. */ get url() { return this.environments.apiBillingPA ?? ''; } /** * Retrieves a list of districts based on query parameters. * * @param {QueryParams} params - Query parameters for filtering the districts. * @returns {Observable<DistrictsOut>} The list of districts. */ getDistricts(params) { return this.http.get(`${this.url}/districts`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves a list of parishes based on query parameters. * * @param {QueryParams} params - Query parameters for filtering the parishes. * @returns {Observable<ParishesOut>} The list of parishes. */ getParishes(params) { return this.http.get(`${this.url}/parishes`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves a list of provinces based on query parameters. * * @param {QueryParams} params - Query parameters for filtering the provinces. * @returns {Observable<ProvincesOut>} The list of provinces. */ getProvinces(params) { return this.http.get(`${this.url}/provinces`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves the details of a customer based on query parameters. * * @param {QueryParams} params - Query parameters for get customer. * @return {Observable<BillingPaCustomerOut>} An observable that emits customer data. */ getValidateCustomer(params) { return this.http.get(`${this.url}/validate-customer`, { params }).pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingPaService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingPaService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingPaService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: ['env'] }] }, { type: i1.HttpClient }] }); class ApiCashOperationsService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the cash operations API from the environment configurations. * * @return {string} The URL of the cash operations API. */ get url() { return this.environments.apiCashOperationsUrl ?? ''; } /** * Creates a new installation country reference currency. * * @param {InstallationCountryReferenceCurrencyIn} body - The data for the new reference currency. * @returns {Observable<InstallationCountryReferenceCurrencyOut>} The created reference currency. */ postInstallationCountryReferenceCurrency(body) { return this.http.post(`${this.url}/installation-country-reference-currencies`, body).pipe(map(({ data }) => data)); } /** * Updates an existing installation country reference currency. * * @param {number} id - The ID of the reference currency to update. * @param {InstallationCountryReferenceCurrencyIn} body - The updated data for the reference currency. * @returns {Observable<InstallationCountryReferenceCurrencyOut>} The updated reference currency. */ putInstallationCountryReferenceCurrency(id, body) { return this.http.put(`${this.url}/installation-country-reference-currencies/${id}`, body) .pipe(map(({ data }) => data)); } /** * Retrieves a list of installation country reference currencies based on query parameters. * * @param {QueryParams} params - Query parameters for filtering the currencies. * @returns {Observable<InstallationCountryReferenceCurrenciesOut>} The list of reference currencies. */ getInstallationCompanyCountryCurrencies(params) { return this.http.get(`${this.url}/installation-country-reference-currencies`, { params }).pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCashOperationsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCashOperationsService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCashOperationsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: ['env'] }] }, { type: i1.HttpClient }] }); class ApiCatalogsService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the reports API from the environment configurations. * * @return {string} The URL of the reports API. */ get url() { return this.environments.apiCatalogsUrl ?? ''; } /** * Retrieves the list of collection payments * * @param {QueryParams} params - The query parameters used to fetch the operation types. * @return {Observable<OperationTypesOut[]>} An observable that emits an array of operation type. */ getOperationTypes(params) { return this.http.get(`${this.url}/operation-types`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves the list of identificatios types * * @param {QueryParams} params - The query parameters used to fetch the identification types. * @return {Observable<IdentificationTypesOut[]>} An observable that emits an array of identification type. */ getIdentificationTypes(params) { return this.http.get(`${this.url}/identification-types`, { params }).pipe(map(({ data }) => data)); } /** * Fetches the extra charges based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the results. * @return {Observable<ExtraChargesOut>} An observable emitting the extra charges data. */ getExtraCharges(params) { return this.http.get(`${this.url}/extracharges`, { params }).pipe(map(({ data }) => data)); } /** * Submits an extra charge request to the server and returns the created extra charge details. * * @param {ExtraChargeIn} body - The data for the extra charge to be created. * @return {Observable<ExtraChargeOut>} An observable that emits the details of the created extra charge. */ postExtraCharge(body) { return this.http.post(`${this.url}/extracharges`, body) .pipe(map(({ data }) => data)); } /** * Updates an extra charge entity with new data and returns the updated entity. * * @param {number} id - The unique identifier of the extra charge to update. * @param {ExtraChargeIn} body - The new data for the extra charge. * @return {Observable<ExtraChargeOut>} An observable emitting the updated extra charge entity. */ putExtraCharge(id, body) { return this.http.put(`${this.url}/extracharges/${id}`, body) .pipe(map(({ data }) => data)); } /** * Fetches a list of countries from the API. * * @param {QueryParams} params - The query parameters to be passed to the API request. * @return {Observable<CountriesOut>} An observable containing the list of countries. */ getCountries(params) { return this.http.get(`${this.url}/countries`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the details of a country based on its ID. * * @param {number} id - The identifier of the country to fetch. * @return {Observable<CountryOut>} An observable that emits the country data. */ getCountry(id) { return this.http.get(`${this.url}/countries/${id}`) .pipe(map(({ data }) => data)); } /** * Updates the details of a specific country by its ID. * * @param {number} id - The unique identifier of the country to be updated. * @param {CountryIn} body - The data to update the country with. * @return {Observable<CountryOut>} An observable that emits the updated country data. */ putCountry(id, body) { return this.http.put(`${this.url}/countries/${id}`, body) .pipe(map(({ data }) => data)); } /** * Fetches postal location details based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter and fetch postal location data. * @return {Observable<PostalLocationsOut>} An observable that emits the postal location details. */ getPostalLocations(params) { return this.http.get(`${this.url}/postal-locations`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches a list of regions based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter the regions. * @return {Observable<RegionsOut>} An observable that emits the list of regions. */ getRegions(params) { return this.http.get(`${this.url}/regions`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the zones data based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter the zones data. * @return {Observable<ZonesOut>} An observable that emits the fetched zones data. */ getZones(params) { return this.http.get(`${this.url}/zones`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the management areas based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the management areas. * @return {Observable<ManagementAreasOut>} An observable that emits the management areas data. */ getManagementAreas(params) { return this.http.get(`${this.url}/management-areas`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves cancellation reasons from the server based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the cancellation reasons. * @return {Observable<CancellationReasonsOut>} An observable containing the retrieved cancellation reasons. */ getCancellationReasons(params) { return this.http.get(`${this.url}/cancellation-reasons`, { params }) .pipe(map(({ data }) => data)); } /** * Sends a cancellation reason to the server. * * @param {CancellationReasonIn} body - The cancellation reason object to be sent. * @return {Observable<CancellationReasonOut>} An observable containing the server's response with the processed cancellation reason. */ postCancellationReason(body) { return this.http.post(`${this.url}/cancellation-reasons`, body) .pipe(map(({ data }) => data)); } /** * Updates the cancellation reason for the specified ID with the provided data. * * @param {number} id - The unique identifier of the cancellation reason to update. * @param {CancellationReasonIn} body - The details of the cancellation reason to be updated. * @return {Observable<CancellationReasonOut>} An observable containing the updated cancellation reason. */ putCancellationReason(id, body) { return this.http.put(`${this.url}/cancellation-reasons/${id}`, body) .pipe(map(({ data }) => data)); } /** * Retrieves a list of currencies based on the provided query parameters. * * @param {QueryParams} params - The query parameters to customize the currency retrieval request. * @return {Observable<CurrenciesOut>} An observable that emits the retrieved currencies data. */ getCurrencies(params) { return this.http.get(`${this.url}/currencies`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the list of available languages based on the provided query parameters. * * @param {QueryParams} params - The query parameters to pass with the HTTP request. * @return {Observable<LanguagesOut>} An observable that emits the available languages. */ getLanguages(params) { return this.http.get(`${this.url}/languages`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the available units from the API based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the units being fetched. * @return {Observable<UnitsOut>} An observable that emits the retrieved units data. */ getUnits(params) { return this.http.get(`${this.url}/units`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the shipment scopes based on the provided query parameters. * * @param {QueryParams} params The query parameters to filter or modify the request for shipment scopes. * @return {Observable<ShipmentScopesOut>} An observable that emits the shipment scopes data. */ getShipmentScopes(params) { return this.http.get(`${this.url}/shipment-scopes`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the available shipment content types based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the shipment content types. * @return {Observable<ShipmentContentTypesOut>} An observable that emits the shipment content types data. */ getShipmentContentTypes(params) { return this.http.get(`${this.url}/shipment-content-types`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches a list of generic folios based on the given query parameters. * * @param {QueryParams} params - The query parameters used to filter the generic folios. * @return {Observable<GenericFoliosOut>} An observable containing the fetched generic folios. */ getGenericFolios(params) { return this.http.get(`${this.url}/generic-folios`, { params }) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create or update a generic folio. * * @param {GenericFolioIn} body - The payload containing the details of the generic folio to be created or updated. * @return {Observable<GenericFolioOut>} An observable containing the response data of the created or updated generic folio. */ postGenericFolio(body) { return this.http.post(`${this.url}/generic-folios`, body) .pipe(map(({ data }) => data)); } /** * Updates a generic folio with the specified ID using the provided data. * * @param {number} id - The unique identifier of the generic folio to update. * @param {GenericFolioIn} body - The data to update the generic folio with. * @return {Observable<GenericFolioOut>} An observable containing the updated generic folio. */ putGenericFolio(id, body) { return this.http.put(`${this.url}/generic-folios/${id}`, body) .pipe(map(({ data }) => data)); } /** * Sends a PUT request to update a Generic Folio resource with the specified ID and body data, and returns the updated resource. * * @param {number} id - The unique identifier of the Generic Folio to be updated. * @param {Partial<GenericFolioIn>} body - The partial data representing the changes to be applied to the Generic Folio. * @return {Observable<GenericFolioOut>} An observable containing the updated Generic Folio resource. */ pathGenericFolio(id, body) { return this.http.put(`${this.url}/generic-folios/${id}`, body) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new product. * * @param {ProductIn} body - The product data to be sent in the request body. * @return {Observable<ProductOut>} An observable emitting the created product data. */ postProduct(body) { return this.http.post(`${this.url}/products`, body) .pipe(map(({ data }) => data)); } /** * Updates an existing product with the given ID using the provided data. * * @param {number} id - The unique identifier of the product to update. * @param {ProductIn} body - The product data to update. * @return {Observable<ProductOut>} An observable containing the updated product data. */ putProduct(id, body) { return this.http.put(`${this.url}/products/${id}`, body) .pipe(map(({ data }) => data)); } /** * Retrieves a list of shipment income types based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter the shipment income types. * @return {Observable<ShipmentIncomeTypesOut>} An observable containing the shipment income types data. */ getShipmentIncomeTypes(params) { return this.http.get(`${this.url}/shipment-income-types`, { params }) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new shipment income type. * * @param {ShipmentIncomeTypeIn} body The payload containing the details of the shipment income type to be created. * @return {Observable<ShipmentIncomeTypeOut>} An observable that emits the created shipment income type data. */ postShipmentIncomeType(body) { return this.http.post(`${this.url}/shipment-income-types`, body) .pipe(map(({ data }) => data)); } /** * Updates the shipment income type with the specified ID. * * @param {number} id - The identifier of the shipment income type to update. * @param {ShipmentIncomeTypeIn} body - The data to update the shipment income type with. * @return {Observable<ShipmentIncomeTypeOut>} An observable emitting the updated shipment income type. */ putShipmentIncomeType(id, body) { return this.http.put(`${this.url}/shipment-income-types/${id}`, body) .pipe(map(({ data }) => data)); } /** * Retrieves a list of unique folios based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter and fetch unique folios. * @return {Observable<UniqueFoliosOut>} An observable that emits the unique folios data. */ getUniqueFolios(params) { return this.http.get(`${this.url}/unique-folios`, { params }) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a unique folio. * * @param {UniqueFolioIn} body - The data object containing details for the unique folio to be created. * @return {Observable<UniqueFolioOut>} An observable that emits the created unique folio details. */ postUniqueFolio(body) { return this.http.post(`${this.url}/unique-folios`, body) .pipe(map(({ data }) => data)); } /** * Updates a unique folio with the given data using the provided ID. * * @param {number} id - The ID of the unique folio to be updated. * @param {UniqueFolioIn} body - The payload containing the details of the unique folio to update. * @return {Observable<UniqueFolioOut>} An observable that emits the updated unique folio. */ putUniqueFolio(id, body) { return this.http.put(`${this.url}/unique-folios/${id}`, body) .pipe(map(({ data }) => data)); } /** * Updates a unique folio by its identifier with the provided data. * * @param {number} id - The identifier of the unique folio to update. * @param {Partial<UniqueFolioIn>} body - The partial data of the unique folio to update. * @return {Observable<UniqueFolioOut>} An observable emitting the updated unique folio data. */ pathUniqueFolio(id, body) { return this.http.put(`${this.url}/unique-folios/${id}`, body) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCatalogsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCatalogsService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCatalogsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: ['env'] }] }, { type: i1.HttpClient }] }); class ApiCompaniesService { environments; http; constructor(environments, http) { this.environments = environments; this.http = http; } /** * Retrieves the URL for the companies API from the environment configurations. * * @return {string} The URL of the companies API. */ get url() { return this.environments.apiCompaniesUrl ?? ''; } /** * Fetches the installations based on the provided query parameters. * * @param {QueryParams} params - The parameters used to filter the installations query. * @return {Observable<InstallationsOut>} An observable that emits the installation's data. */ getInstallations(params) { return this.http.get(`${this.url}/installations`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the installation details based on the given installation ID. * * @param {number} id - The unique identifier of the installation to retrieve. * @returns {Observable<InstallationOut>} An observable of the installation details. */ getInstallation(id) { return this.http.get(`${this.url}/installations/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a post-installation request to the server and retrieves the installation details. * * @param {InstallationIn} body - The installation details to be sent in the request body. * @return {Observable<InstallationOut>} An observable that emits the response containing installation output details. */ postInstallation(body) { return this.http.post(`${this.url}/installations`, body) .pipe(map(({ data }) => data)); } /** * Updates an existing installation record by its ID. * * @param id The unique identifier of the installation to update. * @param body The data payload containing the updated installation information. * @return An observable that emits the updated installation data upon a successful update. */ putInstallation(id, body) { return this.http.put(`${this.url}/installations/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes an installation by its unique identifier. * * @param {number} id - The unique identifier of the installation to be deleted. * @return {Observable<{}>} An observable that emits the response after the installation is deleted. */ deleteInstallation(id) { return this.http.delete(`${this.url}/installations/${id}`) .pipe(map(({ data }) => data)); } /** * Retrieves a list of locations based on the provided query parameters. * * @param {QueryParams} params - The parameters to use for querying locations. * @return {Observable<LocationsOut>} An observable that emits the location's data. */ getLocations(params) { return this.http.get(`${this.url}/locations`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the location details for a given location ID. * * @param {number} id - The unique identifier of the location. * @return {Observable<LocationOut>} An Observable containing the location details. */ getLocation(id) { return this.http.get(`${this.url}/locations/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a location object to the server and returns the created location data. * * @param {LocationIn} body - The location input object to be sent in the request body. * @return {Observable<LocationOut>} An observable emitting the created location output object. */ postLocation(body) { return this.http.post(`${this.url}/locations`, body) .pipe(map(({ data }) => data)); } /** * Updates the location information for the specified ID. * * @param {number} id - The unique identifier of the location to be updated. * @param {LocationIn} body - The updated location data to be sent in the request body. * @return {Observable<LocationOut>} An observable containing the updated location information. */ putLocation(id, body) { return this.http.put(`${this.url}/locations/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes a location by its unique identifier. * * @param {number} id - The unique identifier of the location to be deleted. * @return {Observable<{}>} An observable that emits an empty object upon successful deletion. */ deleteLocation(id) { return this.http.delete(`${this.url}/locations/${id}`) .pipe(map(({ data }) => data)); } /** * Retrieves a list of active supply entities. * * @param {QueryParams} params - The query parameters to filter supply entities. * @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data. */ getSupplyEntitiesActives(params) { return this.http.get(`${this.url}/supply-entities/actives`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves supply entities based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter and fetch the supply entities. * @return {Observable<SupplyEntitiesOut>} An observable that emits the supply entities data. */ getSupplyEntities(params) { return this.http.get(`${this.url}/supply-entities`, { params }) .pipe(map(({ data }) => data)); } /** * Sends supply entities information to the server and receives the processed supply entities data in response. * * @param {SupplyEntitiesIn} body - The supply entities data to be sent to the server. * @return {Observable<SupplyEntitiesOut>} An observable containing the processed supply entities data. */ putSupplyEntities(body) { return this.http.post(`${this.url}/accounts`, body) .pipe(map(({ data }) => data)); } /** * Fetches a list of employees based on the specified query parameters. * * @param {QueryParams} params - The parameters to filter and sort the employees. * @return {Observable<EmployeesOut>} An observable that emits the list of employees. */ getEmployees(params) { return this.http.get(`${this.url}/employees`, { params, }).pipe(map(({ data }) => data)); } /** * Fetches an employee's details based on the provided employee ID. * * @param {number} id - The unique identifier of the employee. * @return {Observable<EmployeeOut>} An observable that emits the employee's details. */ getEmployee(id) { return this.http.get(`${this.url}/employees/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new employee record. * * @param {EmployeeIn} body - The data of the employee to be created. * @return {Observable<EmployeeOut>} An observable containing the created employee data. */ postEmployee(body) { return this.http.post(`${this.url}/employees`, body) .pipe(map(({ data }) => data)); } /** * Updates an existing employee record with the specified data. * * @param {number} id - The unique identifier of the employee to be updated. * @param {EmployeeIn} body - The employee data to update the record with. * @return {Observable<EmployeeOut>} An observable containing the updated employee data. */ putEmployee(id, body) { return this.http.put(`${this.url}/employees/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes an employee based on the provided ID. * * @param {number} id - The unique identifier of the employee to delete. * @return {Observable<{}>} An observable containing the response data after the employee is deleted. */ deleteEmployee(id) { return this.http.delete(`${this.url}/employees/${id}`) .pipe(map(({ data }) => data)); } /** * Retrieves the list of employees for a specified location based on provided query parameters. * * @param {QueryParams} params - The query parameters used to filter and retrieve the location employees. * @returns {Observable<LocationEmployeesOut>} An observable that emits the list of employees for the specified location. */ getLocationEmployees(params) { return this.http.get(`${this.url}/location-employees`, { params, }).pipe(map(({ data }) => data)); } /** * Fetches the location employee details for a given employee ID. * * @param {number} id - The unique identifier of the employee whose location details are to be retrieved. * @return {Observable<LocationEmployeeOut>} An observable containing the location employee details. */ getLocationEmployee(id) { return this.http.get(`${this.url}/location-employees/${id}`) .pipe(map(({ data }) => data)); } /** * Deletes a specific location employee by their unique identifier. * * @param {number} id - The unique identifier of the employee to be deleted. * @return {Observable<{}>} - An observable emitting the server's response after the deletion. */ deleteLocationEmployee(id) { return this.http.delete(`${this.url}/location-employees/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a batch of location-employee associations to the server for processing. * * @param {LocationEmployeeBatchIn} body - The object containing a batch of location-employee data to be posted. * @return {Observable<EmployeeOut>} An observable emitting the processed employee data from the server's response. */ postLocationEmployeeBatch(body) { return this.http.post(`${this.url}/location-employees/batch`, body) .pipe(map(({ data }) => data)); } /** * Retrieves a list of countries where the company operates. * * @param {QueryParams} params - The query parameters for the API request. * @return {Observable<CompanyCountriesOut>} An observable containing the list of company countries. */ getCompanyCountries(params) { return this.http.get(`${this.url}/company-countries`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the country information for a specified company by its ID. * * @param {number} id - The unique identifier of the company. * @return {Observable<CompanyCountryOut>} An observable containing the country information of the company. */ getCompanyCountry(id) { return this.http.get(`${this.url}/company-countries/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a request to update or create a company country entry on the server. * * @param {CompanyCountryIn} body The data object representing the company country information to be sent to the server. * @return {Observable<CompanyCountryOut>} An observable containing the server response with the updated or created company country data. */ postCompanyCountry(body) { return this.http.put(`${this.url}/company-countries`, body) .pipe(map(({ data }) => data)); } /** * Updates the country information for a specific company. * * @param {number} id - The unique identifier of the company whose country information needs to be updated. * @param {CompanyCountryIn} body - The updated country information to be applied to the company. * @return {Observable<CompanyCountryOut>} An observable that emits the updated company country information. */ putCompanyCountry(id, body) { return this.http.put(`${this.url}/company-countries/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes a company-country association by its unique identifier. * * @param {number} id - The unique identifier of the company-country record to be deleted. * @return {Observable<{}>} An observable emitting the result of the delete operation. */ deleteCompanyCountry(id) { return this.http.delete(`${this.url}/company-countries/${id}`) .pipe(map(({ data }) => data)); } /** * Fetches the reference currencies for a given country. * * @param {QueryParams} params - The query parameters to include in the request. * @return {Observable<CountryReferenceCurrenciesOut>} The observable containing the country reference currencies data. */ getCountryReferenceCurrencies(params) { return this.http.get(`${this.url}/country-reference-currencies`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the reference currency details for a specific country using its ID. * * @param {number} id - The unique identifier of the country. * @return {Observable<CountryReferenceCurrencyOut>} An observable emitting the country's reference currency details. */ getCountryReferenceCurrency(id) { return this.http.get(`${this.url}/country-reference-currencies/${id}`) .pipe(map(({ data }) => data)); } /** * Retrieves a list of currencies for different countries along with their current exchange rates. * * @param {QueryParams} params - The query parameters used to fetch the country reference currencies. * @return {Observable<CountryCurrencyRate[]>} An observable that emits an array of country currency rates. */ getCountryCurrenciesWithRate(params) { return this.getCountryReferenceCurrencies(params) .pipe(mergeMap((currenciesData) => { const $observables = currenciesData.country_reference_currencies .map((item) => this.getCurrentExchanges({ currency_id: item.currency.id, }).pipe(map((exchangesData) => ({ ...item, rate: exchangesData.exchanges[0]?.value, })))); return forkJoin($observables); })); } /** * Updates the reference currency for a specified country. * * @param {number} id - The unique identifier of the country. * @param {CountryReferenceCurrencyIn} body - The data for updating the country's reference currency. * @return {Observable<CountryReferenceCurrencyOut>} An Observable emitting the updated country reference currency data. */ putCountryReferenceCurrency(id, body) { return this.http.put(`${this.url}/country-reference-currencies/${id}`, body) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a country reference currency. * * @param {CountryReferenceCurrencyIn} body - The payload containing the country reference currency data. * @return {Observable<CountryReferenceCurrencyOut>} An observable emitting the created country reference currency. */ postCountryReferenceCurrency(body) { return this.http.post(`${this.url}/country-reference-currencies`, body) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create or update a country reference extra charge. * * @param {CountryReferenceExtraChargeIn} body - The request payload containing details about the country reference extra charge. * @return {Observable<CountryReferenceExtraChargeOut>} An observable containing the response with the created or updated country reference extra charge. */ postCountryReferenceExtraCharge(body) { return this.http.post(`${this.url}/country-reference-extra-charges`, body) .pipe(map(({ data }) => data)); } /** * Updates a country reference extra charge by its ID. * * @param {number} id - The unique identifier of the country reference extra charge to be updated. * @param {CountryReferenceExtraChargeIn} body - The data to update the country reference extra charge with. * @return {Observable<CountryReferenceExtraChargeOut>} An observable that emits the updated country reference extra charge. */ putCountryReferenceExtraCharge(id, body) { return this.http.put(`${this.url}/country-reference-extra-charges/${id}`, body) .pipe(map(({ data }) => data)); } /** * Enables or disables a country reference extra charge based on the provided parameters. * * @param {CountryReferenceExtraCharge} extraCharge - The country reference extra charge object to be updated. * @param {boolean} [isActive] - Optional parameter to explicitly set the active status of the extra charge. * If not provided, the current active status will be toggled. * @return {Observable<EmployeeCustomersOut>} An Observable that emits the updated employee customers output. */ patchCountryReferenceExtraCharge(extraCharge, isActive) { return this.http.patch(`${this.url}/country-reference-extra-charges/${extraCharge.id}`, { is_active: isActive ?? !extraCharge.is_active }).pipe(map(({ data }) => data)); } /** * Fetches exchange data based on the provided query parameters. * * @param {QueryParams} params - The query parameters for retrieving exchange data. * @return {Observable<ExchangesOut>} An observable containing the exchange data. */ getExchanges(params) { return this.http.get(`${this.url}/exchanges`, { params }) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create or update an exchange. * * @param {ExchangeIn} body - The request body containing the exchange data to be sent. * @return {Observable<ExchangeOut>} An observable that emits the response containing the created or updated exchange data. */ postExchange(body) { return this.http.put(`${this.url}/exchanges`, body) .pipe(map(({ data }) => data)); } /** * Updates an existing exchange with new data. * * @param {number} id - The unique identifier of the exchange to update. * @param {ExchangeIn} body - The data to update the exchange with. * @return {Observable<ExchangeOut>} An observable that emits the updated exchange data. */ putExchange(id, body) { return this.http.put(`${this.url}/exchanges/${id}`, body) .pipe(map(({ data }) => data)); } /** * Retrieves the current exchanges based on the given query parameters. * * @param {QueryParams} params - The query parameters to filter the exchanges. * * @returns {Observable<ExchangesOut>} - An observable that emits the API response data containing the current exchanges. */ getCurrentExchanges(params) { return this.http.get(`${this.url}/exchanges/current`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the country-specific tax information for a company. * * @param {QueryParams} params - The parameters used to filter and query the taxes. * @return {Observable<CompanyCountryTaxesOut>} An observable that emits the tax information. */ getCompanyCountryTaxes(params) { return this.http.get(`${this.url}/company-country-taxes`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches account information based on the provided query parameters. * * @param {QueryParams} params - The query parameters for fetching account data. * @return {Observable<AccountsOut>} An observable emitting the account data. */ getAccounts(params) { return this.http.get(`${this.url}/accounts`) .pipe(map(({ data }) => data)); } /** * Fetches the account information for the specified account ID. * * @param {number} id - The unique identifier of the account to retrieve. * @return {Observable<AccountOut>} An observable that emits the account details. */ getAccount(id) { return this.http.get(`${this.url}/accounts/${id}`) .pipe(map(({ data }) => data)); } /** * Creates a new account by sending account details in the body. * * @param {AccountIn} body - The account information to be sent in the request body. * @return {Observable<AccountOut>} Observable that emits the created account details upon success. */ postAccount(body) { return this.http.post(`${this.url}/accounts`, body) .pipe(map(({ data }) => data)); } /** * Updates an account with the specified ID using the provided data. * * @param {number} id - The unique identifier of the account to be updated. * @param {AccountIn} body - The data to update the account with. * @return {Observable<AccountOut>} An observable emitting the updated account details. */ putAccount(id, body) { return this.http.post(`${this.url}/accounts/${id}`, body) .pipe(map(({ data }) => data)); } /** * Fetches account entity data from the server based on the provided query parameters. * * @param {QueryParams} params - The query parameters to be sent with the HTTP request. * @return {Observable<AccountEntitiesOut>} An observable that emits the account entities data. */ getAccountEntities(params) { return this.http.g