UNPKG

@experteam-mx/ngx-services

Version:

Angular common services for Experteam apps

1,121 lines (1,110 loc) 224 kB
import * as i0 from '@angular/core'; import { InjectionToken, makeEnvironmentProviders, NgModule, inject, Injectable } from '@angular/core'; import { provideHttpClient, HttpClient, 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 { 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('ENVIRONMENT_TOKEN'); /** * Provides ngx-services dependencies for standalone Angular applications. * * Register this provider in `ApplicationConfig.providers` so all services in * this library can resolve the environment-based configuration. */ function provideNgxServices(environment) { return makeEnvironmentProviders([ { provide: ENVIRONMENT_TOKEN, useValue: environment } ]); } 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. * * @deprecated Use `provideNgxServices(environment)` in `ApplicationConfig.providers` * for standalone applications. This API will be removed in `20.2.0`. */ static forRoot(environment) { return { ngModule: NgxServicesModule, providers: [provideNgxServices(environment)] }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.18", ngImport: i0, type: NgxServicesModule }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: NgxServicesModule, decorators: [{ type: NgModule, args: [{ providers: [provideHttpClient()] }] }] }); class ApiBillingDOService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Gets the base URL for Billing DO API endpoints. * * @returns {string} Billing DO API base URL, or an empty string when it is not configured. */ get url() { return this.environments.apiBillingDO ?? ''; } /** * Retrieves the list of income types from Billing DO. * * @returns {Observable<IncomeTypesOut>} Observable that emits the income types payload. */ getIncomeTypes() { return this.http.get(`${this.url}/income-types`) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingDOService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingDOService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingDOService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiBillingGtService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Gets the base URL for Billing GT API endpoints. * * @returns {string} Billing GT API base URL, or an empty string when it is not configured. */ get url() { return this.environments.apiBillingGT ?? ''; } /** * Retrieves the list of billing configurations by location. * * @returns {Observable<BillingConfigsOut>} Observable that emits the billing configurations payload. */ getConfigs() { return this.http.get(`${this.url}/location/configs`) .pipe(map(({ data }) => data)); } /** * Retrieves billing configuration details for a location. * * @param {number} id - Location identifier to fetch. * @returns {Observable<BillingConfigOut>} Observable that emits the location billing configuration payload. */ getConfig(id) { return this.http.get(`${this.url}/locations/${id}`) .pipe(map(({ data }) => data)); } /** * Creates a billing configuration for a location. * * @param {BillingConfigIn} body - Billing configuration payload for the location. * @returns {Observable<BillingConfigOut>} Observable that emits the created billing configuration payload. */ postConfigs(body) { return this.http.post(`${this.url}/locations`, body) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingGtService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingGtService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingGtService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiBillingMxService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Gets the base URL for Billing MX API endpoints. * * @returns {string} Billing MX API base URL, or an empty string when it is not configured. */ get url() { return this.environments.apiBillingMX ?? ''; } /** * Retrieves the list of fiscal regimens from Billing MX. * * @returns {Observable<FiscalRegimensOut>} Observable that emits the fiscal regimens payload. */ getFiscalRegimens() { return this.http.get(`${this.url}/fiscal-regimens`) .pipe(map(({ data }) => data)); } /** * Retrieves the CFDI uses accepted for a fiscal regimen. * * @param {number} fiscalRegimen Fiscal regimen identifier used to filter accepted CFDI uses. * @returns {Observable<FiscalRegimensAcceptedOut>} Observable that emits the accepted CFDI uses payload. */ getFiscalRegimensAccepted(fiscalRegimen) { const params = { 'fiscal-regimen': fiscalRegimen }; return this.http.get(`${this.url}/cfdi-uses/fiscal-regimen-accepted/list`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves postal code information from Billing MX. * * @param {QueryParams} params Query parameters used by the postal codes endpoint. * @returns {Observable<PostalCodesOut>} Observable that emits the postal code data payload. */ getPostalCodes(params) { return this.http.get(`${this.url}/postal-codes`, { params }) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingMxService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingMxService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingMxService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiBillingPaService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Gets the base URL for Billing PA API endpoints. * * @returns {string} Billing PA API base URL, or an empty string when it is not configured. */ get url() { return this.environments.apiBillingPA ?? ''; } /** * Retrieves the list of districts. * * @param {QueryParams} params Query parameters used by the districts endpoint. * @returns {Observable<DistrictsOut>} Observable that emits the districts payload. */ getDistricts(params) { return this.http.get(`${this.url}/districts`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves the list of parishes. * * @param {QueryParams} params Query parameters used by the parishes endpoint. * @returns {Observable<ParishesOut>} Observable that emits the parishes payload. */ getParishes(params) { return this.http.get(`${this.url}/parishes`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves the list of provinces. * * @param {QueryParams} params Query parameters used by the provinces endpoint. * @returns {Observable<ProvincesOut>} Observable that emits the provinces payload. */ getProvinces(params) { return this.http.get(`${this.url}/provinces`, { params }).pipe(map(({ data }) => data)); } /** * Validates a customer using Billing PA. * * @param {QueryParams} params Query parameters used by the customer validation endpoint. * @returns {Observable<BillingPaCustomerOut>} Observable that emits customer validation data. */ getValidateCustomer(params) { return this.http.get(`${this.url}/validate-customer`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves billing configurations by location. * * @returns {Observable<BillingConfigsOut>} Observable that emits billing configuration items. */ getConfigs() { return this.http.get(`${this.url}/location/configs`) .pipe(map(({ data }) => data)); } /** * Retrieves the billing configuration for a location. * * @param {number} id Location identifier. * @returns {Observable<BillingConfigOut>} Observable that emits the location billing configuration payload. */ getConfig(id) { return this.http.get(`${this.url}/locations/${id}`) .pipe(map(({ data }) => data)); } /** * Creates a billing configuration for a location. * * @param {BillingConfigIn} body Billing configuration payload for the new location. * @returns {Observable<BillingConfigOut>} Observable that emits the created billing configuration payload. */ postConfigs(body) { return this.http.post(`${this.url}/locations`, body) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingPaService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingPaService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingPaService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiBillingSvService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Retrieves the URL for the billing API. * If the URL is not defined in the environments configuration, returns an empty string. * * @returns {string} The billing API URL or an empty string if not set. */ get url() { return this.environments.apiBillingSV ?? ''; } /** * Fetches the list of economic activities based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter the economic activities. * @returns {Observable<EconomicActivitiesOut>} An observable that emits the list of economic activities. */ getEconomicActivities(params) { return this.http.get(`${this.url}/economic-activities`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the list of person types based on given query parameters. * * @param {QueryParams} params - The query parameters used to filter the person types. * @returns {Observable<PersonTypesOut>} An observable that emits a list of person types. */ getPersonTypes(params) { return this.http.get(`${this.url}/person-types`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the list of establishment types. * * @param {QueryParams} params The query parameters to be sent with the HTTP request. * @returns {Observable<EstablishmentTypesOut>} An observable that emits the establishment types data. */ getEstablishmentTypes(params) { return this.http.get(`${this.url}/establishment-types`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches the list of departments based on the provided query parameters. * * @param {QueryParams} params - The query parameters to filter or modify the departments fetch request. * @returns {Observable<DepartmentsOut>} An observable emitting the list of departments. */ getDepartments(params) { return this.http.get(`${this.url}/departments`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves a list of municipalities based on the provided query parameters. * * @param {QueryParams} params - The query parameters used to filter the municipalities. * @returns {Observable<MunicipalitiesOut>} An observable that emits the retrieved municipalities data. */ getMunicipalities(params) { return this.http.get(`${this.url}/municipalities`, { params }) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingSvService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingSvService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiBillingSvService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiCashOperationsService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * Retrieves the URL for the cash operations API from the environment configurations. * * @returns {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)); } /** * Retrieves the cash value summary for a specific opening ID. * * @param {number} id - The ID of the opening for which to retrieve the cash value summary. * @returns {Observable<CashValueSummaryOut>} An observable that emits the cash value summary data. */ getOpeningCashValueSummary(id) { return this.http.get(`${this.url}/openings/${id}/cash-value-summary`) .pipe(map(({ data }) => data)); } /** * Creates a new opening transference record. * * @param {OpeningTransferenceIn} body - The data to create the new opening transference. * @returns {Observable<OpeningTransferenceOut>} An observable that emits the newly created opening transference. */ postOpeningTransferences(body) { return this.http.post(`${this.url}/opening-transferences`, body) .pipe(map(({ data }) => data)); } /** * Retrieves the receipt file associated with the given opening transference ID. * * @param {number} id - The ID of the opening transference whose receipt is to be retrieved. * @returns {Observable<ReceiptFileOut>} An observable that emits the receipt file data. */ getOpeningTransferenceReceipt(id) { return this.http.get(`${this.url}/opening-transferences/${id}/receipt`) .pipe(map(({ data }) => data)); } /** * Retrieves a deposit slip by its ID. * @param id - The unique identifier of the deposit slip to retrieve * @returns An Observable that emits the deposit slip data */ getDepositSlip(id) { return this.http.get(`${this.url}/deposits/${id}/slip`) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCashOperationsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCashOperationsService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCashOperationsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiCatalogsService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * 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)); } /** * Retrieve a single identification type by its id. * * Sends an HTTP GET request to the indentification type endpoint and returns an Observable that emits * the IdentificationTypeOut payload extracted from the API success envelope. * * @param id - The numeric identifier of the identification type to fetch. * @returns An Observable that emits the requested IdentificationTypeOut. The Observable will error * if the HTTP request fails (for example network issues or non-2xx responses). */ getIdentificationType(id) { return this.http.get(`${this.url}/identification-types/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new identification type and returns the created resource. * * The request payload is sent as an object with a `body` property containing the provided * IdentificationTypeIn value (i.e. { body: IdentificationTypeIn }). On success the HTTP response is expected * to follow the ApiSuccess<T> shape; the operator maps that response to the inner `data` * object and emits it as a IdentificationTypeOut. * * @param body - The identification type payload to create (IdentificationTypeIn). * @returns Observable<IdentificationTypeOut> that emits the created identification type on success. */ postIdentificationType(body) { return this.http.post(`${this.url}/identification-types`, body) .pipe(map(({ data }) => data)); } /** * Update a identification type by its ID. * * Sends an HTTP PUT to `${this.url}/identification-types/${id}` with the provided payload. * The request body is sent as an object with a `body` property containing the * `IdentificationTypeIn` data. The server response is expected to be an `ApiSuccess<IdentificationTypeOut>` * and this method returns an Observable that emits the unwrapped `IdentificationTypeOut`. * * @param id - The identifier of the identification type to update. * @param body - The update payload for the identification type. * @returns An Observable that emits the updated `IdentificationTypeOut` on success. */ putIdentificationType(id, body) { return this.http.put(`${this.url}/identification-types/${id}`, body) .pipe(map(({ data }) => data)); } /** * Delete a identification type by its ID. * * Sends an HTTP DELETE request to the backend endpoint `/identification-types/{id}` and * returns an Observable that emits the API response's `data` payload (typically an empty object). * * The implementation maps an ApiSuccess wrapper to its `data` property before emitting. * * @param id - The numeric identifier of the identification type to delete. * @returns An Observable that emits the deleted resource payload ({} expected) on success. * The Observable will emit an error if the HTTP request fails. */ deleteIdentificationType(id) { return this.http.delete(`${this.url}/identification-types/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a POST request to validate identification type number. * * The request payload is sent as an object with a `body` property containing the provided * IdentificationTypeNumberValidationIn value (i.e. { body: IdentificationTypeNumberValidationIn }). On success the HTTP response is expected * to follow the ApiSuccess<T> shape; the operator maps that response to the inner `data` * object and emits it as a IdentificationTypeNumberValidationOut. * * @param body - The identification type number validation payload to validate (IdentificationTypeNumberValidationIn). * @returns Observable<IdentificationTypeNumberValidationOut> that emits the validate status. */ postIdentificationTypeNumberValidation(body) { return this.http.post(`${this.url}/identification-types/number-validation`, body) .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 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)); } /** * Retrieves currency information by ID. * @param id - The unique identifier of the currency to retrieve. * @returns An Observable that emits the currency data. */ getCurrency(id) { return this.http.get(`${this.url}/currencies/${id}`) .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)); } /** * Retrieves shipment groups based on the provided query parameters. * * @param params - The query parameters to filter the shipment groups. * @returns An Observable that emits the shipment groups data. */ getShipmentGroups(params) { return this.http.get(`${this.url}/shipment-groups`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieves the shipment statuses from the API. * * @param params - The query parameters to filter or modify the request. * @returns An Observable that emits the shipment statuses output. */ getShipmentStatuses(params) { return this.http.get(`${this.url}/shipment-statuses`, { params }) .pipe(map(({ data }) => data)); } /** * Fetches questions from the catalogs API. * * Sends an HTTP GET request to `${this.url}/questions` using the supplied query parameters * and returns the unwrapped payload (`data`) from the API response. * * @param params - Query parameters to include in the request (e.g. paging, filters, sorting). * @returns An Observable that emits the QuestionsOut payload (the `data` field from ApiSuccess<QuestionsOut>). */ getQuestions(params) { return this.http.get(`${this.url}/questions`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieve a single question by its id. * * Sends an HTTP GET request to the questions endpoint and returns an Observable that emits * the QuestionOut payload extracted from the API success envelope. * * @param id - The numeric identifier of the question to fetch. * @returns An Observable that emits the requested QuestionOut. The Observable will error * if the HTTP request fails (for example network issues or non-2xx responses). */ getQuestion(id) { return this.http.get(`${this.url}/questions/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new question and returns the created resource. * * The request payload is sent as an object with a `body` property containing the provided * QuestionIn value (i.e. { body: QuestionIn }). On success the HTTP response is expected * to follow the ApiSuccess<T> shape; the operator maps that response to the inner `data` * object and emits it as a QuestionOut. * * @param body - The question payload to create (QuestionIn). * @returns Observable<QuestionOut> that emits the created question on success. */ postQuestion(body) { return this.http.post(`${this.url}/questions`, body) .pipe(map(({ data }) => data)); } /** * Update a question by its ID. * * Sends an HTTP PUT to `${this.url}/questions/${id}` with the provided payload. * The request body is sent as an object with a `body` property containing the * `QuestionIn` data. The server response is expected to be an `ApiSuccess<QuestionOut>` * and this method returns an Observable that emits the unwrapped `QuestionOut`. * * @param id - The identifier of the question to update. * @param body - The update payload for the question. * @returns An Observable that emits the updated `QuestionOut` on success. */ putQuestion(id, body) { return this.http.put(`${this.url}/questions/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes a question by its ID. * * Sends an HTTP DELETE request to the backend endpoint `/questions/{id}` and * returns an Observable that emits the API response's `data` payload (typically an empty object). * * The implementation maps an ApiSuccess wrapper to its `data` property before emitting. * * @param id - The numeric identifier of the question to delete. * @returns An Observable that emits the deleted resource payload ({} expected) on success. * The Observable will emit an error if the HTTP request fails. */ deleteQuestion(id) { return this.http.delete(`${this.url}/questions/${id}`) .pipe(map(({ data }) => data)); } /** * Fetches holidays from the catalogs API. * * Sends an HTTP GET request to `${this.url}/holidays` using the supplied query parameters * and returns the unwrapped payload (`data`) from the API response. * * @param params - Query parameters to include in the request (e.g. paging, filters, sorting). * @returns An Observable that emits the HolidaysOut payload (the `data` field from ApiSuccess<HolidaysOut>). */ getHolidays(params) { return this.http.get(`${this.url}/holidays`, { params }) .pipe(map(({ data }) => data)); } /** * Retrieve a single holiday by its id. * * Sends an HTTP GET request to the holidays endpoint and returns an Observable that emits * the HolidayOut payload extracted from the API success envelope. * * @param id - The numeric identifier of the holiday to fetch. * @returns An Observable that emits the requested HolidayOut. The Observable will error * if the HTTP request fails (for example network issues or non-2xx responses). */ getHoliday(id) { return this.http.get(`${this.url}/holidays/${id}`) .pipe(map(({ data }) => data)); } /** * Sends a POST request to create a new holiday and returns the created resource. * * The request payload is sent as an object with a `body` property containing the provided * HolidayIn value (i.e. { body: HolidayIn }). On success the HTTP response is expected * to follow the ApiSuccess<T> shape; the operator maps that response to the inner `data` * object and emits it as a HolidayOut. * * @param body - The holiday payload to create (HolidayIn). * @returns Observable<HolidayOut> that emits the created holiday on success. */ postHoliday(body) { return this.http.post(`${this.url}/holidays`, body) .pipe(map(({ data }) => data)); } /** * Update a holiday by its ID. * * Sends an HTTP PUT to `${this.url}/holidays/${id}` with the provided payload. * The request body is sent as an object with a `body` property containing the * `HolidayIn` data. The server response is expected to be an `ApiSuccess<HolidayOut>` * and this method returns an Observable that emits the unwrapped `HolidayOut`. * * @param id - The identifier of the holiday to update. * @param body - The update payload for the holiday. * @returns An Observable that emits the updated `HolidayOut` on success. */ putHoliday(id, body) { return this.http.put(`${this.url}/holidays/${id}`, body) .pipe(map(({ data }) => data)); } /** * Deletes a question by its ID. * * Sends an HTTP DELETE request to the backend endpoint `/questions/{id}` and * returns an Observable that emits the API response's `data` payload (typically an empty object). * * The implementation maps an ApiSuccess wrapper to its `data` property before emitting. * * @param id - The numeric identifier of the question to delete. * @returns An Observable that emits the deleted resource payload ({} expected) on success. * The Observable will emit an error if the HTTP request fails. */ deleteHoliday(id) { return this.http.delete(`${this.url}/holidays/${id}`) .pipe(map(({ data }) => data)); } /** * Retrieves a list of business party trader types * @param {QueryParams} params - Query parameters for filtering and pagination (optional) * @returns {Observable<BusinessPartyTraderTypesOut>} Observable containing the list of trader types */ getBusinessPartyTraderTypes(params) { return this.http.get(`${this.url}/business-party-trader-types`, { params }).pipe(map(({ data }) => data)); } /** * Retrieves package locations based on the provided query parameters. * @param params - Query parameters to filter or configure the package locations request * @returns An Observable that emits the package locations data */ getPackageLocations(params) { return this.http.get(`${this.url}/package-locations`, { params }) .pipe(map(({ data }) => data)); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCatalogsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCatalogsService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.18", ngImport: i0, type: ApiCatalogsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class ApiCompaniesService { environments = inject(ENVIRONMENT_TOKEN); http = inject(HttpClient); /** * 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(i