Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa
val result = mutableListOf<Config.Task>()

value?.forEach {
result.add(Config.Task(
product = Config.Product.valueOf((it["product"] as String).uppercase()),
distribution = configDistributionFromMap(it["distribution"] as? Map<String, Any> )))
}
result.add(Config.Task(
product = (it["product"] as? String)?.let { Config.Product.valueOf(it.uppercase()) },
operation = (it["operation"] as? String)?.let { Config.Product.valueOf(it.uppercase()) },
distribution = configDistributionFromMap(it["distribution"] as? Map<String, Any> )))
}

return result
}
Expand Down
20 changes: 5 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,16 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
late AtomicConfig _config;
late AtomicTheme _theme;

@override
void initState() {
super.initState();

_theme = AtomicTheme(dark: true);
_config = AtomicConfig(
void _onButtonPressed() {
final AtomicConfig config = AtomicConfig(
scope: 'user-link',
publicToken: '',
tasks: [AtomicTask(product: AtomicProductType.deposit)],
theme: _theme,
theme: AtomicTheme(dark: true),
);
print("config: ${_config.toJson()}");
}

void _onButtonPressed() {
Atomic.transact(
config: _config,
config: config,
environment: TransactEnvironment.production,
presentationStyleIOS: AtomicPresentationStyleIOS.formSheet,
onInteraction: (AtomicTransactInteraction interaction) {
Expand Down Expand Up @@ -81,7 +71,7 @@ class _MyAppState extends State<MyApp> {
id: '',
environment: TransactEnvironment.custom(
'http://localhost:4545', 'http://localhost:3003'),
theme: _theme,
theme: AtomicTheme(dark: true),
presentationStyleIOS: AtomicPresentationStyleIOS.formSheet,
onLaunch: () {
print("onLaunch");
Expand Down
32 changes: 23 additions & 9 deletions lib/src/config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'dart:io' show Platform;

import 'types.dart';
Expand Down Expand Up @@ -145,7 +147,11 @@ class AtomicExperiments {
/// Defines configuration for the tasks you wish to execute as part of the task workflow.
class AtomicTask {
/// One of deposit, verify, switch, or present.
final AtomicProductType product;
@Deprecated('Use operation instead')
final AtomicProductType? product;

/// One of deposit, verify, switch, present, or tax.
final AtomicOperationType? operation;

/// The action to take on completion of the task. Can be either "continue" or "finish." To execute the next task, use "continue." To finish the task workflow and not execute any of the subsequent tasks, use "finish."
/// Default value: "continue"
Expand All @@ -159,17 +165,25 @@ class AtomicTask {
final AtomicDistribution? distribution;

AtomicTask({
required this.product,
@Deprecated('Use operation instead') this.product,
this.operation,
this.onComplete = "continue",
this.onFail = "continue",
this.distribution,
});
}) : assert(operation != null || product != null,
'Either operation or product must be provided');

/// Returns a JSON object representation.
Map<String, dynamic> toJson() {
String? operationValue;
if (operation != null) {
operationValue = operation!.operationName;
} else if (product != null) {
operationValue = product!.productName;
}

return <String, dynamic>{
'product':
product == AtomicProductType.switchPayment ? 'switch' : product.name,
'operation': operationValue,
'onComplete': onComplete,
'onFail': onFail,
'distribution': distribution?.toJson(),
Expand Down Expand Up @@ -295,12 +309,12 @@ class TransactEnvironment {
final String apiPath;

/// Production environment
static const TransactEnvironment production =
TransactEnvironment._('https://transact.atomicfi.com', 'https://api.atomicfi.com');
static const TransactEnvironment production = TransactEnvironment._(
'https://transact.atomicfi.com', 'https://api.atomicfi.com');

/// Sandbox environment
static const TransactEnvironment sandbox =
TransactEnvironment._('https://transact.atomicfi.com', 'https://sandbox-api.atomicfi.com');
static const TransactEnvironment sandbox = TransactEnvironment._(
'https://transact.atomicfi.com', 'https://sandbox-api.atomicfi.com');

/// Custom environment with specified path
static TransactEnvironment custom(String transactPath, String apiPath) =>
Expand Down
31 changes: 21 additions & 10 deletions lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import '../src/events.dart';

/// The product to initiate
enum AtomicProductType {
/// Update the destination bank account of paychecks
deposit,
deposit('deposit'),
verify('verify'),
switchPayment('switch'),
present('present'),
tax('tax');

/// Verify a user's income and employment status
verify,
final String productName;

/// Switch a user's payment method
switchPayment,

/// Subscription management
present,
const AtomicProductType(this.productName);
}

/// Type of distribution
Expand Down Expand Up @@ -111,7 +109,20 @@ typedef AtomicTaskStatusUpdateHandler = void Function(
enum AtomicPresentationStyleIOS {
/// Full screen presentation style
fullScreen,

/// Form sheet presentation style (default)
formSheet,
}

/// The operation type to initiate
enum AtomicOperationType {
deposit('deposit'),
verify('verify'),
switchPayment('switch'),
present('present'),
tax('tax');

final String operationName;

const AtomicOperationType(this.operationName);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 3.13.4
repository: https://github.com/atomicfi/atomic-transact-flutter

environment:
sdk: ">=2.15.1 <4.0.0"
sdk: ">=2.17.0 <4.0.0"
flutter: ">=2.5.0"

dependencies:
Expand Down