Skip to content

Commit

Permalink
refactor: update brij structure (#1645)
Browse files Browse the repository at this point in the history
  • Loading branch information
ookami-kb authored Dec 14, 2024
1 parent 8365230 commit d7b7f8f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 57 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
enum BrijOrderStatus {
pending('PENDING'),
accepted('ACCEPTED'),
rejected('REJECTED'),
completed('COMPLETED'),
failed('FAILED'),
unknown('UNKNOWN');

const BrijOrderStatus(this.value);

final String value;

static BrijOrderStatus fromString(String status) {
for (final BrijOrderStatus brijStatus in BrijOrderStatus.values) {
if (brijStatus.value == status) {
return brijStatus;
}
}

return BrijOrderStatus.unknown;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import '../../../../analytics/analytics_manager.dart';
import '../../../../currency/models/amount.dart';
import '../../../../currency/models/currency.dart';
import '../../../../kyc_sharing/data/kyc_repository.dart';
import '../../../../kyc_sharing/models/kyc_order_status.dart';
import '../../../../kyc_sharing/utils/kyc_utils.dart';
import '../../../../ramp_partner/models/ramp_partner.dart';
import '../../../../ramp_partner/models/ramp_type.dart';
import '../../../../tokens/token.dart';
import '../../../../transactions/models/tx_results.dart';
import '../../../../transactions/services/resign_tx.dart';
import '../../../../transactions/services/tx_sender.dart';
import '../models/brij_order_status.dart';

@Singleton(scope: authScope)
class BrijOffRampOrderService implements Disposable {
Expand Down Expand Up @@ -237,16 +237,16 @@ class BrijOffRampOrderService implements Disposable {
);

final orderData = await _kycRepository.fetchOrder(order.partnerOrderId);
final kycStatus = KycOrderStatus.fromString(orderData.status);
final kycStatus = BrijOrderStatus.fromString(orderData.status);

final status = switch (kycStatus) {
KycOrderStatus.completed => OffRampOrderStatus.completed,
KycOrderStatus.unknown ||
KycOrderStatus.rejected =>
BrijOrderStatus.completed => OffRampOrderStatus.completed,
BrijOrderStatus.unknown ||
BrijOrderStatus.rejected =>
OffRampOrderStatus.rejected,
KycOrderStatus.failed => OffRampOrderStatus.failure,
KycOrderStatus.pending => OffRampOrderStatus.waitingPartnerReview,
KycOrderStatus.accepted => OffRampOrderStatus.creatingDepositTx,
BrijOrderStatus.failed => OffRampOrderStatus.failure,
BrijOrderStatus.pending => OffRampOrderStatus.waitingPartnerReview,
BrijOrderStatus.accepted => OffRampOrderStatus.creatingDepositTx,
};

if (status != order.status) {
Expand Down Expand Up @@ -279,16 +279,16 @@ class BrijOffRampOrderService implements Disposable {
);

final orderData = await _kycRepository.fetchOrder(order.partnerOrderId);
final kycStatus = KycOrderStatus.fromString(orderData.status);
final kycStatus = BrijOrderStatus.fromString(orderData.status);

final status = switch (kycStatus) {
KycOrderStatus.completed => OffRampOrderStatus.completed,
KycOrderStatus.unknown ||
KycOrderStatus.rejected =>
BrijOrderStatus.completed => OffRampOrderStatus.completed,
BrijOrderStatus.unknown ||
BrijOrderStatus.rejected =>
OffRampOrderStatus.rejected,
KycOrderStatus.failed => OffRampOrderStatus.failure,
KycOrderStatus.pending => OffRampOrderStatus.waitingPartnerReview,
KycOrderStatus.accepted => OffRampOrderStatus.creatingDepositTx,
BrijOrderStatus.failed => OffRampOrderStatus.failure,
BrijOrderStatus.pending => OffRampOrderStatus.waitingPartnerReview,
BrijOrderStatus.accepted => OffRampOrderStatus.creatingDepositTx,
};

if (status == OffRampOrderStatus.creatingDepositTx) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import '../../../../accounts/auth_scope.dart';
import '../../../../analytics/analytics_manager.dart';
import '../../../../currency/models/amount.dart';
import '../../../../kyc_sharing/data/kyc_repository.dart';
import '../../../../kyc_sharing/models/kyc_order_status.dart';
import '../../../../kyc_sharing/services/kyc_service.dart';
import '../../../../kyc_sharing/utils/kyc_utils.dart';
import '../../../../ramp_partner/models/ramp_partner.dart';
import '../../../../ramp_partner/models/ramp_type.dart';
import '../../../../tokens/token.dart';
import '../models/brij_order_status.dart';

@Singleton(scope: authScope)
class BrijOnRampOrderService implements Disposable {
Expand Down Expand Up @@ -168,16 +168,16 @@ class BrijOnRampOrderService implements Disposable {
);

final orderData = await _kycRepository.fetchOrder(order.partnerOrderId);
final kycStatus = KycOrderStatus.fromString(orderData.status);
final kycStatus = BrijOrderStatus.fromString(orderData.status);

final status = switch (kycStatus) {
KycOrderStatus.completed => OnRampOrderStatus.completed,
KycOrderStatus.unknown ||
KycOrderStatus.rejected =>
BrijOrderStatus.completed => OnRampOrderStatus.completed,
BrijOrderStatus.unknown ||
BrijOrderStatus.rejected =>
OnRampOrderStatus.rejected,
KycOrderStatus.failed => OnRampOrderStatus.failure,
KycOrderStatus.pending => OnRampOrderStatus.waitingPartnerReview,
KycOrderStatus.accepted => OnRampOrderStatus.waitingForDeposit,
BrijOrderStatus.failed => OnRampOrderStatus.failure,
BrijOrderStatus.pending => OnRampOrderStatus.waitingPartnerReview,
BrijOrderStatus.accepted => OnRampOrderStatus.waitingForDeposit,
};

if (status != order.status) {
Expand Down Expand Up @@ -214,16 +214,16 @@ class BrijOnRampOrderService implements Disposable {
);

final orderData = await _kycRepository.fetchOrder(order.partnerOrderId);
final kycStatus = KycOrderStatus.fromString(orderData.status);
final kycStatus = BrijOrderStatus.fromString(orderData.status);

final status = switch (kycStatus) {
KycOrderStatus.completed => OnRampOrderStatus.completed,
KycOrderStatus.unknown ||
KycOrderStatus.rejected =>
BrijOrderStatus.completed => OnRampOrderStatus.completed,
BrijOrderStatus.unknown ||
BrijOrderStatus.rejected =>
OnRampOrderStatus.rejected,
KycOrderStatus.failed => OnRampOrderStatus.failure,
KycOrderStatus.pending => OnRampOrderStatus.waitingPartnerReview,
KycOrderStatus.accepted => OnRampOrderStatus.waitingForDeposit,
BrijOrderStatus.failed => OnRampOrderStatus.failure,
BrijOrderStatus.pending => OnRampOrderStatus.waitingPartnerReview,
BrijOrderStatus.accepted => OnRampOrderStatus.waitingForDeposit,
};

if (status == OnRampOrderStatus.waitingForDeposit) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import '../services/brij_off_ramp_order_service.dart';
import '../services/brij_on_ramp_order_service.dart';

extension BuildContextExt on BuildContext {
Future<void> launchKycOnRamp() async {
Future<void> launchBrijOnRamp() async {
final kycService = sl<KycSharingService>();

await runWithLoader(this, () async => kycService.initialized);
Expand Down Expand Up @@ -139,7 +139,7 @@ extension BuildContextExt on BuildContext {
}
}

Future<void> launchKycOffRamp() async {
Future<void> launchBrijOffRamp() async {
final kycService = sl<KycSharingService>();

await runWithLoader(this, () async => kycService.initialized);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import '../../profile/data/profile_repository.dart';
import '../../ramp_partner/models/ramp_partner.dart';
import '../../ramp_partner/models/ramp_type.dart';
import '../models/profile_data.dart';
import '../partners/brij/widgets/launch.dart';
import '../partners/coinflow/widgets/launch.dart';
import '../partners/guardarian/widgets/launch.dart';
import '../partners/kado/widgets/launch.dart';
import '../partners/kyc/widgets/launch.dart';
import '../partners/moneygram/widgets/launch.dart';
import '../partners/ramp_network/widgets/launch.dart';
import '../partners/scalex/widgets/launch.dart';
Expand Down Expand Up @@ -212,7 +212,7 @@ extension RampBuildContextExt on BuildContext {
case RampPartner.scalex:
launchScalexOnRamp(profile: profile, address: address);
case RampPartner.brij:
launchKycOnRamp();
launchBrijOnRamp();
case RampPartner.moneygram:
launchMoneygramOnRamp(profile: profile);
case RampPartner.coinflow:
Expand All @@ -238,7 +238,7 @@ extension RampBuildContextExt on BuildContext {
case RampPartner.moneygram:
launchMoneygramOffRamp(profile: profile);
case RampPartner.brij:
launchKycOffRamp();
launchBrijOffRamp();
case RampPartner.rampNetwork:
case RampPartner.guardarian:
throw UnimplementedError('Not implemented for $partner');
Expand Down

0 comments on commit d7b7f8f

Please sign in to comment.