@infrab4a/connect 4.20.0-beta.12 → 4.20.0-beta.14
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/index.cjs.js +59 -1
- package/index.esm.js +59 -1
- package/package.json +1 -1
- package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +4 -0
- package/src/domain/shopping/services/glampoints-payment.service.d.ts +7 -2
- package/src/domain/shopping/types/glam-credentials.type.d.ts +6 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/payment-card-info.type.d.ts +2 -0
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -2464,7 +2464,8 @@ class AntifraudPixService {
|
|
|
2464
2464
|
}
|
|
2465
2465
|
|
|
2466
2466
|
class GlampointsPaymentService {
|
|
2467
|
-
constructor(paymentRepository) {
|
|
2467
|
+
constructor(glamCredentials, paymentRepository) {
|
|
2468
|
+
this.glamCredentials = glamCredentials;
|
|
2468
2469
|
this.paymentRepository = paymentRepository;
|
|
2469
2470
|
}
|
|
2470
2471
|
async pay(checkout) {
|
|
@@ -2495,6 +2496,63 @@ class GlampointsPaymentService {
|
|
|
2495
2496
|
}));
|
|
2496
2497
|
return payment;
|
|
2497
2498
|
}
|
|
2499
|
+
async rewardByOrder(orderId, user, lineItens) {
|
|
2500
|
+
try {
|
|
2501
|
+
const points = lineItens.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2502
|
+
console.log('GlampointsPaymentService glamCredentials', this.glamCredentials);
|
|
2503
|
+
const result = await axios__default["default"]({
|
|
2504
|
+
method: 'POST',
|
|
2505
|
+
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
2506
|
+
headers: {
|
|
2507
|
+
'Content-Type': 'application/json',
|
|
2508
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2509
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2510
|
+
},
|
|
2511
|
+
timeout: 60000,
|
|
2512
|
+
data: {
|
|
2513
|
+
personId: user.id,
|
|
2514
|
+
rewardType: 50,
|
|
2515
|
+
referenceId: 0,
|
|
2516
|
+
referenceName: `Compra - ${points} produto(s)`,
|
|
2517
|
+
points: points,
|
|
2518
|
+
productId: '',
|
|
2519
|
+
token: this.glamCredentials.integrationToken,
|
|
2520
|
+
orderId,
|
|
2521
|
+
},
|
|
2522
|
+
});
|
|
2523
|
+
console.info('[rewards - rewardByOrder] reward success:', JSON.stringify(result));
|
|
2524
|
+
return result.data;
|
|
2525
|
+
}
|
|
2526
|
+
catch (err) {
|
|
2527
|
+
console.error('[rewards - rewardByOrder] reward request error', JSON.stringify(err));
|
|
2528
|
+
return err;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
async negativateRewardByOrderId(orderId, orderNumber) {
|
|
2532
|
+
try {
|
|
2533
|
+
const result = await axios__default["default"]({
|
|
2534
|
+
method: 'POST',
|
|
2535
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2536
|
+
headers: {
|
|
2537
|
+
'Content-Type': 'application/json',
|
|
2538
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2539
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2540
|
+
},
|
|
2541
|
+
timeout: 60000,
|
|
2542
|
+
data: {
|
|
2543
|
+
rewardType: 51,
|
|
2544
|
+
referenceName: `Pedido #${orderId} cancelado`,
|
|
2545
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2546
|
+
orderId,
|
|
2547
|
+
orderNumber: parseInt(orderNumber.replace(/\D/g, ''), 10),
|
|
2548
|
+
},
|
|
2549
|
+
});
|
|
2550
|
+
return result;
|
|
2551
|
+
}
|
|
2552
|
+
catch (error) {
|
|
2553
|
+
return error;
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2498
2556
|
}
|
|
2499
2557
|
|
|
2500
2558
|
class RoundProductPricesHelper {
|
package/index.esm.js
CHANGED
|
@@ -2458,7 +2458,8 @@ class AntifraudPixService {
|
|
|
2458
2458
|
}
|
|
2459
2459
|
|
|
2460
2460
|
class GlampointsPaymentService {
|
|
2461
|
-
constructor(paymentRepository) {
|
|
2461
|
+
constructor(glamCredentials, paymentRepository) {
|
|
2462
|
+
this.glamCredentials = glamCredentials;
|
|
2462
2463
|
this.paymentRepository = paymentRepository;
|
|
2463
2464
|
}
|
|
2464
2465
|
async pay(checkout) {
|
|
@@ -2489,6 +2490,63 @@ class GlampointsPaymentService {
|
|
|
2489
2490
|
}));
|
|
2490
2491
|
return payment;
|
|
2491
2492
|
}
|
|
2493
|
+
async rewardByOrder(orderId, user, lineItens) {
|
|
2494
|
+
try {
|
|
2495
|
+
const points = lineItens.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2496
|
+
console.log('GlampointsPaymentService glamCredentials', this.glamCredentials);
|
|
2497
|
+
const result = await axios({
|
|
2498
|
+
method: 'POST',
|
|
2499
|
+
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
2500
|
+
headers: {
|
|
2501
|
+
'Content-Type': 'application/json',
|
|
2502
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2503
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2504
|
+
},
|
|
2505
|
+
timeout: 60000,
|
|
2506
|
+
data: {
|
|
2507
|
+
personId: user.id,
|
|
2508
|
+
rewardType: 50,
|
|
2509
|
+
referenceId: 0,
|
|
2510
|
+
referenceName: `Compra - ${points} produto(s)`,
|
|
2511
|
+
points: points,
|
|
2512
|
+
productId: '',
|
|
2513
|
+
token: this.glamCredentials.integrationToken,
|
|
2514
|
+
orderId,
|
|
2515
|
+
},
|
|
2516
|
+
});
|
|
2517
|
+
console.info('[rewards - rewardByOrder] reward success:', JSON.stringify(result));
|
|
2518
|
+
return result.data;
|
|
2519
|
+
}
|
|
2520
|
+
catch (err) {
|
|
2521
|
+
console.error('[rewards - rewardByOrder] reward request error', JSON.stringify(err));
|
|
2522
|
+
return err;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
async negativateRewardByOrderId(orderId, orderNumber) {
|
|
2526
|
+
try {
|
|
2527
|
+
const result = await axios({
|
|
2528
|
+
method: 'POST',
|
|
2529
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2530
|
+
headers: {
|
|
2531
|
+
'Content-Type': 'application/json',
|
|
2532
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2533
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2534
|
+
},
|
|
2535
|
+
timeout: 60000,
|
|
2536
|
+
data: {
|
|
2537
|
+
rewardType: 51,
|
|
2538
|
+
referenceName: `Pedido #${orderId} cancelado`,
|
|
2539
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2540
|
+
orderId,
|
|
2541
|
+
orderNumber: parseInt(orderNumber.replace(/\D/g, ''), 10),
|
|
2542
|
+
},
|
|
2543
|
+
});
|
|
2544
|
+
return result;
|
|
2545
|
+
}
|
|
2546
|
+
catch (error) {
|
|
2547
|
+
return error;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2492
2550
|
}
|
|
2493
2551
|
|
|
2494
2552
|
class RoundProductPricesHelper {
|
package/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { User } from '../../users';
|
|
2
|
+
import { LineItem } from '../models';
|
|
1
3
|
import { Checkout } from '../models/checkout';
|
|
2
4
|
import { Payment } from '../models/payment';
|
|
3
5
|
export interface PaymentProviderGlampoints {
|
|
4
6
|
pay(checkout: Checkout): Promise<Payment>;
|
|
7
|
+
rewardByOrder(orderId: string, user: User, lineItems: LineItem[]): Promise<void>;
|
|
8
|
+
negativateRewardByOrderId(orderId: string, orderNumber: string): Promise<any>;
|
|
5
9
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { User } from '../../users';
|
|
1
2
|
import { PaymentProviderGlampoints } from '../interfaces';
|
|
2
|
-
import { Checkout, Payment } from '../models';
|
|
3
|
+
import { Checkout, LineItem, Payment } from '../models';
|
|
3
4
|
import { PaymentRepository } from '../repositories';
|
|
5
|
+
import { GlamCredentials } from '../types';
|
|
4
6
|
export declare class GlampointsPaymentService implements PaymentProviderGlampoints {
|
|
7
|
+
private glamCredentials;
|
|
5
8
|
private paymentRepository;
|
|
6
|
-
constructor(paymentRepository: PaymentRepository);
|
|
9
|
+
constructor(glamCredentials: GlamCredentials, paymentRepository: PaymentRepository);
|
|
7
10
|
pay(checkout: Checkout): Promise<Payment>;
|
|
11
|
+
rewardByOrder(orderId: string, user: User, lineItens: LineItem[]): Promise<any>;
|
|
12
|
+
negativateRewardByOrderId(orderId: string, orderNumber: string): Promise<any>;
|
|
8
13
|
}
|
|
@@ -2,6 +2,7 @@ export * from './adyen-card.type';
|
|
|
2
2
|
export * from './adyen-credentials.type';
|
|
3
3
|
export * from './antifraud-provider.type';
|
|
4
4
|
export * from './card-info.type';
|
|
5
|
+
export * from './glam-credentials.type';
|
|
5
6
|
export * from './order-tracking-events.type';
|
|
6
7
|
export * from './pagarme-card.type';
|
|
7
8
|
export * from './pagarme-credentials.type';
|
|
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
|
|
|
5
5
|
export declare const withHelpers: <TMixinBase extends MixinCtor<any, any[]> = MixinCtor<any, any[]>>(MixinBase: MixinCtor<any, any[]> & TMixinBase) => {
|
|
6
6
|
new (...args: any[]): {
|
|
7
7
|
[x: string]: any;
|
|
8
|
-
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T
|
|
8
|
+
toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
|
|
9
9
|
isSubCollection<T_1 extends ModelBaseStructure<T_1, T_1["identifiersFields"][number]>, E extends ModelBaseStructure<E, E["identifiersFields"][number]>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
|
|
10
10
|
};
|
|
11
11
|
} & TMixinBase;
|