@fiado/api-invoker 3.6.0 → 3.7.0

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.
@@ -1,7 +1,7 @@
1
1
  import { ApiGatewayResponse } from "@fiado/gateway-adapter";
2
2
  import { IHttpRequest } from "@fiado/http-client";
3
- import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
4
- import { ICardApi } from "./interfaces/ICardApi";
3
+ import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, Status, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
4
+ import { CardsByStatusResponse, ICardApi } from "./interfaces/ICardApi";
5
5
  import { Provider } from "@fiado/type-kit/bin/provider";
6
6
  import { InfoSelfVerifiedStatus } from "@fiado/type-kit/bin/identity";
7
7
  export declare class CardApi implements ICardApi {
@@ -12,6 +12,7 @@ export declare class CardApi implements ICardApi {
12
12
  getById(provider: Provider, id: string, onlyDb?: boolean): Promise<ApiGatewayResponse<CardResponse>>;
13
13
  getByExternalId(provider: Provider, externalId: string): Promise<ApiGatewayResponse<CardResponse>>;
14
14
  getCardByIdExternal(externalCardId: string): Promise<ApiGatewayResponse<any>>;
15
+ getByStatus(provider: Provider, status: Status | string, index?: string, pageSize?: number, order?: "ascending" | "descending"): Promise<ApiGatewayResponse<CardsByStatusResponse>>;
15
16
  evaluateAccountLevelUpdate(directoryId: string): Promise<void>;
16
17
  findCardIssuanceByIds(directoryIds: string[]): Promise<ApiGatewayResponse<any>>;
17
18
  updateIssuance(provider: Provider, input: CardUpdateIssuanceRequest): Promise<ApiGatewayResponse<void>>;
@@ -35,6 +35,18 @@ let CardApi = class CardApi {
35
35
  const url = `${this.baseUrl}/cards/${externalCardId}?raw=true`;
36
36
  return await this.httpRequest.get(url);
37
37
  }
38
+ async getByStatus(provider, status, index, pageSize, order) {
39
+ const queryParts = [];
40
+ if (index !== undefined)
41
+ queryParts.push(`index=${encodeURIComponent(index)}`);
42
+ if (pageSize !== undefined)
43
+ queryParts.push(`pageSize=${pageSize}`);
44
+ if (order !== undefined)
45
+ queryParts.push(`order=${order}`);
46
+ const queryString = queryParts.length ? `?${queryParts.join("&")}` : "";
47
+ const url = `${this.baseUrl}${provider}/status/${status}${queryString}`;
48
+ return await this.httpRequest.get(url);
49
+ }
38
50
  async evaluateAccountLevelUpdate(directoryId) {
39
51
  const url = `${this.baseUrl}accounts/levels`;
40
52
  await this.httpRequest.post(url, { directoryId });
@@ -1,12 +1,17 @@
1
1
  import { ApiGatewayResponse } from "@fiado/gateway-adapter";
2
- import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
2
+ import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, Status, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
3
3
  import { InfoSelfVerifiedStatus } from "@fiado/type-kit/bin/identity";
4
4
  import { Provider } from "@fiado/type-kit/bin/provider";
5
+ export interface CardsByStatusResponse {
6
+ items: CardResponse[];
7
+ index: string | null;
8
+ }
5
9
  export interface ICardApi {
6
10
  getByDirectoryId(provider: Provider, directoryId: string, onlyDb?: boolean): Promise<ApiGatewayResponse<CardResponse>>;
7
11
  getById(provider: Provider, id: string, onlyDb?: boolean): Promise<ApiGatewayResponse<CardResponse>>;
8
12
  getByExternalId(provider: Provider, externalId: string): Promise<ApiGatewayResponse<CardResponse>>;
9
13
  getCardByIdExternal(externalCardId: string): Promise<ApiGatewayResponse<any>>;
14
+ getByStatus(provider: Provider, status: Status | string, index?: string, pageSize?: number, order?: "ascending" | "descending"): Promise<ApiGatewayResponse<CardsByStatusResponse>>;
10
15
  findCardIssuanceByIds(directoryIds: string[]): Promise<ApiGatewayResponse<any>>;
11
16
  updateIssuance(provider: Provider, input: CardUpdateIssuanceRequest): Promise<ApiGatewayResponse<void>>;
12
17
  updateIssuanceObservation(directoryId: string, input: CardIssuanceObservationUpdateRequest): Promise<ApiGatewayResponse<void>>;
@@ -23,6 +23,7 @@ const card_1 = require("./card");
23
23
  const transaction_1 = require("./transaction");
24
24
  const contract_generator_1 = require("./contract-generator");
25
25
  const ContractBusinessApi_1 = __importDefault(require("./contract-business/api/ContractBusinessApi"));
26
+ const MilestoneBusinessApi_1 = __importDefault(require("./milestone-business/api/MilestoneBusinessApi"));
26
27
  const CreditStatementsApi_1 = __importDefault(require("./credit-statements/api/CreditStatementsApi"));
27
28
  const ProductCatalogApi_1 = __importDefault(require("./product-catalog/ProductCatalogApi"));
28
29
  const collector_1 = require("./collector");
@@ -122,6 +123,7 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
122
123
  bind("ICardApi").to(card_1.CardApi);
123
124
  bind("IContractGeneratorApi").to(contract_generator_1.ContractGeneratorApi);
124
125
  bind("IContractBusinessApi").to(ContractBusinessApi_1.default);
126
+ bind("IMilestoneBusinessApi").to(MilestoneBusinessApi_1.default);
125
127
  bind("ICreditStatementsApi").to(CreditStatementsApi_1.default);
126
128
  bind("ICollectorApi").to(collector_1.CollectorApi);
127
129
  bind("IProductCatalogApi").to(ProductCatalogApi_1.default);
package/bin/index.d.ts CHANGED
@@ -72,3 +72,4 @@ export * from "./teams-connector";
72
72
  export * from "./countries-business";
73
73
  export * from "./ai-engine-connector";
74
74
  export * from "./benefits-marketplace";
75
+ export * from "./milestone-business";
package/bin/index.js CHANGED
@@ -88,3 +88,4 @@ __exportStar(require("./teams-connector"), exports);
88
88
  __exportStar(require("./countries-business"), exports);
89
89
  __exportStar(require("./ai-engine-connector"), exports);
90
90
  __exportStar(require("./benefits-marketplace"), exports);
91
+ __exportStar(require("./milestone-business"), exports);
@@ -0,0 +1,9 @@
1
+ import { IHttpRequest } from "@fiado/http-client";
2
+ import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business";
3
+ import { IMilestoneBusinessApi } from "./interfaces/IMilestoneBusinessApi";
4
+ export default class MilestoneBusinessApi implements IMilestoneBusinessApi {
5
+ private httpRequest;
6
+ private readonly baseUrl;
7
+ constructor(httpRequest: IHttpRequest);
8
+ listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
9
+ }
@@ -0,0 +1,41 @@
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
+ const inversify_1 = require("inversify");
16
+ let MilestoneBusinessApi = class MilestoneBusinessApi {
17
+ constructor(httpRequest) {
18
+ this.httpRequest = httpRequest;
19
+ this.baseUrl = process.env.MILESTONE_BUSINESS_LAMBDA_URL || "";
20
+ }
21
+ async listByEventKeyAndDateRange(eventKey, params) {
22
+ const queryParams = new URLSearchParams();
23
+ queryParams.append('eventKey', eventKey);
24
+ queryParams.append('startDate', String(params.startDate));
25
+ queryParams.append('endDate', String(params.endDate));
26
+ if (params.pageSize !== undefined && params.pageSize !== null)
27
+ queryParams.append('pageSize', String(params.pageSize));
28
+ if (params.index)
29
+ queryParams.append('index', params.index);
30
+ if (params.sort)
31
+ queryParams.append('sort', params.sort);
32
+ const url = `${this.baseUrl}private/milestones/by-event-key?${queryParams.toString()}`;
33
+ return await this.httpRequest.get(url);
34
+ }
35
+ };
36
+ MilestoneBusinessApi = __decorate([
37
+ (0, inversify_1.injectable)(),
38
+ __param(0, (0, inversify_1.inject)("IHttpRequest")),
39
+ __metadata("design:paramtypes", [Object])
40
+ ], MilestoneBusinessApi);
41
+ exports.default = MilestoneBusinessApi;
@@ -0,0 +1,8 @@
1
+ import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business";
2
+ export interface IMilestoneBusinessApi {
3
+ /**
4
+ * Lista milestones por eventKey filtrados por rango de eventDate.
5
+ * Usado por el flujo de cálculo de comisiones (eventKey=HomeAzul para USA, HomeRosa para MEX).
6
+ */
7
+ listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './api/MilestoneBusinessApi';
2
+ export * from './api/interfaces/IMilestoneBusinessApi';
@@ -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("./api/MilestoneBusinessApi"), exports);
18
+ __exportStar(require("./api/interfaces/IMilestoneBusinessApi"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
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",
@@ -16,7 +16,7 @@
16
16
  "@fiado/gateway-adapter": "^1.1.50",
17
17
  "@fiado/http-client": "^1.0.7",
18
18
  "@fiado/logger": "^1.0.3",
19
- "@fiado/type-kit": "^3.9.0",
19
+ "@fiado/type-kit": "^3.13.0",
20
20
  "dotenv": "^16.4.7",
21
21
  "i": "^0.3.7",
22
22
  "inversify": "^6.2.2",
@@ -1,8 +1,8 @@
1
1
  import { ApiGatewayResponse } from "@fiado/gateway-adapter";
2
2
  import { IHttpRequest } from "@fiado/http-client";
3
- import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
3
+ import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, Status, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
4
4
  import { inject, injectable } from "inversify";
5
- import { ICardApi } from "./interfaces/ICardApi";
5
+ import { CardsByStatusResponse, ICardApi } from "./interfaces/ICardApi";
6
6
  import { Provider } from "@fiado/type-kit/bin/provider";
7
7
  import { InfoSelfVerifiedStatus } from "@fiado/type-kit/bin/identity";
8
8
 
@@ -39,6 +39,24 @@ export class CardApi implements ICardApi {
39
39
  return await this.httpRequest.get(url);
40
40
  }
41
41
 
42
+ async getByStatus(
43
+ provider: Provider,
44
+ status: Status | string,
45
+ index?: string,
46
+ pageSize?: number,
47
+ order?: "ascending" | "descending"
48
+ ): Promise<ApiGatewayResponse<CardsByStatusResponse>> {
49
+
50
+ const queryParts: string[] = [];
51
+ if (index !== undefined) queryParts.push(`index=${encodeURIComponent(index)}`);
52
+ if (pageSize !== undefined) queryParts.push(`pageSize=${pageSize}`);
53
+ if (order !== undefined) queryParts.push(`order=${order}`);
54
+ const queryString = queryParts.length ? `?${queryParts.join("&")}` : "";
55
+
56
+ const url = `${this.baseUrl}${provider}/status/${status}${queryString}`;
57
+ return await this.httpRequest.get(url);
58
+ }
59
+
42
60
  async evaluateAccountLevelUpdate(directoryId: string): Promise<void> {
43
61
 
44
62
  const url = `${this.baseUrl}accounts/levels`
@@ -1,8 +1,13 @@
1
1
  import { ApiGatewayResponse } from "@fiado/gateway-adapter";
2
- import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
2
+ import { CardIssuanceObservationUpdateRequest, CardResponse, CardUpdateIssuanceRequest, Status, UpdateBankAccountCardRequest } from "@fiado/type-kit/bin/card";
3
3
  import { InfoSelfVerifiedStatus } from "@fiado/type-kit/bin/identity";
4
4
  import { Provider } from "@fiado/type-kit/bin/provider";
5
5
 
6
+ export interface CardsByStatusResponse {
7
+ items: CardResponse[];
8
+ index: string | null;
9
+ }
10
+
6
11
  export interface ICardApi {
7
12
 
8
13
  getByDirectoryId(provider: Provider, directoryId: string, onlyDb?: boolean): Promise<ApiGatewayResponse<CardResponse>>
@@ -13,6 +18,8 @@ export interface ICardApi {
13
18
 
14
19
  getCardByIdExternal(externalCardId: string): Promise<ApiGatewayResponse<any>>;
15
20
 
21
+ getByStatus(provider: Provider, status: Status | string, index?: string, pageSize?: number, order?: "ascending" | "descending"): Promise<ApiGatewayResponse<CardsByStatusResponse>>;
22
+
16
23
  findCardIssuanceByIds(directoryIds: string[]): Promise<ApiGatewayResponse<any>>;
17
24
 
18
25
  updateIssuance(provider: Provider, input: CardUpdateIssuanceRequest): Promise<ApiGatewayResponse<void>>
@@ -25,6 +25,8 @@ import { ITransactionApi, ITransactionPublisher, TransactionPublisher } from "./
25
25
  import { ContractGeneratorApi, IContractGeneratorApi } from "./contract-generator";
26
26
  import { IContractBusinessApi } from "./contract-business";
27
27
  import ContractBusinessApi from "./contract-business/api/ContractBusinessApi";
28
+ import { IMilestoneBusinessApi } from "./milestone-business";
29
+ import MilestoneBusinessApi from "./milestone-business/api/MilestoneBusinessApi";
28
30
  import { ICreditStatementsApi } from "./credit-statements";
29
31
  import CreditStatementsApi from "./credit-statements/api/CreditStatementsApi";
30
32
  import { IProductCatalogApi } from "./product-catalog";
@@ -172,6 +174,7 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
172
174
  bind<ICardApi>("ICardApi").to(CardApi);
173
175
  bind<IContractGeneratorApi>("IContractGeneratorApi").to(ContractGeneratorApi);
174
176
  bind<IContractBusinessApi>("IContractBusinessApi").to(ContractBusinessApi);
177
+ bind<IMilestoneBusinessApi>("IMilestoneBusinessApi").to(MilestoneBusinessApi);
175
178
  bind<ICreditStatementsApi>("ICreditStatementsApi").to(CreditStatementsApi);
176
179
  bind<ICollectorApi>("ICollectorApi").to(CollectorApi);
177
180
  bind<IProductCatalogApi>("IProductCatalogApi").to(ProductCatalogApi);
package/src/index.ts CHANGED
@@ -72,3 +72,4 @@ export * from "./teams-connector";
72
72
  export * from "./countries-business";
73
73
  export * from "./ai-engine-connector";
74
74
  export * from "./benefits-marketplace";
75
+ export * from "./milestone-business";
@@ -0,0 +1,26 @@
1
+ import { inject, injectable } from "inversify";
2
+ import { IHttpRequest } from "@fiado/http-client";
3
+ import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business";
4
+ import { IMilestoneBusinessApi } from "./interfaces/IMilestoneBusinessApi";
5
+
6
+ @injectable()
7
+ export default class MilestoneBusinessApi implements IMilestoneBusinessApi {
8
+
9
+ private readonly baseUrl = process.env.MILESTONE_BUSINESS_LAMBDA_URL || "";
10
+
11
+ constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
12
+ }
13
+
14
+ async listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any> {
15
+ const queryParams = new URLSearchParams();
16
+ queryParams.append('eventKey', eventKey);
17
+ queryParams.append('startDate', String(params.startDate));
18
+ queryParams.append('endDate', String(params.endDate));
19
+ if (params.pageSize !== undefined && params.pageSize !== null) queryParams.append('pageSize', String(params.pageSize));
20
+ if (params.index) queryParams.append('index', params.index);
21
+ if (params.sort) queryParams.append('sort', params.sort);
22
+
23
+ const url = `${this.baseUrl}private/milestones/by-event-key?${queryParams.toString()}`;
24
+ return await this.httpRequest.get(url);
25
+ }
26
+ }
@@ -0,0 +1,9 @@
1
+ import { MilestonesByEventKeyDateRangeParams } from "@fiado/type-kit/bin/milestone-business";
2
+
3
+ export interface IMilestoneBusinessApi {
4
+ /**
5
+ * Lista milestones por eventKey filtrados por rango de eventDate.
6
+ * Usado por el flujo de cálculo de comisiones (eventKey=HomeAzul para USA, HomeRosa para MEX).
7
+ */
8
+ listByEventKeyAndDateRange(eventKey: string, params: MilestonesByEventKeyDateRangeParams): Promise<any>;
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from './api/MilestoneBusinessApi';
2
+ export * from './api/interfaces/IMilestoneBusinessApi';