@experteam-mx/ngx-services 18.4.0 → 18.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/esm2022/lib/apis/api-billing-do.service.mjs +41 -0
  2. package/esm2022/lib/apis/api-billing-mx.service.mjs +62 -0
  3. package/esm2022/lib/apis/api-companies.service.mjs +21 -22
  4. package/esm2022/lib/apis/api-external-pickups.service.mjs +74 -0
  5. package/esm2022/lib/apis/api-invoices.service.mjs +79 -9
  6. package/esm2022/lib/apis/api-open-items.service.mjs +62 -0
  7. package/esm2022/lib/apis/api-reports.service.mjs +48 -2
  8. package/esm2022/lib/apis/api-security.service.mjs +56 -39
  9. package/esm2022/lib/apis/api-shipments.service.mjs +13 -3
  10. package/esm2022/lib/apis/models/api-billing.interfaces.mjs +2 -0
  11. package/esm2022/lib/apis/models/api-billing.types.mjs +2 -0
  12. package/esm2022/lib/apis/models/api-catalog.interfaces.mjs +1 -1
  13. package/esm2022/lib/apis/models/api-companies.types.mjs +1 -1
  14. package/esm2022/lib/apis/models/api-external-pickups.types.mjs +2 -0
  15. package/esm2022/lib/apis/models/api-invoices.interfaces.mjs +1 -1
  16. package/esm2022/lib/apis/models/api-invoices.types.mjs +1 -1
  17. package/esm2022/lib/apis/models/api-open-items.interfaces.mjs +2 -0
  18. package/esm2022/lib/apis/models/api-open-items.types.mjs +2 -0
  19. package/esm2022/lib/apis/models/api-reports.interfaces.mjs +1 -1
  20. package/esm2022/lib/apis/models/api-reports.types.mjs +1 -1
  21. package/esm2022/lib/apis/models/api-security.types.mjs +1 -1
  22. package/esm2022/lib/apis/models/api-shipments.types.mjs +1 -1
  23. package/esm2022/lib/ngx-services.models.mjs +1 -1
  24. package/esm2022/lib/websockets/web-sockets.service.mjs +115 -0
  25. package/esm2022/public-api.mjs +11 -1
  26. package/fesm2022/experteam-mx-ngx-services.mjs +615 -137
  27. package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
  28. package/lib/apis/api-billing-do.service.d.ts +24 -0
  29. package/lib/apis/api-billing-mx.service.d.ts +39 -0
  30. package/lib/apis/api-companies.service.d.ts +9 -9
  31. package/lib/apis/api-external-pickups.service.d.ts +46 -0
  32. package/lib/apis/api-invoices.service.d.ts +59 -9
  33. package/lib/apis/api-open-items.service.d.ts +41 -0
  34. package/lib/apis/api-reports.service.d.ts +24 -1
  35. package/lib/apis/api-security.service.d.ts +45 -32
  36. package/lib/apis/api-shipments.service.d.ts +10 -3
  37. package/lib/apis/models/api-billing.interfaces.d.ts +41 -0
  38. package/lib/apis/models/api-billing.types.d.ts +17 -0
  39. package/lib/apis/models/api-catalog.interfaces.d.ts +6 -0
  40. package/lib/apis/models/api-companies.types.d.ts +7 -13
  41. package/lib/apis/models/api-external-pickups.types.d.ts +31 -0
  42. package/lib/apis/models/api-invoices.interfaces.d.ts +35 -1
  43. package/lib/apis/models/api-invoices.types.d.ts +57 -5
  44. package/lib/apis/models/api-open-items.interfaces.d.ts +32 -0
  45. package/lib/apis/models/api-open-items.types.d.ts +58 -0
  46. package/lib/apis/models/api-reports.interfaces.d.ts +149 -0
  47. package/lib/apis/models/api-reports.types.d.ts +13 -4
  48. package/lib/apis/models/api-security.types.d.ts +9 -8
  49. package/lib/apis/models/api-shipments.types.d.ts +41 -0
  50. package/lib/ngx-services.models.d.ts +16 -5
  51. package/lib/websockets/web-sockets.service.d.ts +49 -0
  52. package/package.json +11 -2
  53. package/public-api.d.ts +9 -0
