@fiado/api-invoker 1.5.43 → 1.5.44
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.
- package/bin/product-payment/api/ProductPaymentApi.d.ts +3 -1
- package/bin/product-payment/api/ProductPaymentApi.js +6 -0
- package/bin/product-payment/api/interfaces/IProductPaymentApi.d.ts +3 -1
- package/package.json +1 -1
- package/src/product-payment/api/ProductPaymentApi.ts +8 -1
- package/src/product-payment/api/interfaces/IProductPaymentApi.ts +3 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IProductPaymentApi } from "./interfaces/IProductPaymentApi";
|
|
2
2
|
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
-
import { ServicePaymentRequest } from "@fiado/type-kit/bin/servicePayment";
|
|
3
|
+
import { GetCatalogParams, ServicePaymentRequest } from "@fiado/type-kit/bin/servicePayment";
|
|
4
4
|
import { ApiGatewayResponse } from "@fiado/gateway-adapter";
|
|
5
5
|
import { Provider } from "@fiado/type-kit/bin/provider";
|
|
6
|
+
import { CountryId } from "@fiado/type-kit/bin/country";
|
|
6
7
|
export default class ProductPaymentApi implements IProductPaymentApi {
|
|
7
8
|
private httpRequest;
|
|
8
9
|
private readonly baseUrl;
|
|
9
10
|
constructor(httpRequest: IHttpRequest);
|
|
11
|
+
getCatalog(params: GetCatalogParams, countryId: CountryId): Promise<ApiGatewayResponse<any>>;
|
|
10
12
|
pay(request: ServicePaymentRequest, provider: Provider): Promise<ApiGatewayResponse<any>>;
|
|
11
13
|
}
|
|
@@ -18,6 +18,12 @@ let ProductPaymentApi = class ProductPaymentApi {
|
|
|
18
18
|
this.httpRequest = httpRequest;
|
|
19
19
|
this.baseUrl = process.env.PRODUCT_PAYMENT_LAMBDA_URL || "";
|
|
20
20
|
}
|
|
21
|
+
async getCatalog(params, countryId) {
|
|
22
|
+
const paramsWithCountry = { ...params, countryId };
|
|
23
|
+
const queryParams = Object.keys(paramsWithCountry).map(key => `${key}=${encodeURIComponent(paramsWithCountry[key])}`).join('&');
|
|
24
|
+
const url = `${this.baseUrl}/catalog?${queryParams}`;
|
|
25
|
+
return await this.httpRequest.get(url);
|
|
26
|
+
}
|
|
21
27
|
async pay(request, provider) {
|
|
22
28
|
const url = `${this.baseUrl}/${provider}/pay`;
|
|
23
29
|
return await this.httpRequest.post(url, request);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ServicePaymentRequest } from "@fiado/type-kit/bin/servicePayment";
|
|
1
|
+
import { GetCatalogParams, ServicePaymentRequest } from "@fiado/type-kit/bin/servicePayment";
|
|
2
2
|
import { ApiGatewayResponse } from "@fiado/gateway-adapter";
|
|
3
3
|
import { Provider } from "@fiado/type-kit/bin/provider";
|
|
4
|
+
import { CountryId } from "@fiado/type-kit/bin/country";
|
|
4
5
|
export interface IProductPaymentApi {
|
|
5
6
|
pay(request: ServicePaymentRequest, provider: Provider): Promise<ApiGatewayResponse<any>>;
|
|
7
|
+
getCatalog(params: GetCatalogParams, countryId: CountryId): Promise<ApiGatewayResponse<any>>;
|
|
6
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.44",
|
|
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",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {IProductPaymentApi} from "./interfaces/IProductPaymentApi";
|
|
2
2
|
import {inject, injectable} from "inversify";
|
|
3
3
|
import {IHttpRequest} from "@fiado/http-client";
|
|
4
|
-
import {ServicePaymentRequest} from "@fiado/type-kit/bin/servicePayment";
|
|
4
|
+
import {GetCatalogParams, ServicePaymentRequest} from "@fiado/type-kit/bin/servicePayment";
|
|
5
5
|
import {ApiGatewayResponse} from "@fiado/gateway-adapter";
|
|
6
6
|
import { Provider } from "@fiado/type-kit/bin/provider";
|
|
7
|
+
import { CountryId } from "@fiado/type-kit/bin/country";
|
|
7
8
|
|
|
8
9
|
@injectable()
|
|
9
10
|
export default class ProductPaymentApi implements IProductPaymentApi {
|
|
@@ -11,6 +12,12 @@ export default class ProductPaymentApi implements IProductPaymentApi {
|
|
|
11
12
|
|
|
12
13
|
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {
|
|
13
14
|
}
|
|
15
|
+
async getCatalog(params: GetCatalogParams, countryId: CountryId): Promise<ApiGatewayResponse<any>> {
|
|
16
|
+
const paramsWithCountry = { ...params, countryId };
|
|
17
|
+
const queryParams = Object.keys(paramsWithCountry).map(key => `${key}=${encodeURIComponent(paramsWithCountry[key])}`).join('&');
|
|
18
|
+
const url = `${this.baseUrl}/catalog?${queryParams}`;
|
|
19
|
+
return await this.httpRequest.get(url);
|
|
20
|
+
}
|
|
14
21
|
|
|
15
22
|
async pay(request: ServicePaymentRequest, provider:Provider): Promise<ApiGatewayResponse<any>> {
|
|
16
23
|
const url = `${this.baseUrl}/${provider}/pay`;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {ServicePaymentRequest} from "@fiado/type-kit/bin/servicePayment";
|
|
1
|
+
import {GetCatalogParams, ServicePaymentRequest} from "@fiado/type-kit/bin/servicePayment";
|
|
2
2
|
import {ApiGatewayResponse} from "@fiado/gateway-adapter";
|
|
3
3
|
import { Provider } from "@fiado/type-kit/bin/provider";
|
|
4
|
+
import { CountryId } from "@fiado/type-kit/bin/country";
|
|
4
5
|
|
|
5
6
|
export interface IProductPaymentApi {
|
|
6
7
|
pay(request: ServicePaymentRequest,provider:Provider): Promise<ApiGatewayResponse<any>>;
|
|
8
|
+
getCatalog(params: GetCatalogParams, countryId:CountryId): Promise<ApiGatewayResponse<any>>;
|
|
7
9
|
}
|