@fiado/api-invoker 1.3.89 → 1.3.91

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.
@@ -60,6 +60,7 @@ const order_collector_business_1 = require("./order-collector-business");
60
60
  const EstafetaApi_1 = __importDefault(require("./estafeta/api/EstafetaApi"));
61
61
  const appselectondata_1 = require("./appselectondata");
62
62
  const directorySetting_1 = require("./directorySetting");
63
+ const firebase_connector_1 = require("./firebase-connector");
63
64
  exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
64
65
  // UTILS bindings
65
66
  bind("InvokerUtils").to(InvokerUtils_1.InvokerUtils);
@@ -118,4 +119,5 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
118
119
  bind("IEstafetaApi").to(EstafetaApi_1.default);
119
120
  bind("IAppSelectionDataApi").to(appselectondata_1.AppSelectionDataApi);
120
121
  bind("IDirectorySettingApi").to(directorySetting_1.DirectorySettingApi);
122
+ bind("IFirebaseConnectorApi").to(firebase_connector_1.FirebaseConnectorApi);
121
123
  });
@@ -0,0 +1,13 @@
1
+ import { IFirebaseConnectorApi } from "./interfaces/IFirebaseConnectorApi";
2
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
3
+ import { IHttpRequest } from "@fiado/http-client";
4
+ export declare class FirebaseConnectorApi implements IFirebaseConnectorApi {
5
+ private readonly httpRequest;
6
+ constructor(httpRequest: IHttpRequest);
7
+ private readonly baseUrl;
8
+ sendMulticastMessage(message: any): Promise<FiadoApiResponse<any>>;
9
+ sendGroupMessage(message: any): Promise<FiadoApiResponse<any>>;
10
+ getRemoteConfig(): Promise<FiadoApiResponse<{
11
+ [key: string]: string;
12
+ }>>;
13
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FirebaseConnectorApi = void 0;
16
+ const inversify_1 = require("inversify");
17
+ const logger_1 = require("@fiado/logger");
18
+ let FirebaseConnectorApi = class FirebaseConnectorApi {
19
+ constructor(httpRequest) {
20
+ this.httpRequest = httpRequest;
21
+ this.baseUrl = process.env.FIREBASE_CONNECTOR_URL || "";
22
+ }
23
+ async sendMulticastMessage(message) {
24
+ try {
25
+ const url = `${this.baseUrl}messages/multicast/send`;
26
+ logger_1.log.info(`Sending multicast message to url: ${url}`);
27
+ return await this.httpRequest.post(url, message);
28
+ }
29
+ catch (error) {
30
+ logger_1.log.error('Error sending multicast message from adapter', error);
31
+ throw new Error('Error sending multicast message from adapter');
32
+ }
33
+ }
34
+ async sendGroupMessage(message) {
35
+ try {
36
+ const url = `${this.baseUrl}messages/group/send`;
37
+ logger_1.log.info(`Sending group message to url: ${url}`);
38
+ return await this.httpRequest.post(url, message);
39
+ }
40
+ catch (error) {
41
+ logger_1.log.error('Error sending group message from adapter', error);
42
+ throw new Error('Error sending group message from adapter');
43
+ }
44
+ }
45
+ async getRemoteConfig() {
46
+ try {
47
+ const url = `${this.baseUrl}remoteconfig`;
48
+ logger_1.log.info(`Getting remote config from url: ${url}`);
49
+ return await this.httpRequest.get(url);
50
+ }
51
+ catch (error) {
52
+ logger_1.log.error('Error getting remote config from adapter', error);
53
+ throw new Error('Error getting remote config from adapter');
54
+ }
55
+ }
56
+ };
57
+ exports.FirebaseConnectorApi = FirebaseConnectorApi;
58
+ exports.FirebaseConnectorApi = FirebaseConnectorApi = __decorate([
59
+ (0, inversify_1.injectable)(),
60
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
61
+ __metadata("design:paramtypes", [Object])
62
+ ], FirebaseConnectorApi);
@@ -0,0 +1,2 @@
1
+ export * from './interfaces/IFirebaseConnectorApi';
2
+ export * from './FirebaseConnectorApi';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces/IFirebaseConnectorApi"), exports);
18
+ __exportStar(require("./FirebaseConnectorApi"), exports);
@@ -0,0 +1,8 @@
1
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
2
+ export interface IFirebaseConnectorApi {
3
+ sendMulticastMessage(message: any): Promise<FiadoApiResponse<any>>;
4
+ sendGroupMessage(message: any): Promise<FiadoApiResponse<any>>;
5
+ getRemoteConfig(): Promise<FiadoApiResponse<{
6
+ [key: string]: string;
7
+ }>>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/bin/index.d.ts CHANGED
@@ -47,3 +47,4 @@ export * from "./order-collector-business";
47
47
  export * from "./estafeta";
48
48
  export * from "./appselectondata";
49
49
  export * from "./directorySetting";
50
+ export * from "./firebase-connector";
package/bin/index.js CHANGED
@@ -63,3 +63,4 @@ __exportStar(require("./order-collector-business"), exports);
63
63
  __exportStar(require("./estafeta"), exports);
64
64
  __exportStar(require("./appselectondata"), exports);
65
65
  __exportStar(require("./directorySetting"), exports);
66
+ __exportStar(require("./firebase-connector"), exports);
@@ -77,10 +77,10 @@ let TransactionApi = class TransactionApi {
77
77
  }
78
78
  async findExpiringPreAuthTransactions(params) {
79
79
  let queryParams = [];
80
- if (!params.index) {
80
+ if (params.index) {
81
81
  queryParams.push(`index=${params.index}`);
82
82
  }
83
- if (!params.pageSize) {
83
+ if (params.pageSize) {
84
84
  queryParams.push(`pageSize=${params.pageSize}`);
85
85
  }
86
86
  queryParams.push(`startDate=${params.startDate}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "1.3.89",
3
+ "version": "1.3.91",
4
4
  "description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -76,6 +76,7 @@ import { IEstafetaApi } from "./estafeta";
76
76
  import EstafetaApi from "./estafeta/api/EstafetaApi";
77
77
  import { AppSelectionDataApi, IAppSelectionDataApi } from "./appselectondata";
78
78
  import { DirectorySettingApi, IDirectorySettingApi } from "./directorySetting";
79
+ import { FirebaseConnectorApi, IFirebaseConnectorApi } from "./firebase-connector";
79
80
 
80
81
  export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
81
82
  // UTILS bindings
@@ -136,4 +137,5 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
136
137
  bind<IEstafetaApi>("IEstafetaApi").to(EstafetaApi);
137
138
  bind<IAppSelectionDataApi>("IAppSelectionDataApi").to(AppSelectionDataApi);
138
139
  bind<IDirectorySettingApi>("IDirectorySettingApi").to(DirectorySettingApi);
140
+ bind<IFirebaseConnectorApi>("IFirebaseConnectorApi").to(FirebaseConnectorApi);
139
141
  });
@@ -0,0 +1,53 @@
1
+
2
+ import { inject, injectable } from "inversify";
3
+ import { IFirebaseConnectorApi } from "./interfaces/IFirebaseConnectorApi";
4
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
5
+ import { IHttpRequest } from "@fiado/http-client";
6
+ import { log } from "@fiado/logger";
7
+ @injectable()
8
+ export class FirebaseConnectorApi implements IFirebaseConnectorApi {
9
+
10
+ constructor(
11
+ @inject("IHttpRequest") private readonly httpRequest: IHttpRequest,
12
+
13
+ ){}
14
+
15
+ private readonly baseUrl = process.env.FIREBASE_CONNECTOR_URL || "";
16
+
17
+ async sendMulticastMessage(message: any): Promise<FiadoApiResponse<any>> {
18
+ try {
19
+ const url: string = `${this.baseUrl}messages/multicast/send`;
20
+ log.info(`Sending multicast message to url: ${url}`);
21
+ return await this.httpRequest.post(url, message);
22
+ } catch (error) {
23
+ log.error('Error sending multicast message from adapter', error as Error);
24
+ throw new Error('Error sending multicast message from adapter');
25
+ }
26
+ }
27
+
28
+ async sendGroupMessage(message: any): Promise<FiadoApiResponse<any>> {
29
+ try {
30
+ const url: string = `${this.baseUrl}messages/group/send`;
31
+ log.info(`Sending group message to url: ${url}`);
32
+ return await this.httpRequest.post(url, message);
33
+ } catch (error) {
34
+ log.error('Error sending group message from adapter', error as Error);
35
+ throw new Error('Error sending group message from adapter');
36
+ }
37
+ }
38
+ async getRemoteConfig(): Promise<FiadoApiResponse<{ [key: string]: string; }>> {
39
+ try {
40
+ const url: string = `${this.baseUrl}remoteconfig`;
41
+ log.info(`Getting remote config from url: ${url}`);
42
+ return await this.httpRequest.get(url);
43
+ } catch (error) {
44
+ log.error('Error getting remote config from adapter', error as Error);
45
+ throw new Error('Error getting remote config from adapter');
46
+ }
47
+ }
48
+
49
+ }
50
+
51
+
52
+
53
+
@@ -0,0 +1,4 @@
1
+
2
+
3
+ export * from './interfaces/IFirebaseConnectorApi';
4
+ export * from './FirebaseConnectorApi';
@@ -0,0 +1,7 @@
1
+ import FiadoApiResponse from "@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse";
2
+
3
+ export interface IFirebaseConnectorApi {
4
+ sendMulticastMessage(message: any): Promise<FiadoApiResponse<any>>;
5
+ sendGroupMessage(message: any): Promise<FiadoApiResponse<any>>;
6
+ getRemoteConfig(): Promise<FiadoApiResponse<{ [key: string]: string }>>;
7
+ }
package/src/index.ts CHANGED
@@ -47,4 +47,6 @@ export * from "./order-collector-business";
47
47
  export * from "./estafeta";
48
48
  export * from "./appselectondata";
49
49
  export * from "./directorySetting";
50
+ export * from "./firebase-connector";
51
+
50
52
 
@@ -108,11 +108,11 @@ export default class TransactionApi implements ITransactionApi {
108
108
 
109
109
  let queryParams = [];
110
110
 
111
- if (!params.index) {
111
+ if (params.index) {
112
112
  queryParams.push(`index=${params.index}`);
113
113
  }
114
114
 
115
- if (!params.pageSize) {
115
+ if (params.pageSize) {
116
116
  queryParams.push(`pageSize=${params.pageSize}`);
117
117
  }
118
118