@@ -1,11 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, NgModule, Injectable, Inject, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
- import { provideHttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/common/http';
5
- import { map, mergeMap, forkJoin, tap, of } from 'rxjs';
4
+ import { provideHttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http';
5
+ import { map, mergeMap, forkJoin, tap, Observable, of } from 'rxjs';
6
+ import { map as map$1, tap as tap$1 } from 'rxjs/operators';
6
7
  import * as i1$1 from 'ngx-cookie-service';
7
8
  import { CookieService } from 'ngx-cookie-service';
8
- import { tap as tap$1 } from 'rxjs/operators';
9
+ import Pusher from 'pusher-js';
9
10
 
10
11
  /**
11
12
  * Injection token used to inject environment configurations.
@@ -47,70 +48,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
47
48
  }]
48
49
  }] });
49
50
 
50
- /**
51
- * Convert an object of key-value pairs into a URL query string.
52
- *
53
- * @param {Object} params - The key-value pairs to converted into a query string.
54
- *
55
- * @return {string} - The generated query string.
56
- */
57
- const queryString = (params) => {
58
- const queryElements = [];
59
- Object.entries(params).forEach(([key, value]) => {
60
- if (Array.isArray(value)) {
61
- const arrayQuery = value
62
- .map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
63
- .join('&');
64
- queryElements.push(arrayQuery);
65
- }
66
- else {
67
- const encodedQuery = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
68
- queryElements.push(encodedQuery);
69
- }
70
- });
71
- const queryString = queryElements.join('&');
72
- return queryString.length ? `?${queryString}` : '';
73
- };
74
- /**
75
- * Creates an instance of HttpParams using the provided params object.
76
- *
77
- * @param {Object} params - The object containing the params to the HttpParams constructor.
78
- *
79
- * @returns {HttpParams} - An instance of HttpParams created from the params object.
80
- */
81
- const httpParams = (params) => new HttpParams({
82
- fromObject: params
83
- });
84
- /**
85
- * Returns the headers for generating PDF files.
86
- *
87
- * @param {string} format - The format of the headers, 'object' or 'http_header'.
88
- *
89
- * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating PDF files.
90
- */
91
- const pdfHeaders = (format = 'object') => {
92
- const headers = {
93
- Accept: 'application/pdf'
94
- };
95
- return format === 'object'
96
- ? headers
97
- : new HttpHeaders(headers);
98
- };
99
- /**
100
- * Returns the headers for generating XML files.
101
- *
102
- * @param {string} format - The format of the headers, 'object' or 'http_header'.
103
- *
104
- * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating XML files.
105
- */
106
- const xmlHeaders = (format = 'object') => {
107
- const headers = {
108
- Accept: 'application/xml',
109
- };
110
- return format === 'object'
111
- ? headers
112
- : new HttpHeaders(headers);
113
- };
51
+ class ApiBillingDOService {
52
+ environments;
53
+ http;
54
+ constructor(environments, http) {
55
+ this.environments = environments;
56
+ this.http = http;
57
+ }
58
+ /**
59
+ * Retrieves the URL for the shipments API from the environment configurations.
60
+ *
61
+ * @return {string} The URL of the shipments API.
62
+ */
63
+ get url() {
64
+ return this.environments.apiBillingDO ?? '';
65
+ }
66
+ /**
67
+ * Retrieves a list of income types
68
+ *
69
+ * @return {Observable<ApiSuccess<IncomeTypesOut>>} An observable that emits the income types data.
70
+ */
71
+ getIncomeTypes() {
72
+ return this.http.get(`${this.url}/income-types`)
73
+ .pipe(map(({ data }) => data));
74
+ }
75
+ 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 });
76
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, providedIn: 'root' });
77
+ }
78
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingDOService, decorators: [{
79
+ type: Injectable,
80
+ args: [{
81
+ providedIn: 'root'
82
+ }]
83
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
84
+ type: Inject,
85
+ args: ['env']
86
+ }] }, { type: i1.HttpClient }] });
87
+
88
+ class ApiBillingMxService {
89
+ environments;
90
+ http;
91
+ constructor(environments, http) {
92
+ this.environments = environments;
93
+ this.http = http;
94
+ }
95
+ /**
96
+ * Retrieves the URL for the shipments API from the environment configurations.
97
+ *
98
+ * @return {string} The URL of the shipments API.
99
+ */
100
+ get url() {
101
+ return this.environments.apiBillingMX ?? '';
102
+ }
103
+ /**
104
+ * Fetches the tax regimen data from the server.
105
+ *
106
+ * @return {Observable<FiscalRegimensOut>} An observable that emits the fiscal regimen data.
107
+ */
108
+ getFiscalRegimens() {
109
+ return this.http.get(`${this.url}/fiscal-regimens`)
110
+ .pipe(map(({ data }) => data));
111
+ }
112
+ /**
113
+ * Fetches a paginated list of CFDIs (Comprobante Fiscal Digital por Internet) based on the provided fiscal regimen.
114
+ *
115
+ * @param {number} fiscalRegimen - The fiscal regimen identifier to filter the CFDIs.
116
+ * @return {Observable<FiscalRegimensAcceptedOut>} An observable containing the paginated list of CFDIs.
117
+ */
118
+ getFiscalRegimensAccepted(fiscalRegimen) {
119
+ const params = { 'fiscal-regimen': fiscalRegimen };
120
+ return this.http.get(`${this.url}/cfdi-uses/fiscal-regimen-accepted/list`, { params })
121
+ .pipe(map(({ data }) => data));
122
+ }
123
+ /**
124
+ * Fetches and validates postal code data from the server.
125
+ *
126
+ * @param {QueryParams} params - Query parameters used to filter the postal code data.
127
+ * @return {Observable<PostalCodesOut>} - An observable emitting the validated postal code data.
128
+ */
129
+ getPostalCodes(params) {
130
+ return this.http.get(`${this.url}/postal-codes`, { params })
131
+ .pipe(map(({ data }) => data));
132
+ }
133
+ 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 });
134
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, providedIn: 'root' });
135
+ }
136
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiBillingMxService, decorators: [{
137
+ type: Injectable,
138
+ args: [{
139
+ providedIn: 'root'
140
+ }]
141
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
142
+ type: Inject,
143
+ args: ['env']
144
+ }] }, { type: i1.HttpClient }] });
114
145
 
115
146
  class ApiCompaniesService {
116
147
  environments;
@@ -125,7 +156,7 @@ class ApiCompaniesService {
125
156
  * @return {string} The URL of the companies API.
126
157
  */
127
158
  get url() {
128
- return this.environments.apiCompaniesUrl;
159
+ return this.environments.apiCompaniesUrl ?? '';
129
160
  }
130
161
  /**
131
162
  * Fetches the installations based on the provided query parameters.
@@ -135,7 +166,7 @@ class ApiCompaniesService {
135
166
  */
136
167
  getInstallations(params) {
137
168
  return this.http.get(`${this.url}/installations`, {
138
- params: httpParams(params),
169
+ params,
139
170
  }).pipe(map(({ data }) => data));
140
171
  }
141
172
  /**
@@ -156,7 +187,7 @@ class ApiCompaniesService {
156
187
  */
157
188
  getLocations(params) {
158
189
  return this.http.get(`${this.url}/locations`, {
159
- params: httpParams(params),
190
+ params,
160
191
  }).pipe(map(({ data }) => data));
161
192
  }
162
193
  /**
@@ -173,11 +204,11 @@ class ApiCompaniesService {
173
204
  * Retrieves a list of active supply entities.
174
205
  *
175
206
  * @param {QueryParams} params - The query parameters to filter supply entities.
176
- * @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data.
207
+ * @return {Observable<SupplyEntitiesActivesOut>} Observable emitting supply entities data.
177
208
  */
178
- getSupplyEntitiesActive(params) {
209
+ getSupplyEntitiesActives(params) {
179
210
  return this.http.get(`${this.url}/supply-entities/actives`, {
180
- params: httpParams(params),
211
+ params,
181
212
  }).pipe(map(({ data }) => data));
182
213
  }
183
214
  /**
@@ -188,7 +219,7 @@ class ApiCompaniesService {
188
219
  */
189
220
  getEmployees(params) {
190
221
  return this.http.get(`${this.url}/employees`, {
191
- params: httpParams(params),
222
+ params,
192
223
  }).pipe(map(({ data }) => data));
193
224
  }
194
225
  /**
@@ -209,7 +240,7 @@ class ApiCompaniesService {
209
240
  */
210
241
  getLocationEmployees(params) {
211
242
  return this.http.get(`${this.url}/location-employees`, {
212
- params: httpParams(params),
243
+ params,
213
244
  }).pipe(map(({ data }) => data));
214
245
  }
215
246
  /**
@@ -220,7 +251,7 @@ class ApiCompaniesService {
220
251
  */
221
252
  getCompanyCountries(params) {
222
253
  return this.http.get(`${this.url}/company-countries`, {
223
- params: httpParams(params),
254
+ params,
224
255
  }).pipe(map(({ data }) => data));
225
256
  }
226
257
  /**
@@ -265,11 +296,11 @@ class ApiCompaniesService {
265
296
  * Fetches exchange data based on the provided query parameters.
266
297
  *
267
298
  * @param {QueryParams} params - The query parameters for retrieving exchange data.
268
- * @return {Observable<CountryExchangesOut>} An observable containing the exchange data.
299
+ * @return {Observable<ExchangesOut>} An observable containing the exchange data.
269
300
  */
270
301
  getExchanges(params) {
271
302
  return this.http.get(`${this.url}/exchanges`, {
272
- params: httpParams(params),
303
+ params,
273
304
  }).pipe(map(({ data }) => data));
274
305
  }
275
306
  /**
@@ -281,7 +312,7 @@ class ApiCompaniesService {
281
312
  */
282
313
  getCurrentExchanges(params) {
283
314
  return this.http.get(`${this.url}/exchanges/current`, {
284
- params: httpParams(params),
315
+ params,
285
316
  }).pipe(map(({ data }) => data));
286
317
  }
287
318
  /**
@@ -292,18 +323,18 @@ class ApiCompaniesService {
292
323
  */
293
324
  getCompanyCountryTaxes(params) {
294
325
  return this.http.get(`${this.url}/company-country-taxes`, {
295
- params: httpParams(params),
326
+ params,
296
327
  }).pipe(map(({ data }) => data));
297
328
  }
298
329
  /**
299
330
  * Retrieves the list of active account entities based on the provided query parameters.
300
331
  *
301
332
  * @param {QueryParams} params - The parameters to filter and query active account entities.
302
- * @return {Observable<AccountEntitiesOut>} An observable that emits the list of active account entities.
333
+ * @return {Observable<AccountEntitiesActivesOut>} An observable that emits the list of active account entities.
303
334
  */
304
- getActiveAccountEntities(params) {
335
+ getAccountEntitiesActives(params) {
305
336
  return this.http.get(`${this.url}/account-entities/actives`, {
306
- params: httpParams(params),
337
+ params,
307
338
  }).pipe(map(({ data }) => data));
308
339
  }
309
340
  /**
@@ -311,9 +342,9 @@ class ApiCompaniesService {
311
342
  *
312
343
  * @param {Object} params - An object containing the required parameters.
313
344
  * @param {string[]} params.paramNames - An array of parameter names for which the values need to be fetched.
314
- * @return {Observable<ParametersOut>} An observable that emits the fetched parameter values.
345
+ * @return {Observable<ParametersValuesOut>} An observable that emits the fetched parameter values.
315
346
  */
316
- getParameters({ paramNames, }) {
347
+ getParametersValues({ paramNames, }) {
317
348
  const parameters = paramNames.map((p) => ({ name: p }));
318
349
  return this.http.post(`${this.url}/parameters-values`, {
319
350
  parameters
@@ -338,7 +369,7 @@ class ApiCompaniesService {
338
369
  */
339
370
  getCountryReferences(params) {
340
371
  return this.http.get(`${this.url}/country-references`, {
341
- params: httpParams(params),
372
+ params,
342
373
  }).pipe(map(({ data }) => data));
343
374
  }
344
375
  /**
@@ -359,7 +390,7 @@ class ApiCompaniesService {
359
390
  */
360
391
  getWorkflows(params) {
361
392
  return this.http.get(`${this.url}/workflows`, {
362
- params: httpParams(params),
393
+ params,
363
394
  }).pipe(map(({ data }) => data));
364
395
  }
365
396
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -375,6 +406,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
375
406
  args: ['env']
376
407
  }] }, { type: i1.HttpClient }] });
377
408
 
409
+ class ApiExternalPickupsService {
410
+ httpClient;
411
+ environment;
412
+ appKey;
413
+ constructor(httpClient, environment) {
414
+ this.httpClient = httpClient;
415
+ this.environment = environment;
416
+ this.appKey = environment.apiExternalOperationsKey ?? '';
417
+ }
418
+ /**
419
+ * Getter method to retrieve the API's external operations URL.
420
+ * Fetches the URL from the `apiExternalOperationsUrl` property of the environment object.
421
+ * Defaults to an empty string if the property is undefined or null.
422
+ *
423
+ * @return {string} The external operations URL or an empty string if unavailable.
424
+ */
425
+ get url() {
426
+ return this.environment.apiExternalOperationsUrl ?? '';
427
+ }
428
+ /**
429
+ * Generates a delivery confirmation by sending the provided payload to the API.
430
+ *
431
+ * @param {DeliveryConfirmationGenerateIn} payload - The input payload required to generate the delivery confirmation.
432
+ * @return {Observable<DeliveryConfirmationGenerateOut>} An observable that emits the generated delivery confirmation data.
433
+ */
434
+ postDeliveryConfirmationGenerate(payload) {
435
+ return this.httpClient.post(`${this.url}/delivery-confirmation/generate`, payload, {
436
+ headers: { appkey: this.appKey }
437
+ }).pipe(map$1(({ data }) => data));
438
+ }
439
+ /**
440
+ * Confirms the completion of a delivery operation by making a PATCH request.
441
+ *
442
+ * @param {Object} input - The input parameters for the method.
443
+ * @param {string} input.operationId - The unique identifier of the delivery operation to be confirmed.
444
+ * @param {string} input.keyOTP - The one-time password (OTP) key associated with the delivery confirmation.
445
+ * @return {Observable<Object>} - An observable containing the response data from the API.
446
+ */
447
+ patchDeliveryConfirmationComplete({ keyOTP, operationId, }) {
448
+ return this.httpClient.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
449
+ headers: { appkey: this.appKey },
450
+ params: { operation_id: operationId }
451
+ }).pipe(map$1(({ data }) => data));
452
+ }
453
+ /**
454
+ * Cancels a delivery confirmation by sending an OTP and additional data to the server.
455
+ *
456
+ * @param {Object} param0 - The parameter object containing the required properties.
457
+ * @param {string} param0.otp - The one-time password to authenticate the cancellation request.
458
+ * @param {Object} param0.body - Additional body data required for cancellation.
459
+ * @return {Observable<Object>} An observable that emits the server's response when the cancellation is processed.
460
+ */
461
+ putDeliveryConfirmation({ otp, ...body }) {
462
+ return this.httpClient.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
463
+ headers: { appkey: this.appKey },
464
+ }).pipe(map$1(({ data }) => data));
465
+ }
466
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
467
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, providedIn: 'root' });
468
+ }
469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiExternalPickupsService, decorators: [{
470
+ type: Injectable,
471
+ args: [{
472
+ providedIn: 'root'
473
+ }]
474
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
475
+ type: Inject,
476
+ args: ['env']
477
+ }] }] });
478
+
378
479
  class ApiInvoicesService {
379
480
  environments;
380
481
  http;
@@ -388,15 +489,25 @@ class ApiInvoicesService {
388
489
  * @return {string} The API URL for invoices.
389
490
  */
390
491
  get url() {
391
- return this.environments.apiInvoicesUrl;
492
+ return this.environments.apiInvoicesUrl ?? '';
493
+ }
494
+ /**
495
+ * Sends an operation document to the server and processes the response.
496
+ *
497
+ * @param {OperationDocumentIn} body - The input data for the operation document.
498
+ * @return {Observable<OperationDocumentOut>} An observable containing the processed operation document output.
499
+ */
500
+ postOperationDocument(body) {
501
+ return this.http.post(`${this.url}/operation/document`, body)
502
+ .pipe(map(({ data }) => data));
392
503
  }
393
504
  /**
394
505
  * Fetches and returns the collection receipt data for a given collection ID.
395
506
  *
396
507
  * @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
397
- * @return {Observable<CollectionReceiptOut>} An observable containing the collection receipt data.
508
+ * @return {Observable<PrintCollectionReceiptOut>} An observable containing the collection receipt data.
398
509
  */
399
- printCollectionReceipt(id) {
510
+ getPrintCollectionReceipt(id) {
400
511
  return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
401
512
  .pipe(map(({ data }) => data));
402
513
  }
@@ -404,10 +515,10 @@ class ApiInvoicesService {
404
515
  * Handles the account payment operation by sending a POST request to the specified endpoint.
405
516
  * Processes the response and returns the operation data.
406
517
  *
407
- * @param {AccountPaymentOperationIn} body The payload containing information for the account payment operation.
408
- * @return {Observable<AccountPaymentOperationOut>} An observable emitting the processed account payment operation data.
518
+ * @param {OperationAccountPaymentIn} body The payload containing information for the account payment operation.
519
+ * @return {Observable<OperationAccountPaymentOut>} An observable emitting the processed account payment operation data.
409
520
  */
410
- accountPaymentOperation(body) {
521
+ postOperationAccountPayment(body) {
411
522
  return this.http.post(`${this.url}/operation/account-payment`, body)
412
523
  .pipe(map(({ data }) => data));
413
524
  }
@@ -418,7 +529,7 @@ class ApiInvoicesService {
418
529
  * @param body The data required to cancel the payment receipt, encapsulated in a CancelPaymentReceiptIn object.
419
530
  * @return An Observable representing the result of the cancellation. Emits an empty object on success.
420
531
  */
421
- cancelPaymentReceipt(body) {
532
+ postOperationCancelDocument(body) {
422
533
  return this.http.post(`${this.url}/operation/cancel-document`, body)
423
534
  .pipe(map(({ data }) => data));
424
535
  }
@@ -428,10 +539,70 @@ class ApiInvoicesService {
428
539
  * @param {Object} parameters - The parameters required to cancel the invoice, encapsulated in a CancelBillingIn object.
429
540
  * @return {Observable<Object>} An observable that emits the response of the cancellation operation.
430
541
  */
431
- cancelInvoice({ invoiceId, ...body }) {
542
+ postOperationCancelBilling({ invoiceId, ...body }) {
432
543
  return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
433
544
  .pipe(map(({ data }) => data));
434
545
  }
546
+ /**
547
+ * Fetches a list of customer types from the server.
548
+ *
549
+ * @param {QueryParams} params - Query parameters to filter or customize the request.
550
+ * @return {Observable<CustomerTypesOut>} An observable emitting the customer types fetched from the server.
551
+ */
552
+ getCustomerTypes(params) {
553
+ return this.http.get(`${this.url}/customer-types`, { params })
554
+ .pipe(map(({ data }) => data));
555
+ }
556
+ /**
557
+ * Retrieves document types specific to a given country.
558
+ *
559
+ * @param {QueryParams} params - The query parameters containing country-specific information.
560
+ * @return {Observable<CustomerDocumentTypesOut>} An observable emitting the document types available for the specified country.
561
+ */
562
+ getCustomerDocumentTypes(params) {
563
+ return this.http.get(`${this.url}/customer-country-document-types`, { params })
564
+ .pipe(map(({ data }) => data));
565
+ }
566
+ /**
567
+ * Fetches customer invoice details filtered by a custom invoice type.
568
+ *
569
+ * @param {InvoiceTypeCustomParamsIn} params - An object containing the filter parameters for the custom invoice type.
570
+ * @return {Observable<CustomersOut>} An observable containing customer invoice details of the specified type.
571
+ */
572
+ getCustomers(params) {
573
+ return this.http.get(`${this.url}/customers`, { params })
574
+ .pipe(map(({ data }) => data));
575
+ }
576
+ /**
577
+ * Sends a POST request to create or update an external shipment operation.
578
+ *
579
+ * @param {OperationShipmentExternalIn} params - The input parameters for the external shipment operation.
580
+ * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external shipment operation.
581
+ */
582
+ postOperationShipmentExternal(params) {
583
+ return this.http.post(`${this.url}/operation/shipment/external`, params)
584
+ .pipe(map(({ data }) => data));
585
+ }
586
+ /**
587
+ * Processes an external payment operation for a shipment.
588
+ *
589
+ * @param {OperationShipmentExternalIn} params - The input parameters required for the external payment operation.
590
+ * @return {Observable<OperationShipmentExternalOut>} An observable that emits the result of the external payment operation for a shipment.
591
+ */
592
+ postOperationShipmentExternalPayment(params) {
593
+ return this.http.post(`${this.url}/operation/shipment/external/payment`, params)
594
+ .pipe(map(({ data }) => data));
595
+ }
596
+ /**
597
+ * Retrieves and returns billing operation print details for a given document ID.
598
+ *
599
+ * @param {number} documentId - The ID of the document for which to fetch the print billing operation details.
600
+ * @return {Observable<OperationPrintDocumentOut>} An observable emitting the print billing operation details for the specified document.
601
+ */
602
+ getOperationPrintDocument(documentId) {
603
+ return this.http.get(`${this.url}/operation/print/document/${documentId}`)
604
+ .pipe(map(({ data }) => data));
605
+ }
435
606
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
436
607
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
437
608
  }
@@ -445,6 +616,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
445
616
  args: ['env']
446
617
  }] }, { type: i1.HttpClient }] });
447
618
 
619
+ class ApiOpenItemsService {
620
+ environments;
621
+ http;
622
+ constructor(environments, http) {
623
+ this.environments = environments;
624
+ this.http = http;
625
+ }
626
+ /**
627
+ * Retrieves the API URL for open-items from the environments' configuration.
628
+ *
629
+ * @return {string} The API URL for open-items.
630
+ */
631
+ get url() {
632
+ return this.environments.apiOpenItemsUrl ?? '';
633
+ }
634
+ /**
635
+ * Retrieves a list of open-items based on the provided query parameters.
636
+ *
637
+ * @param {QueryParams} params - The parameters to use for querying open-items.
638
+ * @return {Observable<OpenItemsOut>} An observable that emits the open-item's data.
639
+ */
640
+ getOpenItems(params) {
641
+ return this.http.get(`${this.url}/open-items`, { params })
642
+ .pipe(map(({ data }) => data));
643
+ }
644
+ /**
645
+ * Processes a payment for an open item.
646
+ *
647
+ * @param {PaymentOpenItemIn} body - The payment details for the open item.
648
+ * @return {Observable<PaymentOut>} An observable that emits the result of the payment processing.
649
+ */
650
+ postPayment(body) {
651
+ return this.http.post(`${this.url}/payment`, body)
652
+ .pipe(map(({ data }) => data));
653
+ }
654
+ /**
655
+ * Processes a payment for other invoice.
656
+ *
657
+ * @param {OtherInvoiceIn} body - The payment details for the other invoice.
658
+ * @return {Observable<OtherInvoiceOut>} An observable that emits the result of the payment processing.
659
+ */
660
+ postOtherInvoice(body) {
661
+ return this.http.post(`${this.url}/other-invoices`, body)
662
+ .pipe(map(({ data }) => data));
663
+ }
664
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
665
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, providedIn: 'root' });
666
+ }
667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiOpenItemsService, decorators: [{
668
+ type: Injectable,
669
+ args: [{
670
+ providedIn: 'root'
671
+ }]
672
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
673
+ type: Inject,
674
+ args: ['env']
675
+ }] }, { type: i1.HttpClient }] });
676
+
448
677
  class ApiReportsService {
449
678
  environments;
450
679
  http;
@@ -458,7 +687,7 @@ class ApiReportsService {
458
687
  * @return {string} The URL of the reports API.
459
688
  */
460
689
  get url() {
461
- return this.environments.apiReportsUrl;
690
+ return this.environments.apiReportsUrl ?? '';
462
691
  }
463
692
  /**
464
693
  * Retrieves the list of collection payments
@@ -471,6 +700,52 @@ class ApiReportsService {
471
700
  params
472
701
  }).pipe(map(({ data }) => data));
473
702
  }
703
+ /**
704
+ * Fetches the list of shipments with pending payments.
705
+ *
706
+ * @param {ExistPendingPaymentsIn} params - The parameters to filter pending payment shipments.
707
+ * @return {Observable<ShipmentsReportOut>} An observable emitting the shipments report data.
708
+ */
709
+ shipmentsPendingPayments(params) {
710
+ return this.http.get(`${this.url}/shipments-report`, {
711
+ params: {
712
+ ...params,
713
+ limit: 1,
714
+ offset: 0,
715
+ to_landing: true,
716
+ shipment_status_code: 'PMPEN',
717
+ },
718
+ }).pipe(map(({ data }) => data));
719
+ }
720
+ /**
721
+ * Fetches shipment reports that are pending invoices based on the specified parameters.
722
+ * This method retrieves a filtered list of shipments with pending invoice statuses.
723
+ *
724
+ * @param {ExistPendingInvoicesIn} params - The parameters to filter the pending invoices, including
725
+ * shipment status codes, and pagination options.
726
+ * @return {Observable<ShipmentsReportOut>} An observable that emits the shipment report data based on the filter criteria.
727
+ */
728
+ shipmentsPendingInvoices(params) {
729
+ return this.http.get(`${this.url}/shipments-report`, {
730
+ params: {
731
+ ...params,
732
+ limit: 1,
733
+ offset: 0,
734
+ to_landing: true,
735
+ 'shipment_status_code[in]': 'IPMPE,IMPEN,IPPEN',
736
+ },
737
+ }).pipe(map(({ data }) => data));
738
+ }
739
+ /**
740
+ * Fetches shipment reports based on the provided query parameters.
741
+ *
742
+ * @param {QueryParams} params - The query parameters used to filter or define the shipment reports.
743
+ * @return {Observable<ShipmentsReportOut>} An observable emitting the shipment report data.
744
+ */
745
+ getShipmentsReport(params) {
746
+ return this.http.get(`${this.url}/shipments-report`, { params })
747
+ .pipe(map(({ data }) => data));
748
+ }
474
749
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
475
750
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
476
751
  }
@@ -499,23 +774,25 @@ class ApiSecurityService {
499
774
  * @return {string} The API security URL.
500
775
  */
501
776
  get url() {
502
- return this.environments.apiSecurityUrl;
777
+ return this.environments.apiSecurityUrl ?? '';
503
778
  }
504
779
  /**
505
- * Authenticates a user with the provided credentials and role.
780
+ * Performs user authentication by sending login credentials to the server.
506
781
  *
507
- * @param {Object} param0 - The login input object.
508
- * @param {string} param0.username - The username of the user.
509
- * @param {string} param0.password - The password of the user.
510
- * @param {string} param0.role - The role of the user.
511
- * @return {Observable<LoginOut>} An observable emitting the login output object.
782
+ * @param {Object} params - An object containing the user's login credentials and system details.
783
+ * @param {string} params.username - The username of the user attempting to log in.
784
+ * @param {string} params.password - The user's password.
785
+ * @param {string} params.role - The role of the user (e.g., admin, user).
786
+ * @param {string} params.system_name - The name of the system the user is logging into.
787
+ *
788
+ * @return {Observable<AuthLoginOut>} An observable that emits the authentication result, including tokens and user information.
512
789
  */
513
- login({ username, password, role, }) {
790
+ postAuthLogin({ username, password, role, system_name }) {
514
791
  return this.http.post(`${this.url}/auth/login`, {
515
- system_name: 'CRA',
516
792
  username,
517
793
  password,
518
794
  role,
795
+ system_name,
519
796
  }).pipe(map(({ data }) => data), tap(({ access_token }) => this.cookie.set(this.environments.authCookie, access_token, { path: '/' })));
520
797
  }
521
798
  /**
@@ -525,7 +802,7 @@ class ApiSecurityService {
525
802
  *
526
803
  * @return {Observable<{}>} An observable that emits the server's response to the logout request.
527
804
  */
528
- logout() {
805
+ postAuthLogout() {
529
806
  return this.http.post(`${this.url}/auth/logout`, null)
530
807
  .pipe(map(({ data }) => data), tap(() => this.cookie.delete(this.environments.authCookie, '/')));
531
808
  }
@@ -537,9 +814,9 @@ class ApiSecurityService {
537
814
  * @param {string} params.modelId - The ID of the model.
538
815
  * @param {string} [params.token] - Optional authorization token.
539
816
  *
540
- * @return {Observable<CreateSessionOut>} An observable containing the created session details.
817
+ * @return {Observable<SessionOut>} An observable containing the created session details.
541
818
  */
542
- createSession({ modelType, modelId, token, }) {
819
+ postSession({ modelType, modelId, token, }) {
543
820
  let headers = new HttpHeaders({});
544
821
  if (token) {
545
822
  headers = headers.set('Authorization', `Bearer ${token}`);
@@ -556,9 +833,9 @@ class ApiSecurityService {
556
833
  * Sends a GET request to the endpoint '/auth/me' to retrieve information
557
834
  * about the currently authenticated user.
558
835
  *
559
- * @return {Observable<MeOut>} An observable that emits the authenticated user's data.
836
+ * @return {Observable<AuthMeOut>} An observable that emits the authenticated user's data.
560
837
  */
561
- me() {
838
+ getAuthMe() {
562
839
  return this.http.get(`${this.url}/auth/me`)
563
840
  .pipe(map(({ data }) => data));
564
841
  }
@@ -568,7 +845,7 @@ class ApiSecurityService {
568
845
  * @param token The JWT token used for authorization.
569
846
  * @return An Observable that emits the user's details encapsulated in a MeOut object.
570
847
  */
571
- otherMe(token) {
848
+ getOtherMe(token) {
572
849
  return this.http.get(`${this.url}/auth/me`, {
573
850
  headers: {
574
851
  Authorization: `Bearer ${token}`
@@ -581,7 +858,7 @@ class ApiSecurityService {
581
858
  * @param {number} id - The unique identifier of the user to be fetched.
582
859
  * @return {Observable<GetUserOut>} An observable containing the user information.
583
860
  */
584
- user(id) {
861
+ getUser(id) {
585
862
  return this.http.get(`${this.url}/users/${id}`)
586
863
  .pipe(map(({ data }) => data));
587
864
  }
@@ -590,9 +867,9 @@ class ApiSecurityService {
590
867
  *
591
868
  * @param {Object} params - The input parameters for changing the language.
592
869
  * @param {string} params.languageId - The ID of the new language to be set.
593
- * @return {Observable<ApiSuccess<MeOut>>} An observable that emits the result of the language change request.
870
+ * @return {Observable<ApiSuccess<AuthMeOut>>} An observable that emits the result of the language change request.
594
871
  */
595
- changeLanguage({ languageId }) {
872
+ putChangeLanguage({ languageId }) {
596
873
  return this.http.put(`${this.url}/auth/me`, {
597
874
  language_id: languageId
598
875
  }).pipe(map(({ data }) => data));
@@ -601,7 +878,7 @@ class ApiSecurityService {
601
878
  * Retrieves a list of roles with their permissions.
602
879
  *
603
880
  * @param {QueryParams} params - The query parameters to filter the roles.
604
- * @returns {Observable<RolePermissionsIn[]>} An observable that emits an array of role permissions.
881
+ * @returns {Observable<RoleIn[]>} An observable that emits an array of role permissions.
605
882
  */
606
883
  getRoles(params) {
607
884
  return this.http.get(`${this.url}/roles`, {
@@ -619,34 +896,23 @@ class ApiSecurityService {
619
896
  params
620
897
  }).pipe(map(({ data }) => data));
621
898
  }
622
- /**
623
- * Retrieves the permissions for a module.
624
- *
625
- * @param {QueryParams} params - The query parameters to be sent with the request.
626
- * @returns {Observable<ModulePermissionsOut>} An observable containing the module permissions.
627
- */
628
- getPermissions(params) {
629
- return this.http.get(`${this.url}/modules`, {
630
- params
631
- }).pipe(map(({ data }) => data));
632
- }
633
899
  /**
634
900
  * Retrieves roles by the specified ID.
635
901
  *
636
- * @param params - The ID of the role to retrieve.
902
+ * @param id - The ID of the role to retrieve.
637
903
  * @returns An Observable that emits the role data.
638
904
  */
639
- getRolesById(params) {
640
- return this.http.get(`${this.url}/roles/${params}`)
905
+ getRole(id) {
906
+ return this.http.get(`${this.url}/roles/${id}`)
641
907
  .pipe(map(({ data }) => data));
642
908
  }
643
909
  /**
644
910
  * Creates a new role with the specified permissions.
645
911
  *
646
- * @param {RolePermissionsIn} body - The permissions and details for the new role.
647
- * @returns {Observable<ModulePermissionsOut>} An observable containing the created role's permissions.
912
+ * @param {RoleIn} body - The permissions and details for the new role.
913
+ * @returns {Observable<RoleOut>} An observable containing the created role's permissions.
648
914
  */
649
- createRole(body) {
915
+ postRole(body) {
650
916
  return this.http.post(`${this.url}/roles`, body)
651
917
  .pipe(map(({ data }) => data));
652
918
  }
@@ -657,7 +923,7 @@ class ApiSecurityService {
657
923
  * @param body - The new permissions to assign to the role.
658
924
  * @returns An Observable that emits the updated module permissions.
659
925
  */
660
- updateRolePermissions(id, body) {
926
+ putRole(id, body) {
661
927
  return this.http.put(`${this.url}/roles/${id}`, body)
662
928
  .pipe(map(({ data }) => data));
663
929
  }
@@ -667,10 +933,36 @@ class ApiSecurityService {
667
933
  * @param {number} id - The unique identifier of the role whose permissions are to be deleted.
668
934
  * @returns {Observable<{}>} An observable that emits the result of the delete operation.
669
935
  */
670
- deleteRolePermissions(id) {
936
+ deleteRole(id) {
671
937
  return this.http.delete(`${this.url}/roles/${id}`)
672
938
  .pipe(map(({ data }) => data));
673
939
  }
940
+ /**
941
+ * Retrieves a list of modules and permissions
942
+ *
943
+ * @param queryParams - The query parameters to filter the modules.
944
+ * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
945
+ */
946
+ getModules(queryParams) {
947
+ return this.http.get(`${this.url}/modules`, {
948
+ params: queryParams
949
+ }).pipe(map(({ data }) => data));
950
+ }
951
+ /**
952
+ * Retrieves a list of modules and permissions
953
+ *
954
+ * @param params.token - Custom token for authorization.
955
+ * @param params.queryParams - The query parameters to filter the modules.
956
+ * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
957
+ */
958
+ getModulesByToken(params) {
959
+ return this.http.get(`${this.url}/modules`, {
960
+ params: params.queryParams,
961
+ headers: {
962
+ Authorization: `Bearer ${params.token}`
963
+ }
964
+ }).pipe(map(({ data }) => data));
965
+ }
674
966
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
675
967
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
676
968
  }
@@ -697,7 +989,7 @@ class ApiShipmentsService {
697
989
  * @return {string} The URL of the shipments API.
698
990
  */
699
991
  get url() {
700
- return this.environments.apiShipmentUrl;
992
+ return this.environments.apiShipmentUrl ?? '';
701
993
  }
702
994
  /**
703
995
  * Retrieves the parameter values based on the provided parameter names.
@@ -706,10 +998,20 @@ class ApiShipmentsService {
706
998
  * @return {Observable<ValidateAccountIn>} An observable that emits the fetched parameter values
707
999
  * @param body
708
1000
  */
709
- validateAccount(body) {
1001
+ postValidateAccount(body) {
710
1002
  return this.http.post(`${this.url}/accounts`, body)
711
1003
  .pipe(map(({ data }) => data));
712
1004
  }
1005
+ /**
1006
+ * Sends a POST request to the shipments manifest endpoint with the provided body.
1007
+ *
1008
+ * @param body - The request payload of type `ManifestMultipleIn`.
1009
+ * @returns An observable that emits the response data of type `ManifestMultipleOut`.
1010
+ */
1011
+ postManifestMultiple(body) {
1012
+ return this.http.post(`${this.url}/shipments/manifest`, body)
1013
+ .pipe(map(({ data }) => data));
1014
+ }
713
1015
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
714
1016
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
715
1017
  }
@@ -723,6 +1025,117 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
723
1025
  args: ['env']
724
1026
  }] }, { type: i1.HttpClient }] });
725
1027
 
1028
+ class WebSocketsService {
1029
+ environments;
1030
+ pusher;
1031
+ constructor(environments) {
1032
+ this.environments = environments;
1033
+ this.pusher = null;
1034
+ this.connect()
1035
+ .then((pusher) => {
1036
+ if (!pusher)
1037
+ return;
1038
+ this.pusher = pusher;
1039
+ });
1040
+ }
1041
+ /**
1042
+ * Publishes an event to the specified channel with the given data.
1043
+ *
1044
+ * @param {Channel} channel - The channel instance where the event will be published.
1045
+ * @param {string} eventName - The name of the event to be published.
1046
+ * @param {T} data - The payload data to be sent with the event.
1047
+ * @return {Promise<boolean>} A promise that resolves to a boolean indicating
1048
+ * whether the event was successfully triggered on the channel.
1049
+ */
1050
+ async pub(channel, eventName, data) {
1051
+ return channel.trigger(`client-${eventName}`, data);
1052
+ }
1053
+ /**
1054
+ * Subscribes to a specified channel, retrying multiple times upon failure.
1055
+ *
1056
+ * @param {string} channelName - The name of the channel to be subscribed to.
1057
+ * @return {Promise<Channel>} A promise that resolves to the subscribed channel object if successful.
1058
+ * @throws {Error} If the subscription fails after the maximum number of retry attempts.
1059
+ */
1060
+ async channelSub(channelName) {
1061
+ const attempts = 3;
1062
+ for (let attempt = 0; attempt <= attempts; attempt++) {
1063
+ const channel = this.pusher?.channel(channelName);
1064
+ if (channel?.subscribed) {
1065
+ return channel;
1066
+ }
1067
+ this.pusher?.subscribe(channelName);
1068
+ if (attempt < attempts) {
1069
+ await this.wait();
1070
+ }
1071
+ }
1072
+ throw new Error(`Failed to subscribe to channel "${channelName}" after ${attempts} attempts.`);
1073
+ }
1074
+ /**
1075
+ * Binds an event listener to a specified event on a given channel using Pusher or a Channel object,
1076
+ * and returns an Observable that emits event data of type T.
1077
+ *
1078
+ * @param {Channel|string} channel - The channel to bind the event to. It can be a Channel object or a string representing the channel name.
1079
+ * @param {string} event - The name of the event to bind to the channel.
1080
+ * @return {Observable<T>} An Observable that emits data of type T when the specified event is triggered.
1081
+ */
1082
+ eventBind(channel, event) {
1083
+ return new Observable((subscriber) => {
1084
+ if (channel?.name) {
1085
+ channel.bind(event, (data) => subscriber.next(data));
1086
+ }
1087
+ else {
1088
+ this.pusher?.subscribe(channel)
1089
+ .bind(event, (data) => subscriber.next(data));
1090
+ }
1091
+ });
1092
+ }
1093
+ /**
1094
+ * Unbinds an event from the specified channel and returns an observable
1095
+ * that emits data when the event callback is triggered.
1096
+ *
1097
+ * @param {Channel} channel - The channel object from which the event should be unbound.
1098
+ * @param {string} event - The name of the event to unbind.
1099
+ * @return {Observable<T>} An observable that emits data from the unbound event callback.
1100
+ */
1101
+ eventUnbind(channel, event) {
1102
+ return new Observable((subscriber) => channel.unbind(event, (data) => subscriber.next(data)));
1103
+ }
1104
+ connect() {
1105
+ return new Promise((resolve) => {
1106
+ const { sockets } = this.environments;
1107
+ if (!sockets)
1108
+ return resolve(false);
1109
+ const pusher = new Pusher(sockets.app_key, {
1110
+ wsHost: sockets.url,
1111
+ wsPort: sockets.port,
1112
+ enabledTransports: ['wss', 'ws'],
1113
+ forceTLS: false,
1114
+ enableStats: false,
1115
+ });
1116
+ if (sockets.debug) {
1117
+ Pusher.logToConsole = true;
1118
+ }
1119
+ return resolve(pusher);
1120
+ });
1121
+ }
1122
+ async wait() {
1123
+ const waitTime = 3 * 1000;
1124
+ return new Promise((resolve) => setTimeout(resolve, waitTime));
1125
+ }
1126
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1127
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, providedIn: 'root' });
1128
+ }
1129
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WebSocketsService, decorators: [{
1130
+ type: Injectable,
1131
+ args: [{
1132
+ providedIn: 'root',
1133
+ }]
1134
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1135
+ type: Inject,
1136
+ args: ['env']
1137
+ }] }] });
1138
+
726
1139
  class CryptoService {
727
1140
  environments;
728
1141
  constructor(environments) {
@@ -895,6 +1308,71 @@ function httpCachingInterceptor(req, next) {
895
1308
  }));
896
1309
  }
897
1310
 
1311
+ /**
1312
+ * Convert an object of key-value pairs into a URL query string.
1313
+ *
1314
+ * @param {Object} params - The key-value pairs to converted into a query string.
1315
+ *
1316
+ * @return {string} - The generated query string.
1317
+ */
1318
+ const queryString = (params) => {
1319
+ const queryElements = [];
1320
+ Object.entries(params).forEach(([key, value]) => {
1321
+ if (Array.isArray(value)) {
1322
+ const arrayQuery = value
1323
+ .map((item) => `${encodeURIComponent(key)}=${encodeURIComponent(item)}`)
1324
+ .join('&');
1325
+ queryElements.push(arrayQuery);
1326
+ }
1327
+ else {
1328
+ const encodedQuery = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
1329
+ queryElements.push(encodedQuery);
1330
+ }
1331
+ });
1332
+ const queryString = queryElements.join('&');
1333
+ return queryString.length ? `?${queryString}` : '';
1334
+ };
1335
+ /**
1336
+ * Creates an instance of HttpParams using the provided params object.
1337
+ *
1338
+ * @param {Object} params - The object containing the params to the HttpParams constructor.
1339
+ *
1340
+ * @returns {HttpParams} - An instance of HttpParams created from the params object.
1341
+ */
1342
+ const httpParams = (params) => new HttpParams({
1343
+ fromObject: params
1344
+ });
1345
+ /**
1346
+ * Returns the headers for generating PDF files.
1347
+ *
1348
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
1349
+ *
1350
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating PDF files.
1351
+ */
1352
+ const pdfHeaders = (format = 'object') => {
1353
+ const headers = {
1354
+ Accept: 'application/pdf'
1355
+ };
1356
+ return format === 'object'
1357
+ ? headers
1358
+ : new HttpHeaders(headers);
1359
+ };
1360
+ /**
1361
+ * Returns the headers for generating XML files.
1362
+ *
1363
+ * @param {string} format - The format of the headers, 'object' or 'http_header'.
1364
+ *
1365
+ * @returns {HttpHeaders | { [header: string]: string | string[] }} - The headers for generating XML files.
1366
+ */
1367
+ const xmlHeaders = (format = 'object') => {
1368
+ const headers = {
1369
+ Accept: 'application/xml',
1370
+ };
1371
+ return format === 'object'
1372
+ ? headers
1373
+ : new HttpHeaders(headers);
1374
+ };
1375
+
898
1376
  /*
899
1377
  * Public API Surface of ngx-services
900
1378
  */
@@ -903,5 +1381,5 @@ function httpCachingInterceptor(req, next) {
903
1381
  * Generated bundle index. Do not edit.
904
1382
  */
905
1383
 
906
- export { ApiCompaniesService, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
1384
+ export { ApiBillingDOService, ApiBillingMxService, ApiCompaniesService, ApiExternalPickupsService, ApiInvoicesService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, WebSocketsService, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
907
1385
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map